Class CameraComponent
Describes the camera projection and view.
[DataContract("CameraComponent")]
[Display("Camera", null, Expand = ExpandRule.Once)]
[DefaultEntityComponentProcessor(typeof(CameraProcessor))]
[ComponentOrder(13000)]
[ObjectFactory(typeof(CameraComponent.Factory))]
public sealed class CameraComponent : ActivableEntityComponent, IIdentifiable
- Inheritance
-
CameraComponent
- Implements
- Inherited Members
Constructors
CameraComponent()
Create a new CameraComponent instance.
public CameraComponent()
CameraComponent(float, float)
Create a new CameraComponent instance with the provided target, near plane and far plane.
public CameraComponent(float nearClipPlane, float farClipPlane)
Parameters
Fields
DefaultAspectRatio
public const float DefaultAspectRatio = 1.7777778
Field Value
DefaultFarClipPlane
public const float DefaultFarClipPlane = 1000
Field Value
DefaultNearClipPlane
public const float DefaultNearClipPlane = 0.1
Field Value
DefaultOrthographicSize
public const float DefaultOrthographicSize = 10
Field Value
DefaultVerticalFieldOfView
public const float DefaultVerticalFieldOfView = 45
Field Value
Frustum
The frustum extracted from the view projection matrix calculated automatically after calling Update() method.
public BoundingFrustum Frustum
Field Value
ProjectionMatrix
Gets or sets the local projection matrix. See remarks.
public Matrix ProjectionMatrix
Field Value
- Matrix
The local projection matrix.
Remarks
This value is updated when calling Update() or is directly used when UseCustomViewMatrix is true
.
Slot
[DataMember(50)]
public SceneCameraSlotId Slot
Field Value
ViewMatrix
Gets or sets the local view matrix. See remarks.
public Matrix ViewMatrix
Field Value
- Matrix
The local view matrix.
Remarks
This value is updated when calling Update() or is directly used when UseCustomViewMatrix is true
.
ViewProjectionMatrix
The view projection matrix calculated automatically after calling Update() method.
public Matrix ViewProjectionMatrix
Field Value
Properties
ActuallyUsedAspectRatio
Gets the last used aspect ratio.
public float ActuallyUsedAspectRatio { get; }
Property Value
Remarks
This value is updated when calling Update().
It either holds the aspect ratio of the window that called Update or the manually set aspect ratio AspectRatio if UseCustomAspectRatio is true
.
AspectRatio
Gets or sets the custom aspect ratio.
[DataMember(40)]
public float AspectRatio { get; set; }
Property Value
- float
The custom aspect ratio.
FarClipPlane
Gets or sets the far plane distance.
[DataMember(30)]
public float FarClipPlane { get; set; }
Property Value
- float
The far plane distance.
Name
[DataMember(-5)]
[Obsolete("This property is no longer used.")]
public string Name { get; set; }
Property Value
NearClipPlane
Gets or sets the near plane distance.
[DataMember(20)]
public float NearClipPlane { get; set; }
Property Value
- float
The near plane distance.
OrthographicSize
Gets or sets the height of the orthographic projection.
[DataMember(10)]
[Display("Orthographic size", null)]
public float OrthographicSize { get; set; }
Property Value
- float
The height of the orthographic projection.
Projection
Gets or sets the projection.
[DataMember(0)]
public CameraProjectionMode Projection { get; set; }
Property Value
- CameraProjectionMode
The projection.
UseCustomAspectRatio
Gets or sets a value indicating whether to use a custom AspectRatio. Default is false
, meaning that the aspect ratio is calculated from the ratio of the current viewport when rendering.
[DataMember(35)]
[Display("Custom aspect ratio", null)]
public bool UseCustomAspectRatio { get; set; }
Property Value
- bool
The use custom aspect ratio.
UseCustomProjectionMatrix
Gets or sets a value indicating whether to use custom ProjectionMatrix. Default is false
public bool UseCustomProjectionMatrix { get; set; }
Property Value
- bool
true
if use custom ProjectionMatrix; otherwise,false
.
UseCustomViewMatrix
Gets or sets a value indicating whether to use custom ViewMatrix. Default is false
public bool UseCustomViewMatrix { get; set; }
Property Value
- bool
true
if use custom ViewMatrix; otherwise,false
.
VerticalFieldOfView
Gets or sets the vertical field of view in degrees.
[DataMember(5)]
[Display("Field of view", null)]
[DataMemberRange(1, 179, 1, 10, 0)]
public float VerticalFieldOfView { get; set; }
Property Value
- float
The vertical field of view.
Methods
Update()
Calculates the projection matrix and view matrix.
public void Update()
Update(float?)
Calculates the projection matrix and view matrix.
public void Update(float? screenAspectRatio)
Parameters
screenAspectRatio
float?The current screen aspect ratio. If null, use the AspectRatio even if UseCustomAspectRatio is false.