本文整理匯總了Java中com.jme3.scene.Geometry.addControl方法的典型用法代碼示例。如果您正苦於以下問題:Java Geometry.addControl方法的具體用法?Java Geometry.addControl怎麽用?Java Geometry.addControl使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.jme3.scene.Geometry
的用法示例。
在下文中一共展示了Geometry.addControl方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: createPlayer
import com.jme3.scene.Geometry; //導入方法依賴的package包/類
/**
* Create a new player.
* @param parentNode Parent of player. Should be root node.
* @param playerIdx Order of created player starting at 0.
* @return Spatial of new player.
*/
private Spatial createPlayer(Node parentNode, int playerIdx) {
// Currently a simple box is used for the player.
Box box = new Box(1, 1, 1);
Geometry player = new Geometry("PLAYER" + playerIdx, box);
Material mat = new Material(application.getAssetManager(),
"Common/MatDefs/Misc/Unshaded.j3md");
mat.setColor("Color", ColorRGBA.Blue);
player.setMaterial(mat);
// Move player in front of first course point.
Spatial[] coursePoints = coursePath.getCoursePoints();
if (coursePoints.length > 0) {
Spatial startPoint = coursePoints[0];
Vector3f forward = startPoint.getWorldRotation().mult(Vector3f.UNIT_Z);
player.move(forward.mult(PLAYER_START_DISTANCE));
}
// Attribute that this is a player.
player.setUserData(IS_PLAYER_ATTR, true);
// Add physics to player
CollisionShape shape = CollisionShapeFactory.createBoxShape(player);
GhostControl playerPhysics = new GhostControl(shape);
player.addControl(playerPhysics);
bullet.getPhysicsSpace().add(playerPhysics);
// Attach to root node and course path.
parentNode.attachChild(player);
coursePath.addPlayer(player);
return player;
}