本文整理汇总了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));
}
示例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();
}
} } );
}
示例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);
}
}
}
示例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);
}
示例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);
}