예제 #1
0
 @Override
 public void input(Window window, MouseInput mouseInput) {
   cameraInc.set(0, 0, 0);
   if (window.isKeyPressed(GLFW_KEY_W)) {
     cameraInc.z = -1;
   } else if (window.isKeyPressed(GLFW_KEY_S)) {
     cameraInc.z = 1;
   }
   if (window.isKeyPressed(GLFW_KEY_A)) {
     cameraInc.x = -1;
   } else if (window.isKeyPressed(GLFW_KEY_D)) {
     cameraInc.x = 1;
   }
   if (window.isKeyPressed(GLFW_KEY_Z)) {
     cameraInc.y = -1;
   } else if (window.isKeyPressed(GLFW_KEY_X)) {
     cameraInc.y = 1;
   }
   if (window.isKeyPressed(GLFW_KEY_LEFT)) {
     angleInc -= 0.05f;
   } else if (window.isKeyPressed(GLFW_KEY_RIGHT)) {
     angleInc += 0.05f;
   } else {
     angleInc = 0;
   }
   if (window.isKeyPressed(GLFW_KEY_SPACE)) {
     monster.nextFrame();
   }
 }
예제 #2
0
  @Override
  public void init(Window window) throws Exception {
    renderer.init(window);

    scene = new Scene();

    float reflectance = 1f;

    Mesh quadMesh = OBJLoader.loadMesh("/models/plane.obj");
    Material quadMaterial = new Material(new Vector3f(0.0f, 0.0f, 1.0f), reflectance);
    quadMesh.setMaterial(quadMaterial);
    GameItem quadGameItem = new GameItem(quadMesh);
    quadGameItem.setPosition(0, 0, 0);
    quadGameItem.setScale(2.5f);

    // Setup  GameItems
    MD5Model md5Meshodel = MD5Model.parse("/models/monster.md5mesh");
    MD5AnimModel md5AnimModel = MD5AnimModel.parse("/models/monster.md5anim");
    // MD5Model md5Meshodel = MD5Model.parse("/models/boblamp.md5mesh");
    // MD5AnimModel md5AnimModel = MD5AnimModel.parse("/models/boblamp.md5anim");

    monster = MD5Loader.process(md5Meshodel, md5AnimModel, new Vector3f(1, 1, 1));
    monster.setScale(0.05f);
    monster.setRotation(90, 0, 0);

    scene.setGameItems(new GameItem[] {quadGameItem, monster});

    // Setup Lights
    setupLights();

    camera.getPosition().x = 0.25f;
    camera.getPosition().y = 6.5f;
    camera.getPosition().z = 6.5f;
    camera.getRotation().x = 25;
    camera.getRotation().y = -1;
    hud = new Hud("");
  }