예제 #1
0
  // handles camera movement
  public void moveCamera(float speed, Vec3 ratio) {
    double pitch = 0, roll = 0;
    if (rotatorP.equals("") || rotatorR.equals("")) {
    } else if (rotatorP.equals("up")) {
      pitch = Math.PI / 180;
    } else if (rotatorP.equals("down")) {
      pitch = -1 * Math.PI / 180;
    } else if (rotatorR.equals("right")) {
      roll = Math.PI / 180;
    } else if (rotatorR.equals("left")) {
      roll = -1 * Math.PI / 180;
    }

    persp.setToSub(eye);

    // double length;

    if (pitch != 0) {
      turnPitch(pitch);
    } else if (roll != 0 && move) // YAW)
    {
      turnRoll(roll);
    }

    if (!move /*YAW*/ && roll != 0) {
      turnYaw(roll);
    }

    persp.setToAdd(eye);

    if (move) {
      moveForward(speed, ratio);
    }

    if (eye.y < 0) {
      persp.y -= eye.y;
      eye.y = 0;
    }
    if (eye.y > (skyHeight - 1) / 1) {
      persp.y -= (eye.y - (skyHeight - 1) / 1);
      eye.y = (skyHeight - 1) / 1;
    }

    return;
  }