本文整理匯總了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);
}