Beispiel #1
0
  // pitch camera up or down
  private void turnPitch(double pitch) {
    Vec3 oldup = new Vec3(up.x, up.y, up.z);

    up.x -= Math.tan(pitch) * persp.x;
    up.y -= Math.tan(pitch) * persp.y;
    up.z -= Math.tan(pitch) * persp.z;

    persp.x += Math.tan(pitch) * oldup.x;
    persp.y += Math.tan(pitch) * oldup.y;
    persp.z += Math.tan(pitch) * oldup.z;

    up = up.normalize();

    persp = persp.normalize();
  }
Beispiel #2
0
  // turn the camera in its current plane
  private void turnYaw(double roll) {
    // Up cross focus for left vector
    Vec3 left = persp.cross(up);

    // Normalize left vector
    left = left.normalize();

    // Move up vector
    persp.x += (Math.tan(roll) * left.x);
    persp.y += (Math.tan(roll) * left.y);
    persp.z += (Math.tan(roll) * left.z);

    // Normalize persp vector
    persp = persp.normalize();
  }