本文整理匯總了Java中com.jme3.scene.Node.getChild方法的典型用法代碼示例。如果您正苦於以下問題:Java Node.getChild方法的具體用法?Java Node.getChild怎麽用?Java Node.getChild使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.jme3.scene.Node
的用法示例。
在下文中一共展示了Node.getChild方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: CoursePath
import com.jme3.scene.Node; //導入方法依賴的package包/類
/**
* Course path constructor. Locate the course path and organise the points
* into an ordered list. Rotate these points to create a smooth path.
* @param scene Root node of scene.
*/
public CoursePath(Node scene, BulletAppState bullet) {
// Locate each course point and create an array of those points ordered by
// the order data in the user data of the spatials.
Spatial coursePath = scene.getChild(COURSE_PATH_NODE_NAME);
final TreeMap<Integer, Spatial> points = new TreeMap<Integer, Spatial>();
coursePath.breadthFirstTraversal(new SceneGraphVisitor() {
public void visit(Spatial spatial) {
Integer order = spatial.getUserData(COURSE_ORDER_ATTR);
if (order != null) {
points.put(order, spatial);
}
}
});
coursePoints = points.values().toArray(new Spatial[0]);
// To create a smooth rotation along the course, each course point is
// rotated to look in the direction of the vector connecting the preceding
// point with the succeeding point.
for (int i = 0; i < coursePoints.length; ++i) {
Spatial current = coursePoints[i];
Spatial previous = i > 0
? coursePoints[i - 1] : coursePoints[coursePoints.length - 1];
Spatial next = coursePoints[(i + 1) % coursePoints.length];
Vector3f lookDirection
= previous.getLocalTranslation().subtract(next.getLocalTranslation());
current.getLocalRotation().lookAt(lookDirection,
new Vector3f(0.0f, 1.0f, 0.0f));
CollisionShape shape = CollisionShapeFactory.createBoxShape(current);
GhostControl physics = new GhostControl(shape);
current.addControl(physics);
bullet.getPhysicsSpace().add(physics);
}
// Install listener for collisions between player and node.
bullet.getPhysicsSpace()
.addCollisionListener(new CoursePointCollisionListener(this));
}