Package com.j3d.engine.scene
Class Camera
java.lang.Object
com.j3d.engine.react.events.EventEmitter
com.j3d.engine.scene.Camera
- All Implemented Interfaces:
EventEmitterInterface
Represents the virtual camera in the 3D scene.
The camera defines the viewpoint from which the scene is rendered. It holds its own position and orientation (rotation) in world space. It also contains the projection plane, which determines the field of view and focal length for the 3D-to-2D projection.
- Author:
- Lehlogonolo Poole
- See Also:
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate Vector3The 3D position of the camera in the world (c).private Vector3The position of the display surface relative to the camera's local coordinate system.private RotationThe orientation of the camera, defined by pitch, yaw, and roll angles.Fields inherited from class com.j3d.engine.react.events.EventEmitter
registered -
Constructor Summary
ConstructorsConstructorDescriptionCamera()Default constructor that creates a camera at the origin (0,0,0), with zero rotation, looking along the world's Z-axis.Constructs a new Camera with a specified position, rotation, and projection plane. -
Method Summary
Modifier and TypeMethodDescriptionvoidevent()Calculates the camera's forward-facing direction vector in world space.Gets the positionGets the projection planegetRight()Calculates the camera's right-facing direction vector in world space.Gets the rotationgetUp()Calculates the camera's up-facing direction vector in world space.voidOrients the camera to look at a specific target point in world space.voidMoves the camera by a given delta vector.voidsetFocalLength(double d) setPosition(Vector3 position) Sets the positionsetPositionNoEvent(Vector3 position) setProjectionPlane(Vector3 projectionPlane) Sets the projection planesetRotation(Rotation rotation) Sets the rotationsetRotationNoEvent(Rotation rotation) toString()Returns aNormalPlanerepresenting the camera's view plane.Methods inherited from class com.j3d.engine.react.events.EventEmitter
attachListener, broadcast, detachAll, detachListener, genericAttach, genericBroadcast, genericDetach, genericDetachAll, isAttached
-
Field Details
-
position
The 3D position of the camera in the world (c). -
rotation
The orientation of the camera, defined by pitch, yaw, and roll angles. -
projectionPlane
The position of the display surface relative to the camera's local coordinate system. The Z-component of this vector is the most critical, acting as the focal length (zoom). A larger Z-value results in a narrower field of view (more zoom).
-
-
Constructor Details
-
Camera
Constructs a new Camera with a specified position, rotation, and projection plane.- Parameters:
position- The camera's position in 3D space.rotation- The camera's orientation.projectionPlane- The camera's projection plane settings.
-
Camera
public Camera()Default constructor that creates a camera at the origin (0,0,0), with zero rotation, looking along the world's Z-axis. It uses a default projection plane.
-
-
Method Details
-
move
Moves the camera by a given delta vector.- Parameters:
delta- The vector to add to the camera's current position.
-
getPosition
Gets the position- Returns:
- The camera's position in 3D space.
-
setPositionNoEvent
-
setPosition
Sets the position- Parameters:
position- The new position for the camera.
-
getRotation
Gets the rotation- Returns:
- The camera's orientation.
-
setRotationNoEvent
-
setRotation
Sets the rotation- Parameters:
rotation- The new rotation for the camera.
-
getProjectionPlane
Gets the projection plane- Returns:
- The camera's projection plane settings.
-
setProjectionPlane
Sets the projection plane- Parameters:
projectionPlane- The new projection plane settings.
-
getForward
Calculates the camera's forward-facing direction vector in world space. This is determined by transforming a local "forward" vector (0, 0, 1) using the camera's current yaw and pitch.- Returns:
- A normalized
Vector3representing the direction the camera is pointing.
-
getRight
Calculates the camera's right-facing direction vector in world space. This is determined by transforming a local "right" vector (1, 0, 0) using the camera's current yaw and pitch.- Returns:
- A normalized
Vector3representing the direction the camera is pointing.
-
getUp
Calculates the camera's up-facing direction vector in world space. This is determined by transforming a local "up" vector (0, 1, 0) using the camera's current yaw and pitch. Roll is ignored.- Returns:
- A normalized
Vector3representing the direction the camera is pointing.
-
lookAt
Orients the camera to look at a specific target point in world space. This method calculates the necessary pitch and yaw to align the camera's forward vector with the direction from its current position to the target. The camera's roll is set to 0.- Parameters:
target- The world-spaceVector3point to look at.
-
viewPlane
Returns aNormalPlanerepresenting the camera's view plane. This plane is defined by the camera's position and its forward-facing direction.- Returns:
- A
NormalPlanerepresenting the camera's view plane.
-
toString
-
setFocalLength
public void setFocalLength(double d) -
event
public void event()
-