11package engine .scene .camera ;
22
33import engine .components .Transform ;
4- import math .Matrix4f ;
5- import math .Ray3f ;
64import math .Vector3f ;
75
86/**
1917 */
2018public interface Camera {
2119
22- Vector3f getTarget ();
23-
24- /**
25- * Retrieves the camera's transformation.
26- *
27- * <p>The transformation defines the position, rotation, and scaling of the camera in the 3D
28- * world. This transformation is used to compute the camera's position and orientation in world
29- * space.
30- *
31- * @return The {@link Transform} representing the camera's position, rotation, and scaling.
32- */
33- Transform getTransform ();
34-
3520 /**
36- * Retrieves the current view matrix of the camera .
21+ * Sets the camera's target position in the world .
3722 *
38- * <p>The view matrix is used to transform world-space coordinates into camera (view) space. It is
39- * typically derived from the camera's position and orientation in the 3D world.
23+ * <p>The target defines the point in the 3D world that the camera is focused on. This is
24+ * typically used for creating behaviors such as following an object or maintaining a fixed view
25+ * of a specific scene element. The target can be dynamically updated during runtime to adjust the
26+ * camera's view.
4027 *
41- * @return The view matrix as a {@link Matrix4f }.
28+ * @param target The new target for the camera to focus on, represented as a {@link Vector3f }.
4229 */
43- Matrix4f getViewMatrix ( );
30+ void setTarget ( Vector3f target );
4431
4532 /**
46- * Retrieves the current projection matrix of the camera.
33+ * Retrieves the current target position of the camera.
4734 *
48- * <p>The projection matrix defines how a 3D scene is projected onto a 2D viewport, depending on
49- * the camera's projection settings (perspective or orthographic).
35+ * <p>The target defines the point in the 3D world that the camera is currently focused on. This
36+ * is useful for determining the camera's orientation or calculating the view matrix. The target
37+ * remains constant unless explicitly changed using {@link #setTarget(Vector3f)}.
5038 *
51- * @return The projection matrix as a {@link Matrix4f }.
39+ * @return The current target of the camera as a {@link Vector3f }.
5240 */
53- Matrix4f getProjectionMatrix ();
41+ Vector3f getTarget ();
5442
5543 /**
56- * Updates the view matrix based on the current transformation.
44+ * Retrieves the camera's transformation, including its position, rotation, and scale in the 3D
45+ * world.
5746 *
58- * <p>This method should recalculate the view matrix whenever the camera's position or orientation
59- * has changed.
60- */
61- void updateViewMatrix ();
62-
63- /**
64- * Updates the projection matrix based on camera-specific settings.
47+ * <p>The transformation is a {@link Transform} object that encapsulates the camera's position,
48+ * rotation, and scaling within the scene. It is used to compute the camera's world space
49+ * orientation and can be updated to change the camera's location or rotation in the scene.
6550 *
66- * <p>This method should be called whenever changes are made to parameters like the field of view,
67- * near or far clipping planes, or aspect ratio .
51+ * @return The camera's {@link Transform} representing its position, rotation, and scaling in the
52+ * world .
6853 */
69- void updateProjectionMatrix ();
54+ Transform getTransform ();
7055
7156 /**
72- * Retrieves the field of view (FOV) for perspective cameras .
57+ * Retrieves the field of view (FOV) of the camera, applicable for perspective projections .
7358 *
74- * <p>The field of view determines how wide or narrow the camera's view is and only applies to
75- * perspective projections.
59+ * <p>The field of view determines how wide or narrow the camera's perspective is, affecting how
60+ * much of the 3D scene is visible at any given time. This property is only relevant for
61+ * perspective cameras.
7662 *
7763 * @return The current field of view in degrees.
7864 */
@@ -81,45 +67,53 @@ public interface Camera {
8167 /**
8268 * Sets the field of view (FOV) for perspective cameras.
8369 *
84- * <p>This only has an effect on cameras configured for perspective projection.
70+ * <p>The field of view defines how wide or narrow the camera's perspective is, which influences
71+ * the perception of depth in the scene. This property only applies to perspective cameras and has
72+ * no effect on orthographic cameras.
8573 *
8674 * @param fov The desired field of view in degrees.
8775 */
8876 void setFieldOfView (float fov );
8977
9078 /**
91- * Retrieves the near clipping plane distance.
79+ * Retrieves the near clipping plane distance for the camera .
9280 *
93- * <p>The near clipping plane defines the closest distance from the camera at which objects are
94- * rendered. Objects closer than this distance will not be visible.
81+ * <p>The near clipping plane defines the closest distance at which objects will be rendered by
82+ * the camera. Any objects closer than this distance will not be visible. This value is crucial
83+ * for depth calculations and scene rendering.
9584 *
9685 * @return The near clipping plane distance.
9786 */
9887 float getNearPlane ();
9988
10089 /**
101- * Sets the near clipping plane distance.
90+ * Sets the near clipping plane distance for the camera .
10291 *
103- * <p>This modifies how close an object must be to the camera to be visible.
92+ * <p>The near clipping plane defines the closest visible distance in the 3D world. Objects closer
93+ * than this plane will not be rendered. Adjusting this value helps prevent issues like z-fighting
94+ * and ensures proper visibility of objects.
10495 *
10596 * @param nearPlane The desired near clipping plane distance.
10697 */
10798 void setNearPlane (float nearPlane );
10899
109100 /**
110- * Retrieves the far clipping plane distance.
101+ * Retrieves the far clipping plane distance for the camera .
111102 *
112- * <p>The far clipping plane defines the furthest distance from the camera at which objects are
113- * rendered. Objects farther away than this distance will not be visible.
103+ * <p>The far clipping plane defines the furthest distance at which objects will be rendered.
104+ * Objects farther than this distance will not be visible. This value is critical for controlling
105+ * the rendering of distant objects and depth precision.
114106 *
115107 * @return The far clipping plane distance.
116108 */
117109 float getFarPlane ();
118110
119111 /**
120- * Sets the far clipping plane distance.
112+ * Sets the far clipping plane distance for the camera .
121113 *
122- * <p>This modifies how far objects can be from the camera to remain visible.
114+ * <p>The far clipping plane defines the maximum visible distance for the camera. Objects beyond
115+ * this distance will not be rendered. Modifying this value affects the range of visible objects
116+ * in the scene and can help optimize performance by excluding distant geometry.
123117 *
124118 * @param farPlane The desired far clipping plane distance.
125119 */
@@ -128,46 +122,23 @@ public interface Camera {
128122 /**
129123 * Retrieves the current aspect ratio of the camera's viewport.
130124 *
131- * <p>The aspect ratio is defined as the ratio of the viewport's width to its height and is used
132- * to adjust the projection matrix accordingly.
125+ * <p>The aspect ratio is the ratio of the width to the height of the camera's viewport and
126+ * determines how the scene is projected onto the screen. The aspect ratio is used to adjust the
127+ * projection matrix for accurate rendering and proper scene alignment, especially in 3D.
133128 *
134- * @return The aspect ratio of the viewport.
129+ * @return The current aspect ratio of the camera's viewport (width divided by height) .
135130 */
136131 float getAspectRatio ();
137132
138133 /**
139134 * Sets the aspect ratio for the camera's viewport.
140135 *
141- * <p>Changing the aspect ratio should trigger an update to the projection matrix.
136+ * <p>Changing the aspect ratio of the camera will affect how the scene is projected, ensuring
137+ * that the rendered image fits the viewport properly. This adjustment is typically necessary when
138+ * resizing the window or changing the display resolution.
142139 *
143- * @param aspectRatio The desired aspect ratio.
140+ * @param aspectRatio The desired aspect ratio for the camera's viewport (width divided by
141+ * height).
144142 */
145143 void setAspectRatio (float aspectRatio );
146-
147- /**
148- * Converts 2D screen coordinates to a 3D ray in world space.
149- *
150- * <p>This method is essential for raycasting operations, such as determining which objects in the
151- * scene correspond to a given 2D screen-space click.
152- *
153- * @param screenX The x-coordinate on the screen.
154- * @param screenY The y-coordinate on the screen.
155- * @param viewportWidth The width of the viewport in pixels.
156- * @param viewportHeight The height of the viewport in pixels.
157- * @return A {@link Ray3f} representing the computed ray in 3D world space.
158- */
159- Ray3f createRay (float screenX , float screenY , int viewportWidth , int viewportHeight );
160-
161- /**
162- * Converts 2D screen-space coordinates to their corresponding world-space coordinates.
163- *
164- * <p>This is the inverse of projection and can be used for operations like object picking or
165- * determining intersections between screen-space inputs and 3D objects in the world.
166- *
167- * @param screenCoords The 2D screen-space coordinates to unproject.
168- * @param viewportWidth The width of the viewport in pixels.
169- * @param viewportHeight The height of the viewport in pixels.
170- * @return The corresponding 3D world-space coordinates as a {@link Vector3f}.
171- */
172- Vector3f unproject (Vector3f screenCoords , int viewportWidth , int viewportHeight );
173144}
0 commit comments