Class Camera
java.lang.Object
eu.svjatoslav.aukio.e3d.geometry.Camera
Represents the viewer's camera in the 3D world, with position, orientation, and movement.
The camera is the user's "eyes" in the 3D scene. It has a position (location), a looking direction (defined by a quaternion), and a movement system with velocity, acceleration, and friction for smooth camera navigation.
By default, the user can navigate using arrow keys (handled by
WorldNavigationUserInputTracker),
and the mouse controls the look direction (handled by
InputManager).
Programmatic camera control:
Camera camera = viewPanel.getCamera();
// Set camera position
camera.getTransform().setTranslation(new Point3D(0, -50, -200));
// Set camera orientation using a quaternion
camera.getTransform().getRotation().set(Quaternion.fromAngles(0.5, -0.3));
// Copy camera state from another camera
Camera snapshot = new Camera(camera);
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptiondoubleCamera acceleration factor for movement speed.static final doubleCamera movement speed limit, relative to the world.static final doubleWorld units moved per millisecond per unit of velocity. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidClamps the camera's movement speed toSPEED_LIMIT.doubleReturns the current movement speed (magnitude of the movement vector).Returns the current movement velocity vector, relative to the camera's orientation.Returns the transform containing this camera's location and orientation.voidOrients the camera to look at a target point in world coordinates.booleanonFrame(int millisecondsSinceLastFrame) Per-frame camera physics tick (movement integration, friction).
-
Field Details
-
SPEED_LIMIT
public static final double SPEED_LIMITCamera movement speed limit, relative to the world. When camera coordinates are updated within the world, camera orientation relative to the world is taken into account.- See Also:
-
SPEED_MULTIPLIER
public static final double SPEED_MULTIPLIERWorld units moved per millisecond per unit of velocity. Public: direct-drive controllers (SpaceMouse) reuse it to match the keyboard/mouse feel.- See Also:
-
cameraAcceleration
public double cameraAccelerationCamera acceleration factor for movement speed. Higher values result in faster acceleration.
-
-
Constructor Details
-
Camera
public Camera()Creates a camera at the world origin with no rotation. -
Camera
Creates a copy of an existing camera, cloning its position and orientation.- Parameters:
sourceView- the camera to copy
-
Camera
Creates a camera with the specified transform (position and orientation).- Parameters:
transform- the initial transform defining position and rotation
-
-
Method Details
-
onFrame
public boolean onFrame(int millisecondsSinceLastFrame) Per-frame camera physics tick (movement integration, friction). Registered on the panel via aFrameListeneradapter inViewPanel— decoupled from the gui interface so the camera stays in the geometry package.- Parameters:
millisecondsSinceLastFrame- frame delta in milliseconds- Returns:
- true when the camera moved enough to need a repaint
-
enforceSpeedLimit
public void enforceSpeedLimit()Clamps the camera's movement speed toSPEED_LIMIT. Called after modifying the movement vector to prevent excessive velocity. -
getMovementVector
Returns the current movement velocity vector, relative to the camera's orientation. Modify this vector to programmatically move the camera.- Returns:
- the movement vector (mutable reference)
-
getMovementSpeed
public double getMovementSpeed()Returns the current movement speed (magnitude of the movement vector).- Returns:
- the scalar speed value
-
getTransform
Returns the transform containing this camera's location and orientation.- Returns:
- the transform (mutable reference)
-
lookAt
Orients the camera to look at a target point in world coordinates.Calculates the required XZ and YZ rotation angles to point the camera from its current position toward the target. Useful for programmatic camera control, cinematic sequences, and following objects.
Example:
Camera camera = viewPanel.getCamera(); camera.getTransform().setTranslation(new Point3D(100, -50, -200)); camera.lookAt(new Point3D(0, 0, 0)); // Point camera at origin- Parameters:
target- the world-space point to look at
-