Exemplo n.º 1
0
  public void simpleInitApp() {
    bulletAppState = new BulletAppState();
    stateManager.attach(bulletAppState);
    flyCam.setMoveSpeed(100);
    setupKeys();

    this.cam.setFrustumFar(2000);

    DirectionalLight dl = new DirectionalLight();
    dl.setColor(ColorRGBA.White.clone().multLocal(2));
    dl.setDirection(new Vector3f(-1, -1, -1).normalize());
    rootNode.addLight(dl);

    AmbientLight am = new AmbientLight();
    am.setColor(ColorRGBA.White.mult(2));
    rootNode.addLight(am);

    // load the level from zip or http zip
    if (useHttp) {
      assetManager.registerLocator(
          "http://jmonkeyengine.googlecode.com/files/quake3level.zip",
          HttpZipLocator.class.getName());
    } else {
      assetManager.registerLocator("basic.scene", ZipLocator.class.getName());
    }

    // create the geometry and attach it
    MaterialList matList = (MaterialList) assetManager.loadAsset("Scene.material");
    OgreMeshKey key = new OgreMeshKey("main.meshxml", matList);
    gameLevel = (Node) assetManager.loadAsset(key);
    gameLevel.setLocalScale(0.1f);

    // add a physics control, it will generate a MeshCollisionShape based on the gameLevel
    gameLevel.addControl(new RigidBodyControl(0));

    player = new PhysicsCharacter(new SphereCollisionShape(5), .01f);
    player.setJumpSpeed(20);
    player.setFallSpeed(30);
    player.setGravity(30);

    player.setPhysicsLocation(new Vector3f(60, 10, -60));

    rootNode.attachChild(gameLevel);

    getPhysicsSpace().addAll(gameLevel);
    getPhysicsSpace().add(player);
  }