当前位置: 首页>>代码示例>>Java>>正文


Java Spatial.setUserData方法代码示例

本文整理汇总了Java中com.jme3.scene.Spatial.setUserData方法的典型用法代码示例。如果您正苦于以下问题:Java Spatial.setUserData方法的具体用法?Java Spatial.setUserData怎么用?Java Spatial.setUserData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.jme3.scene.Spatial的用法示例。


在下文中一共展示了Spatial.setUserData方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: processOpen

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
 * The process of opening file.
 *
 * @param file the file
 */
@FXThread
protected void processOpen(@NotNull final Path file) {

    final NodeTree<?> nodeTree = getNodeTree();
    final ChangeConsumer consumer = notNull(nodeTree.getChangeConsumer());
    final SceneLayer defaultLayer = getDefaultLayer(consumer);

    final Path assetFile = notNull(getAssetFile(file), "Not found asset file for " + file);
    final String assetPath = toAssetPath(assetFile);

    final ModelKey modelKey = new ModelKey(assetPath);

    final AssetManager assetManager = EDITOR.getAssetManager();
    final Spatial loadedModel = assetManager.loadModel(modelKey);
    loadedModel.setUserData(LOADED_MODEL_KEY, true);

    if (defaultLayer != null) {
        SceneLayer.setLayer(defaultLayer, loadedModel);
    }

    final TreeNode<?> treeNode = getNode();
    final Node parent = (Node) treeNode.getElement();
    consumer.execute(new AddChildOperation(loadedModel, parent));
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder,代码行数:30,代码来源:LoadModelAction.java

示例2: doClicked

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
private void doClicked( Spatial s ) {
	s.setUserData( ClickMe.class.getSimpleName(), new Object[] { new ClickMe() {
		@Override
		public void clicked( Object data ) {
			doProfile();
		}
	} } );
}
 
开发者ID:twak,项目名称:chordatlas,代码行数:9,代码来源:BlockGen.java

示例3: collision

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
 * Handle collision between player characters and course points.
 * @see PhysicsCollisionListener#collision(PhysicsCollisionEvent)
 */
public void collision(PhysicsCollisionEvent event) {
  Spatial nodeA = event.getNodeA();
  Spatial nodeB = event.getNodeB();

  Spatial player = null;
  Spatial coursePoint = null;
  // Determine which node is the player.
  if (nodeA != null
      && nodeA.getUserData(PlayerManager.IS_PLAYER_ATTR) != null
      && (Boolean) nodeA.getUserData(PlayerManager.IS_PLAYER_ATTR)) {
    player = nodeA;
  } else if (nodeB != null
             && nodeB.getUserData(PlayerManager.IS_PLAYER_ATTR) != null
             && (Boolean) nodeB.getUserData(PlayerManager.IS_PLAYER_ATTR)) {
    player = nodeB;
  }
  // Determine which node is the course point.
  if (nodeA != null
      && nodeA.getUserData(CoursePath.COURSE_ORDER_ATTR) != null) {
    coursePoint = nodeA;
  } else if (nodeB != null
             && nodeB.getUserData(CoursePath.COURSE_ORDER_ATTR) != null) {
    coursePoint = nodeB;
  }
  // If collision is player and course point, check if the course
  // point is the player's target.
  if (player != null && coursePoint != null) {
    int playerTarget
        = player.getUserData(CoursePath.PLAYER_TARGET_POINT_ATTR);
    int courseOrder = coursePoint.getUserData(CoursePath.COURSE_ORDER_ATTR);
    if (playerTarget == courseOrder) {
      // Target reached. Set next target.
      int totalCoursePoints = coursePath.getCoursePoints().length;
      player.setUserData(CoursePath.PLAYER_TARGET_POINT_ATTR,
                         (playerTarget + 1) % totalCoursePoints);
      player.setUserData(CoursePath.PLAYER_ON_COURSE_ATTR, true);
    }
  }
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:44,代码来源:CoursePointCollisionListener.java

示例4: addPlayer

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
 * Add a player that must follow the course.
 * @param player Player spatial.
 */
public void addPlayer(Spatial player) {
  player.setUserData(PLAYER_TARGET_POINT_ATTR, 0);
  player.setUserData(PLAYER_ON_COURSE_ATTR, false);
  players.add(player);
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:10,代码来源:CoursePath.java

示例5: setLayer

import com.jme3.scene.Spatial; //导入方法依赖的package包/类
/**
 * Set a layer to a spatial.
 *
 * @param layer   the layer.
 * @param spatial the spatial.
 */
public static void setLayer(@Nullable final SceneLayer layer, @NotNull final Spatial spatial) {
    spatial.setUserData(KEY, layer == NO_LAYER ? null : layer);
}
 
开发者ID:JavaSaBr,项目名称:jmonkeybuilder-extension,代码行数:10,代码来源:SceneLayer.java


注:本文中的com.jme3.scene.Spatial.setUserData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。