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


Java Node.getChild方法代码示例

本文整理汇总了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));
}
 
开发者ID:meoblast001,项目名称:seally-racing,代码行数:43,代码来源:CoursePath.java


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