class
Camera
Camera determines how is world geometry projected onto a 2D surface.
You may position and orient it in space, set options like aspect ratio and field or view and it outputs view and projection matrices required for rendering.
Public
Constructors
Camera
Methods
~Camera
SetMain
Determines whether this is the main application camera.
Main camera controls the final render surface that is displayed to the user.
IsMain
RequestCapture
Requests an asynchronous capture of the next rendered frame from this camera.
Returns: Async operation with captured pixel data, or nullptr if camera is inactive.
staticGetRttiStatic
~TCamera<IsRenderProxy>
SetFlags
Determines flags used for controlling the camera behaviour.
GetFlags
SetHorizontalFOV
Determines the camera horizontal field of view.
This determines how wide the camera viewing angle is along the horizontal axis. Vertical FOV is calculated from the horizontal FOV and the aspect ratio.
GetHorizontalFOV
SetNearClipDistance
Determines the distance from the frustum to the near clipping plane.
Anything closer than the near clipping plane will not be rendered. Decreasing this value decreases depth buffer precision.
GetNearClipDistance
SetFarClipDistance
Determines the distance from the frustum to the far clipping plane.
Anything farther than the far clipping plane will not be rendered. Increasing this value decreases depth buffer precision.
GetFarClipDistance
SetAspectRatio
Determines the current viewport aspect ratio (width / height).
GetAspectRatio
SetFrustumExtents
Manually set the extents of the frustum that will be used when calculating the projection matrix.
This will prevents extents for being automatically calculated from aspect and near plane so it is up to the caller to keep these values accurate.
- left
- The position where the left clip plane intersect the near clip plane, in view space.
- right
- The position where the right clip plane intersect the near clip plane, in view space.
- top
- The position where the top clip plane intersect the near clip plane, in view space.
- bottom
- The position where the bottom clip plane intersect the near clip plane, in view space.
ResetFrustumExtents
Resets frustum extents so they are automatically derived from other values.
This is only relevant if you have previously set custom extents.
GetFrustumExtents
Returns the extents of the frustum in view space at the near plane.
GetProjectionMatrix
Returns the standard projection matrix that determines how are 3D points projected to two dimensions.
The layout of this matrix depends on currently used GPU backend.
GetUnadjustedProjectionMatrix
Returns the standard projection matrix that determines how are 3D points projected to two dimensions.
Returned matrix is standard following right-hand rules and depth range of [-1, 1]. Note that currently used GPU backend might expect different rules, in which case use GetProjectionMatrix() to retrieve an adjusted matrix.
GetViewMatrix
Gets the camera view matrix.
Used for positioning/orienting the camera.
SetCustomProjectionMatrix
Sets whether the camera should use the custom projection matrix.
When this is enabled camera will no longer calculate its projection matrix based on field of view, aspect and other parameters and caller will be resonsible to keep the projection matrix up to date.
IsCustomProjectionMatrixEnabled
Returns the extents of the frustum in view space at the near plane.
SetCustomViewMatrix
Sets whether the camera should use the custom view matrix.
When this is enabled camera will no longer calculate its view matrix based on position/orientation and caller will be resonsible to keep the view matrix up to date.
IsCustomViewMatrixEnabled
Returns true if a custom view matrix is used.
GetFrustum
Returns a convex volume representing the visible area of the camera, in local space.
GetWorldFrustum
Returns a convex volume representing the visible area of the camera, in world space.
SetProjectionType
Determines the type of projection used by the camera.
Projection type controls how is 3D geometry projected onto a 2D plane.
GetProjectionType
SetOrthographicSize
Sets the orthographic window size, for use with orthographic rendering only.
- width
- Width of the window in world units.
- height
- Height of the window in world units.
SetOrthographicHeight
Determines the type of projection used by the camera.
Projection type controls how is 3D geometry projected onto a 2D plane.
GetOrthographicHeight
SetOrthographicWidth
Determines the orthographic window width, for use with orthographic rendering only.
The height of the window will be calculated from the aspect ratio. Value is specified in world units.
GetOrthographicWidth
SetPriority
Determines a priority that determines in which orders the cameras are rendered.
This only applies to cameras rendering to the same render target. Higher value means the camera will be rendered sooner.
GetPriority
SetLayers
Determines layer bitfield that is used when determining which object should the camera render.
GetLayers
SetSampleCount
Determines number of samples to use when rendering to this camera.
Values larger than 1 will enable MSAA rendering.
GetSampleCount
GetViewport
Returns the viewport used by the camera.
SetRenderSettings
Settings that control rendering for this view.
They determine how will the renderer process this view, which effects will be enabled, and what properties will those effects use.
GetRenderSettings
NotifyNeedsRedraw
Notifies a on-demand camera that it should re-draw its contents on the next frame.
Ignored for a camera that isn't on-demand.
WorldToScreenPoint
Converts a point in world space to screen coordinates.
- worldPoint
- 3D point in world space.
Returns: 2D point on the render target attached to the camera's viewport, in pixels.
WorldToNDCPoint
Converts a point in world space to normalized device coordinates.
- worldPoint
- 3D point in world space.
Returns: 2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.
WorldToViewPoint
Converts a point in world space to view space coordinates.
- worldPoint
- 3D point in world space.
Returns: 3D point relative to the camera's coordinate system.
ScreenToWorldPoint
Converts a point in screen space to a point in world space.
- screenPoint
- 2D point on the render target attached to the camera's viewport, in pixels.
- depth
- Depth to place the world point at, in world coordinates. The depth is applied to the vector going from camera origin to the point on the near plane.
Returns: 3D point in world space.
ScreenToWorldPointDeviceDepth
Converts a point in screen space (pixels corresponding to render target attached to the camera) to a point in world space.
- screenPoint
- Point to transform.
- deviceDepth
- Depth to place the world point at, in normalized device coordinates.
Returns: 3D point in world space.
ScreenToViewPoint
Converts a point in screen space to a point in view space.
- screenPoint
- 2D point on the render target attached to the camera's viewport, in pixels.
- depth
- Depth to place the world point at, in device depth. The depth is applied to the vector going from camera origin to the point on the near plane.
Returns: 3D point relative to the camera's coordinate system.
ScreenToNDCPoint
Converts a point in screen space to normalized device coordinates.
- screenPoint
- 2D point on the render target attached to the camera's viewport, in pixels.
Returns: 2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.
ViewToWorldPoint
Converts a point in view space to world space.
- viewPoint
- 3D point relative to the camera's coordinate system.
Returns: 3D point in world space.
ViewToScreenPoint
Converts a point in view space to screen space.
- viewPoint
- 3D point relative to the camera's coordinate system.
Returns: 2D point on the render target attached to the camera's viewport, in pixels.
ViewToNDCPoint
Converts a point in view space to normalized device coordinates.
- viewPoint
- 3D point relative to the camera's coordinate system.
Returns: 2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.
NDCToWorldPoint
Converts a point in normalized device coordinates to world space.
- ndcPoint
- 2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.
- depth
- Depth to place the world point at. The depth is applied to the vector going from camera origin to the point on the near plane.
Returns: 3D point in world space.
NDCToViewPoint
Converts a point in normalized device coordinates to view space.
- ndcPoint
- 2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.
- depth
- Depth to place the world point at. The depth is applied to the vector going from camera origin to the point on the near plane.
Returns: 3D point relative to the camera's coordinate system.
NDCToScreenPoint
Converts a point in normalized device coordinates to screen space.
- ndcPoint
- 2D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport.
Returns: 2D point on the render target attached to the camera's viewport, in pixels.
ScreenPointToRay
Converts a point in screen space to a ray in world space.
- screenPoint
- 2D point on the render target attached to the camera's viewport, in pixels.
Returns: Ray in world space, originating at the selected point on the camera near plane.
ProjectPoint
Projects a point in view space to normalized device coordinates.
Similar to ViewToNDCPoint() but preserves the depth component.
- point
- 3D point relative to the camera's coordinate system.
Returns: 3D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport. Z value range depends on active render API.
UnprojectPoint
Un-projects a point in normalized device space to view space.
- point
- 3D point in normalized device coordinates ([-1, 1] range), relative to the camera's viewport. Z value range depends on active render API.
Returns: 3D point relative to the camera's coordinate system.
Protected
Constructors
Camera
Methods
Initialize
Construct any resources the component needs before use.
Called when the parent scene object is initialized. A non-initialized component shouldn't be used in a live scene (i.e. it should not receive any of the component logic updates or events).
OnCreated
Called once when the component has been created.
Called regardless of the state the component is in.
OnBeginPlay
Called once when the component first leaves the Stopped state.
This includes component creation if requirements for leaving Stopped state are met, in which case it is called after OnCreated. Note this is called even if the component is in disabled state.
OnEnabled
Called every time a component leaves the Stopped state, if the component is enabled.
This includes component creation if requirements for leaving the Stopped state are met. When called during creation it is called after OnBeginPlay.
OnDisabled
Called every time a component is placed into the Stopped state.
This includes component destruction if component wasn't already in Stopped state during destruction. When called during destruction it is called before OnDestroyed.
OnDestroyed
Called once just before the component is destroyed.
Called regardless of the state the component is in.
OnTransformChanged
Called when the component's parent scene object has changed.
Not called if the component is in Stopped state. Also only called if necessary notify flags are set via SetNotifyFlagsInternal().
CreateRenderProxy
Creates an object that contains render thread specific data and methods for this object.
Can be null if such object is not required.
CreateRenderProxySyncPacket
Creates a data packet that will be used for syncing the core object with it's render proxy.
Caller must free the retrieved packet using the provided allocator when done using it.
GetCoreDependencies
Populates the provided array with all core objects that this core object depends upon.
Dependencies are required for syncing to the render thread, so the system can be aware to update the dependant objects if a dependency is marked as dirty (for example updating a camera's viewport should also trigger an update on camera so it has a chance to potentially update its data).
MarkRenderProxyDataDirty
Marks the render proxy data as dirty.
This causes the SyncToRenderProxy() method to trigger the next time objects are synced to the render thread.
- flags
- Flags in case you want to signal that only part of the internal data is dirty. SyncToRenderProxy() will be called regardless and it's up to the implementation to read the flags value if needed.
GetTransform
Returns the world space transform of the object.
CalculateProjectionParameters
Calculate projection parameters that are used when constructing the projection matrix.
UpdateFrustum
Recalculate frustum if dirty.
UpdateFrustumPlanes
Recalculate frustum planes if dirty.
IsFrustumOutOfDate
Checks if the frustum requires updating.
InvalidateFrustum
Notify camera that the frustum requires to be updated.
GetViewportArea
Returns a rectangle that defines the viewport position and size, in pixels.
Fields
mLayers
Bitfield that can be used for filtering what objects the camera sees.
mHorzFOV
Horizontal field of view represents how wide is the camera angle.
mFarDist
Clip any objects further than this.
Larger value decreases depth precision at smaller depths.
mNearDist
Clip any objects close than this.
Smaller value decreases depth precision at larger depths.
mAspect
Width/height viewport ratio.
mOrthoHeight
Height in world units used for orthographic cameras.
mPriority
Determines in what order will the camera be rendered.
Higher priority means the camera will be rendered sooner.
mMain
Determines does this camera render to the main render surface.
mCustomProjMatrix
Is custom projection matrix set.
mCustomViewMatrix
Is custom view matrix set.
mMSAA
Number of samples to render the scene with.
mFrustumExtentsManuallySet
Are frustum extents manually set.
mProjMatrixRS
Cached render-system specific projection matrix.
mProjMatrix
Cached projection matrix that determines how are 3D points projected to a 2D viewport.
mViewMatrix
Cached view matrix that determines camera position/orientation.
mRecalcView
Should view matrix be recalculated.
mFrustum
Main clipping planes describing cameras visible area.
mRecalcFrustum
Should frustum be recalculated.
mRecalcFrustumPlanes
Should frustum planes be recalculated.
mLeft
Frustum extents.
mRight
Frustum extents.
mTop
Frustum extents.
mBottom
Frustum extents.
mRenderSettings
Settings used to control rendering for this camera.