Class Camera
Describes the camera projection and view. Provides information about how to render scene (viewport location and direction, etc.).
Namespace: FlaxEngine
Assembly: FlaxEngine.CSharp.dll
Syntax
[ActorContextMenu("New/Camera")]
[ActorToolbox("Visuals")]
[Unmanaged]
public sealed class Camera : Actor, ISerializable
Constructors
Camera()
Properties
CustomAspectRatio
Gets or sets the custom aspect ratio. 0 if not use custom value.
Declaration
[EditorOrder(50)]
[Limit(0F, 10F, 0.01F)]
[EditorDisplay("Camera", null)]
[Unmanaged]
public float CustomAspectRatio { get; set; }
Property Value
System.
|
FarPlane
Gets or sets camera's far plane distance.
Declaration
[EditorOrder(40)]
[Limit(0F, 3.40282347E+38F, 5F)]
[EditorDisplay("Camera", null)]
[ValueCategory]
[Unmanaged]
public float FarPlane { get; set; }
Property Value
System.
|
FieldOfView
Gets or sets the camera's field of view (in degrees).
Declaration
[EditorOrder(20)]
[Limit(0F, 179F, 1F)]
[EditorDisplay("Camera", "Field Of View")]
[VisibleIf("UsePerspective", false)]
[ValueCategory]
[Unmanaged]
public float FieldOfView { get; set; }
Property Value
System.
|
Frustum
Gets the frustum.
Declaration
[Unmanaged]
public BoundingFrustum Frustum { get; }
Property Value
MainCamera
Gets the main camera.
Declaration
[Unmanaged]
public static Camera MainCamera { get; }
Property Value
NearPlane
Gets or sets camera's near plane distance.
Declaration
[EditorOrder(30)]
[Limit(0F, 1000F, 0.05F)]
[EditorDisplay("Camera", null)]
[ValueCategory]
[Unmanaged]
public float NearPlane { get; set; }
Property Value
System.
|
OrthographicScale
Gets or sets the orthographic projection scale.
Declaration
[EditorOrder(60)]
[Limit(0.0001F, 1000F, 0.01F)]
[EditorDisplay("Camera", null)]
[VisibleIf("UsePerspective", true)]
[Unmanaged]
public float OrthographicScale { get; set; }
Property Value
System.
|
OrthographicSize
Gets or sets the orthographic projection view height (width is based on the aspect ratio). Use 0
for size to be based on the viewport size.
Declaration
[EditorOrder(59)]
[Limit(0F, 3.40282347E+38F, 1F)]
[EditorDisplay("Camera", null)]
[VisibleIf("UsePerspective", true)]
[Unmanaged]
public float OrthographicSize { get; set; }
Property Value
System.
|
OverrideMainCamera
The overriden main camera.
Declaration
[Unmanaged]
public static Camera OverrideMainCamera { get; set; }
Property Value
RenderFlags
Frame rendering flags used to switch between graphics features for this camera.
Declaration
[EditorOrder(110)]
[EditorDisplay("Camera", null)]
[Unmanaged]
public ViewFlags RenderFlags { get; set; }
Property Value
RenderLayersMask
The layers mask used for rendering using this camera. Can be used to include or exclude specific actor layers from the drawing.
Declaration
[EditorOrder(100)]
[EditorDisplay("Camera", null)]
[Unmanaged]
public LayersMask RenderLayersMask { get; set; }
Property Value
RenderMode
Describes frame rendering modes for this camera.
Declaration
[EditorOrder(120)]
[EditorDisplay("Camera", null)]
[Unmanaged]
public ViewMode RenderMode { get; set; }
Property Value
UsePerspective
Gets or sets the value indicating if camera should use perspective rendering mode, otherwise it will use orthographic projection.
Declaration
[EditorOrder(10)]
[EditorDisplay("Camera", null)]
[Unmanaged]
public bool UsePerspective { get; set; }
Property Value
System.
|
Viewport
Gets the camera viewport.
Declaration
[Unmanaged]
public Viewport Viewport { get; }
Property Value
Methods
ConvertMouseToRay(Float2)
Converts the mouse position to 3D ray.
Declaration
[Unmanaged]
public Ray ConvertMouseToRay(Float2 mousePosition)
Parameters
Float2
mousePosition
The mouse position. |
Returns
Ray
Mouse ray |
ConvertMouseToRay(Float2, ref Viewport)
Converts the mouse position to 3D ray.
Declaration
[Unmanaged]
public Ray ConvertMouseToRay(Float2 mousePosition, ref Viewport viewport)
Parameters
Returns
Ray
Mouse ray |
GetMatrices(out Matrix, out Matrix)
Calculates the view and the projection matrices for the camera.
Declaration
[Unmanaged]
public void GetMatrices(out Matrix view, out Matrix projection)
Parameters
GetMatrices(out Matrix, out Matrix, ref Viewport)
Calculates the view and the projection matrices for the camera. Support using custom viewport.
Declaration
[Unmanaged]
public void GetMatrices(out Matrix view, out Matrix projection, ref Viewport viewport)
Parameters
GetMatrices(out Matrix, out Matrix, ref Viewport, ref Vector3)
Calculates the view and the projection matrices for the camera. Support using custom viewport and view origin.
Declaration
[Unmanaged]
public void GetMatrices(out Matrix view, out Matrix projection, ref Viewport viewport, ref Vector3 origin)
Parameters
IntersectsItselfEditor(ref Ray, out Single)
Intersection check for editor picking the camera
Declaration
[Unmanaged]
public bool IntersectsItselfEditor(ref Ray ray, out float distance)
Parameters
Ray
ray
|
System.
|
Returns
System.
|
IsPointOnView(Vector3)
Checks if the 3d point of the world is in the camera's field of view.
Declaration
[Unmanaged]
public bool IsPointOnView(Vector3 worldSpaceLocation)
Parameters
Vector3
worldSpaceLocation
World Position (XYZ). |
Returns
System. Returns true if the point is within the field of view. |
ProjectPoint(Vector3, out Float2)
Projects the point from 3D world-space to game window coordinates (in screen pixels for default viewport calculated from Viewport).
Declaration
[Unmanaged]
public void ProjectPoint(Vector3 worldSpaceLocation, out Float2 gameWindowSpaceLocation)
Parameters
ProjectPoint(Vector3, out Float2, ref Viewport)
Projects the point from 3D world-space to the camera viewport-space (in screen pixels for given viewport).
Declaration
[Unmanaged]
public void ProjectPoint(Vector3 worldSpaceLocation, out Float2 cameraViewportSpaceLocation, ref Viewport viewport)
Parameters
UnprojectPoint(Float2, Single, out Vector3)
Converts a game window-space point into a corresponding point in world space.
Declaration
[Unmanaged]
public void UnprojectPoint(Float2 gameWindowSpaceLocation, float depth, out Vector3 worldSpaceLocation)
Parameters
UnprojectPoint(Float2, Single, out Vector3, ref Viewport)
Converts a camera viewport-space point into a corresponding point in world space.
Declaration
[Unmanaged]
public void UnprojectPoint(Float2 cameraViewportSpaceLocation, float depth, out Vector3 worldSpaceLocation, ref Viewport viewport)