Пример #1
0
  public void move() {
    if (cameraMode == CameraMode.OVERHEAD) {
      if (KeyboardHelper.isKeyDown(Keyboard.KEY_LEFT)) {
        this.position.x -= OVERHEAD_CAMERA_MOVE_SPEED * DisplayManager.getFrameTimeSeconds();
      }
      if (KeyboardHelper.isKeyDown(Keyboard.KEY_RIGHT)) {
        this.position.x += OVERHEAD_CAMERA_MOVE_SPEED * DisplayManager.getFrameTimeSeconds();
      }
      if (KeyboardHelper.isKeyDown(Keyboard.KEY_UP)) {
        this.position.z -= OVERHEAD_CAMERA_MOVE_SPEED * DisplayManager.getFrameTimeSeconds();
      }
      if (KeyboardHelper.isKeyDown(Keyboard.KEY_DOWN)) {
        this.position.z += OVERHEAD_CAMERA_MOVE_SPEED * DisplayManager.getFrameTimeSeconds();
      }

      this.yaw = 0;
      this.pitch = 70;
      this.position.y = world.getTerrain().getTerrainHeight(position.x, position.z) + cameraHeight;

    } else if (cameraMode == CameraMode.FIRST_PERSON) {
      Vector3f viewPos = player.getHardpointWorldPos("HP_VIEW");
      if (viewPos == null) viewPos = player.getPosition();

      this.position.x = viewPos.x;
      this.position.y = viewPos.y;
      this.position.z = viewPos.z;
      this.pitch = player.rotX;
      this.yaw = 180.0f - player.rotY;
    } else if (cameraMode == CameraMode.THIRD_PERSON) {
      calculateZoom();
      calculatePitch();
      calculateAngleAroundPlayer();

      float horizontalDistance = calculateHorizontalDistance();
      float verticalDistance = calculateVerticalDistance();
      calculateCameraPosition(horizontalDistance, verticalDistance);
    }
  }
Пример #2
0
 public Camera(Entity player, World world) {
   this.player = player;
   this.world = world;
   KeyboardHelper.addListener(this);
 }