Exemplo n.º 1
0
 public final boolean isVehicleReachedCheckpoint(BoundingVolume vehicleBoundingVolume) {
   for (StaticPhysicsNode checkPoint : checkPoints) {
     if (vehicleBoundingVolume.intersects(checkPoint.getWorldBound())) {
       return true;
     }
   }
   return false;
 }
Exemplo n.º 2
0
 private StaticPhysicsNode loadCheckpointModel(String modelPath) {
   StaticPhysicsNode checkPoint = physicsSpace.createStaticNode();
   checkPoint.setLocalTranslation(trackLocation);
   checkPoint.attachChild(ModelUtil.convertOBJToStatial(ResourcesPath.MODELS_PATH + modelPath));
   checkPoint.setLocalScale(1f);
   checkPoint.setMaterial(Material.GHOST);
   StateUtil.makeTransparent(checkPoint);
   return checkPoint;
 }
Exemplo n.º 3
0
 private void createTrack(Vector3f trackLocation) {
   track = physicsSpace.createStaticNode();
   track.setLocalTranslation(trackLocation);
   track.setLocalScale(1f);
   track.attachChild(
       ModelUtil.convertOBJToStatial(ResourcesPath.MODELS_PATH + "obj/raceTrack.obj"));
   track.generatePhysicsGeometry(true);
   track.setMaterial(Material.IRON);
   this.attachChild(track);
 }
Exemplo n.º 4
0
 /**
  * a simple helper method to create a static physic wall.
  *
  * @param name node name
  * @param x x extent
  * @param y y extent
  * @param z z extent
  * @param loc location
  * @param type type of material/texture
  * @return staticPhysicNode with the attached box
  */
 public StaticPhysicsNode makeWall(
     String name, float x, float y, float z, Vector3f loc, MaterialType type) {
   Box box = new Box(name, new Vector3f(), x, y, z);
   box.setModelBound(new BoundingBox());
   box.updateModelBound();
   if (type != null) ObjectFactory.get().applyRenderStates(box, type);
   StaticPhysicsNode physicWall = getPhysicsSpace().createStaticNode();
   physicWall.attachChild(box);
   physicWall.setLocalTranslation(loc);
   physicWall.generatePhysicsGeometry();
   return physicWall;
 }
Exemplo n.º 5
0
  /*
   * (non-Javadoc)
   *
   * @see org.rifidi.designer.entities.Entity#init()
   */
  @Override
  public void init() {
    if (!(getNode() instanceof StaticPhysicsNode)) {
      StaticPhysicsNode phys = physicsSpace.createStaticNode();
      phys.setLocalTranslation(getNode().getWorldTranslation());
      for (Spatial spatial : new ArrayList<Spatial>(getNode().getChildren())) {
        phys.attachChild(spatial);
      }

      getNode().removeFromParent();
      setNode(phys);
      phys.generatePhysicsGeometry();
      loaded();
      fieldService.registerField(this);
    }
  }
Exemplo n.º 6
0
  /** creates the floor and two walls standing on the floor. */
  private void createFloor(float width, float length) {
    Texture tex =
        TextureManager.loadTexture(
            ResourceLocatorTool.locateResource(ResourceLocatorTool.TYPE_TEXTURE, "floor.png"),
            false);
    tex.setScale(new Vector3f(10, 10, 10));
    tex.setWrap(WrapMode.Repeat);
    TextureState tsCarpet = DisplaySystem.getDisplaySystem().getRenderer().createTextureState();
    tsCarpet.setTexture(tex);

    StaticPhysicsNode floor = makeWall("floor", width, 0.5f, length, new Vector3f(0, -1, 0), null);
    floor.setRenderState(tsCarpet);
    rootNode.attachChild(floor);

    rootNode.attachChild(
        makeWall(
            "back wall", width / 2, 5, 1, new Vector3f(0, 5, -width / 2), MaterialType.GRANITE));
    rootNode.attachChild(
        makeWall(
            "left wall", 1, 5, width / 2, new Vector3f(-width / 2, 5, 0), MaterialType.GRANITE));
  }