Beispiel #1
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;
 }
  private Node createObjects() {
    Node objects = new Node("objects");

    Torus torus = new Torus("Torus", 50, 50, 10, 20);
    torus.setLocalTranslation(new Vector3f(50, -5, 20));
    TextureState ts = display.getRenderer().createTextureState();
    Texture t0 =
        TextureManager.loadTexture(
            TestSketch.class.getClassLoader().getResource("jmetest/data/images/Monkey.jpg"),
            Texture.MM_LINEAR_LINEAR,
            Texture.FM_LINEAR);
    Texture t1 =
        TextureManager.loadTexture(
            TestSketch.class.getClassLoader().getResource("jmetest/data/texture/north.jpg"),
            Texture.MM_LINEAR_LINEAR,
            Texture.FM_LINEAR);
    t1.setEnvironmentalMapMode(Texture.EM_SPHERE);
    ts.setTexture(t0, 0);
    ts.setTexture(t1, 1);
    ts.setEnabled(true);
    torus.setRenderState(ts);
    objects.attachChild(torus);

    ts = display.getRenderer().createTextureState();
    t0 =
        TextureManager.loadTexture(
            TestSketch.class.getClassLoader().getResource("jmetest/data/texture/wall.jpg"),
            Texture.MM_LINEAR_LINEAR,
            Texture.FM_LINEAR);
    t0.setWrap(Texture.WM_WRAP_S_WRAP_T);
    ts.setTexture(t0);

    Box box = new Box("box1", new Vector3f(-10, -10, -10), new Vector3f(10, 10, 10));
    box.setLocalTranslation(new Vector3f(0, -7, 0));
    box.setRenderState(ts);
    box.setModelBound(new BoundingBox());
    box.updateModelBound();
    objects.attachChild(box);

    box = new Box("box2", new Vector3f(-5, -5, -5), new Vector3f(5, 5, 5));
    box.setLocalTranslation(new Vector3f(15, 10, 0));
    box.setModelBound(new BoundingBox());
    box.updateModelBound();
    box.setRenderState(ts);
    objects.attachChild(box);

    box = new Box("box4", new Vector3f(-5, -5, -5), new Vector3f(5, 5, 5));
    box.setLocalTranslation(new Vector3f(20, 0, 0));
    box.setModelBound(new BoundingBox());
    box.updateModelBound();
    box.setRenderState(ts);
    objects.attachChild(box);

    box = new Box("box5", new Vector3f(-50, -2, -50), new Vector3f(50, 2, 50));
    box.setLocalTranslation(new Vector3f(0, -15, 0));
    box.setModelBound(new BoundingBox());
    box.updateModelBound();
    box.setRenderState(ts);
    objects.attachChild(box);

    ts = display.getRenderer().createTextureState();
    t0 =
        TextureManager.loadTexture(
            TestSketch.class.getClassLoader().getResource("jmetest/data/texture/cloud_land.jpg"),
            Texture.MM_LINEAR_LINEAR,
            Texture.FM_LINEAR);
    t0.setWrap(Texture.WM_WRAP_S_WRAP_T);
    ts.setTexture(t0);

    box = new Box("floor", new Vector3f(-1000, -10, -1000), new Vector3f(1000, 10, 1000));
    box.setLocalTranslation(new Vector3f(0, -100, 0));
    box.setModelBound(new BoundingBox());
    box.updateModelBound();
    box.setRenderState(ts);
    objects.attachChild(box);

    return objects;
  }