Class Camera
Describes the camera projection and view. Provides information about how to render scene (viewport location and direction, etc.).
Inherited Members
Assembly: FlaxEngine.dll
File: Engine/Level/Actors/Camera.h
Syntax
public class Camera : public Actor
Fields
RenderFlags
Frame rendering flags used to switch between graphics features for this camera.
Declaration
public ViewFlags RenderFlags = ViewFlags::DefaultGame
Field Value
|
ViewFlags
|
RenderLayersMask
The layers mask used for rendering using this camera. Can be used to include or exclude specific actor layers from the drawing.
Declaration
public LayersMask RenderLayersMask
Field Value
|
LayersMask
|
RenderMode
Describes frame rendering modes for this camera.
Declaration
public ViewMode RenderMode = ViewMode::Default
Field Value
|
ViewMode
|
Methods
BeginPlay(SceneBeginData* data)
Called when adding object to the game.
Declaration
protected virtual void BeginPlay(SceneBeginData* data) override
Parameters
|
SceneBeginData
data
The initialization data (e.g. used to collect joints to link after begin). |
Overrides
ConvertMouseToRay(const Float2& mousePosition)
Converts the mouse position to 3D ray.
Declaration
public Ray ConvertMouseToRay(const Float2& mousePosition) const
Parameters
|
Float2
mousePosition
The mouse position. |
Returns
|
Ray
Mouse ray |
ConvertMouseToRay(const Float2& mousePosition, const Viewport& viewport)
Converts the mouse position to 3D ray.
Declaration
public Ray ConvertMouseToRay(const Float2& mousePosition, const Viewport& viewport) const
Parameters
|
Float2
mousePosition
The mouse position. |
|
Viewport
viewport
The viewport. |
Returns
|
Ray
Mouse ray |
Deserialize(DeserializeStream& stream, ISerializeModifier* modifier)
Deserializes object from the input stream.
Declaration
public virtual void Deserialize(DeserializeStream& stream, ISerializeModifier* modifier) override
Parameters
|
DeserializeStream
stream
The input stream. |
|
ISerializeModifier
modifier
The deserialization modifier object. Always valid. |
Overrides
Draw(RenderContext& renderContext)
Draws this actor. Called by Scene Rendering service. This call is more optimized than generic Draw (eg. geometry is rendered during all pass types but other actors are drawn only during GBufferFill pass).
Declaration
public virtual void Draw(RenderContext& renderContext) override
Parameters
|
RenderContext
renderContext
The rendering context. |
Overrides
GetCustomAspectRatio()
Gets the custom aspect ratio. 0 if not use custom value.
Declaration
public float GetCustomAspectRatio() const
Returns
|
float
|
GetEditorBox()
Gets actor bounding box (single actor, no children included) for editor tools.
Declaration
public virtual BoundingBox GetEditorBox() const override
Returns
|
BoundingBox
|
Overrides
GetFarPlane()
Gets camera's far plane distance.
Declaration
public float GetFarPlane() const
Returns
|
float
|
GetFieldOfView()
Gets the camera's field of view (in degrees).
Declaration
public float GetFieldOfView() const
Returns
|
float
|
GetFrustum()
GetMatrices(Matrix& view, Matrix& projection)
Calculates the view and the projection matrices for the camera.
Declaration
public void GetMatrices(Matrix& view, Matrix& projection) const
Parameters
|
Matrix
view
The result camera view matrix. |
|
Matrix
projection
The result camera projection matrix. |
GetMatrices(Matrix& view, Matrix& projection, const Viewport& viewport)
Calculates the view and the projection matrices for the camera. Support using custom viewport.
Declaration
public void GetMatrices(Matrix& view, Matrix& projection, const Viewport& viewport) const
Parameters
|
Matrix
view
The result camera view matrix. |
|
Matrix
projection
The result camera projection matrix. |
|
Viewport
viewport
The custom output viewport. |
GetMatrices(Matrix& view, Matrix& projection, const Viewport& viewport, const Vector3& origin)
Calculates the view and the projection matrices for the camera. Support using custom viewport and view origin.
Declaration
public void GetMatrices(Matrix& view, Matrix& projection, const Viewport& viewport, const Vector3& origin) const
Parameters
|
Matrix
view
The result camera view matrix. |
|
Matrix
projection
The result camera projection matrix. |
|
Viewport
viewport
The custom output viewport. |
|
Vector3
origin
The rendering view origin (for relative-to-camera rendering). |
GetNearPlane()
Gets camera's near plane distance.
Declaration
public float GetNearPlane() const
Returns
|
float
|
GetOrthographicScale()
Gets the orthographic projection scale.
Declaration
public float GetOrthographicScale() const
Returns
|
float
|
GetOrthographicSize()
Gets the orthographic projection view height (width is based on the aspect ratio). Use 0 for size to be based on the viewport size.
Declaration
public float GetOrthographicSize() const
Returns
|
float
|
GetUsePerspective()
Gets the value indicating if camera should use perspective rendering mode, otherwise it will use orthographic projection.
Declaration
public bool GetUsePerspective() const
Returns
|
bool
|
GetViewport()
HasContentLoaded()
Returns true if actor has loaded content.
Declaration
public virtual bool HasContentLoaded() const override
Returns
|
bool
|
Overrides
IntersectsItselfEditor(const Ray& ray, Real& distance)
Declaration
public bool IntersectsItselfEditor(const Ray& ray, Real& distance)
Parameters
|
Ray
ray
|
|
Real
distance
|
Returns
|
bool
|
IsPointOnView(const Vector3& worldSpaceLocation)
Checks if the 3d point of the world is in the camera's field of view.
Declaration
public bool IsPointOnView(const Vector3& worldSpaceLocation) const
Parameters
|
Vector3
worldSpaceLocation
World Position (XYZ). |
Returns
|
bool
Returns true if the point is within the field of view. |
OnDebugDrawSelected()
Draws debug shapes for the selected actor and all child scripts.
Declaration
public virtual void OnDebugDrawSelected() override
Overrides
OnDisable()
Called when actor gets removed from game systems. Occurs on EndPlay event or when actor gets inactivated in hierarchy. Use this event to unregister object from other game system (eg. audio).
Declaration
protected virtual void OnDisable() override
Overrides
OnEnable()
Called when actor gets added to game systems. Occurs on BeginPlay event or when actor gets activated in hierarchy. Use this event to register object to other game system (eg. audio).
Declaration
protected virtual void OnEnable() override
Overrides
OnTransformChanged()
Called when actor transform gets changed.
Declaration
protected virtual void OnTransformChanged() override
Overrides
ProjectPoint(const Vector3& worldSpaceLocation, Float2& cameraViewportSpaceLocation, const Viewport& viewport)
Projects the point from 3D world-space to the camera viewport-space (in screen pixels for given viewport).
Declaration
public void ProjectPoint(const Vector3& worldSpaceLocation, Float2& cameraViewportSpaceLocation, const Viewport& viewport) const
Parameters
|
Vector3
worldSpaceLocation
The input world-space location (XYZ in world). |
|
Float2
cameraViewportSpaceLocation
The output camera viewport-space location (XY in screen pixels). |
|
Viewport
viewport
The viewport. |
ProjectPoint(const Vector3& worldSpaceLocation, Float2& gameWindowSpaceLocation)
Projects the point from 3D world-space to game window coordinates (in screen pixels for default viewport calculated from Viewport).
Declaration
public void ProjectPoint(const Vector3& worldSpaceLocation, Float2& gameWindowSpaceLocation) const
Parameters
|
Vector3
worldSpaceLocation
The input world-space location (XYZ in world). |
|
Float2
gameWindowSpaceLocation
The output game window coordinates (XY in screen pixels). |
Serialize(SerializeStream& stream, const void* otherObj)
Serializes object to the output stream compared to the values of the other object instance (eg. default class object). If other object is null then serialize all properties.
Declaration
public virtual void Serialize(SerializeStream& stream, const void* otherObj) override
Parameters
|
SerializeStream
stream
The output stream. |
|
void
otherObj
The instance of the object to compare with and serialize only the modified properties. If null, then serialize all properties. |
Overrides
SetCustomAspectRatio(float value)
Sets the custom aspect ratio. 0 if not use custom value.
Declaration
public void SetCustomAspectRatio(float value)
Parameters
|
float
value
|
SetFarPlane(float value)
Sets camera's far plane distance.
Declaration
public void SetFarPlane(float value)
Parameters
|
float
value
|
SetFieldOfView(float value)
Sets camera's field of view (in degrees).
Declaration
public void SetFieldOfView(float value)
Parameters
|
float
value
|
SetNearPlane(float value)
Sets camera's near plane distance.
Declaration
public void SetNearPlane(float value)
Parameters
|
float
value
|
SetOrthographicScale(float value)
Sets the orthographic projection scale.
Declaration
public void SetOrthographicScale(float value)
Parameters
|
float
value
|
SetOrthographicSize(float value)
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
public void SetOrthographicSize(float value)
Parameters
|
float
value
|
SetUsePerspective(bool value)
Sets the value indicating if camera should use perspective rendering mode, otherwise it will use orthographic projection.
Declaration
public void SetUsePerspective(bool value)
Parameters
|
bool
value
|
UnprojectPoint(const Float2& cameraViewportSpaceLocation, float depth, Vector3& worldSpaceLocation, const Viewport& viewport)
Converts a camera viewport-space point into a corresponding point in world space.
Declaration
public void UnprojectPoint(const Float2& cameraViewportSpaceLocation, float depth, Vector3& worldSpaceLocation, const Viewport& viewport) const
Parameters
|
Float2
cameraViewportSpaceLocation
The input camera viewport-space location (XY in screen pixels). |
|
float
depth
The input camera-relative depth position (eg. clipping plane). |
|
Vector3
worldSpaceLocation
The output world-space location (XYZ in world). |
|
Viewport
viewport
The viewport. |
UnprojectPoint(const Float2& gameWindowSpaceLocation, float depth, Vector3& worldSpaceLocation)
Converts a game window-space point into a corresponding point in world space.
Declaration
public void UnprojectPoint(const Float2& gameWindowSpaceLocation, float depth, Vector3& worldSpaceLocation) const
Parameters
|
Float2
gameWindowSpaceLocation
The input game window coordinates (XY in screen pixels). |
|
float
depth
The input camera-relative depth position (eg. clipping plane). |
|
Vector3
worldSpaceLocation
The output world-space location (XYZ in world). |