Description
The FieldOfView
property of the CameraComponent
class represents the field of view angle for the camera in degrees. This property is crucial for determining how much of the scene is visible through the camera at any given time. The field of view is typically used in perspective projection to simulate the human eye's view.
The valid range for this property is between 1 and 179 degrees, ensuring that the field of view is neither too narrow nor too wide, which could lead to rendering issues or unrealistic perspectives.
This property is hidden when the camera is set to use orthographic projection, as field of view is not applicable in that mode.
Usage
To adjust the field of view of a camera in your scene, you can set the FieldOfView
property on the CameraComponent
instance. This can be useful for creating zoom effects or adjusting the camera's perspective to fit the scene's requirements.
Ensure that the value is within the specified range (1 to 179) to avoid rendering artifacts or unrealistic views.
Example
// Example of setting the FieldOfView property
CameraComponent camera = new CameraComponent();
camera.FieldOfView = 60.0f; // Set the field of view to 60 degrees
// Check if the camera is using orthographic projection
if (!camera.Orthographic)
{
// Adjust the field of view
camera.FieldOfView = 90.0f;
}