Offers all controls to model a camera. More...
Static Public Member Functions | |
| static nkMemory::UniquePtr< Camera > | create (System *system=nullptr) |
Static Public Member Functions inherited from nkGraphics::Node | |
| static nkMemory::UniquePtr< Node > | create (System *system=nullptr) |
Offers all controls to model a camera.
See CameraManager::createOrRetrieve() or Camera::create() for instantiation.
| const Frustum& nkGraphics::Camera::getFrustum | ( | ) |
| nkMemory::StringView nkGraphics::Camera::getName | ( | ) | const |
| PROJECTION_TYPE nkGraphics::Camera::getProjectionType | ( | ) | const |
| float nkGraphics::Camera::getPerspectiveFov | ( | ) | const |
| float nkGraphics::Camera::getPerspectiveAspectRatio | ( | ) | const |
| float nkGraphics::Camera::getPerspectiveOffCenterFovLeft | ( | ) | const |
| float nkGraphics::Camera::getPerspectiveOffCenterFovRight | ( | ) | const |
| float nkGraphics::Camera::getPerspectiveOffCenterFovTop | ( | ) | const |
| float nkGraphics::Camera::getPerspectiveOffCenterFovBottom | ( | ) | const |
| float nkGraphics::Camera::getOrthographicHeight | ( | ) | const |
| float nkGraphics::Camera::getOrthographicAspectRatio | ( | ) | const |
| float nkGraphics::Camera::getNear | ( | ) | const |
| float nkGraphics::Camera::getFar | ( | ) | const |
| bool nkGraphics::Camera::getAutoUpdateOnContextSwitch | ( | ) | const |
| bool nkGraphics::Camera::getHidden | ( | ) | const |
| bool nkGraphics::Camera::getReverseZ | ( | ) | const |
| bool nkGraphics::Camera::getInfiniteZ | ( | ) | const |
| const nkMaths::Matrix& nkGraphics::Camera::getViewMatrix | ( | ) | const |
| const nkMaths::Matrix& nkGraphics::Camera::getProjectionMatrix | ( | ) | const |
| nkMaths::Matrix nkGraphics::Camera::getViewProjMatrix | ( | ) | const |
| nkMaths::Vector nkGraphics::Camera::getProjectionParameters | ( | ) | const |
Allows to retrieve the projection parameters of the camera. These parameters allow to reconstruct the linear ([0, 1]) depth from the camera, of a projected position.
To recompose the depth, these formulas can be used both within CPU or GPU shader code :
| Projection type | Formula |
|---|---|
| Perspective | B / (z - A) |
| Orthographic | near + z * far |
|
overridevirtual |
See Node::setPositionRelative().
Reimplemented from nkGraphics::Node.
|
overridevirtual |
See Node::setPositionAbsolute().
Reimplemented from nkGraphics::Node.
|
overridevirtual |
See Node::translateRelative().
Reimplemented from nkGraphics::Node.
|
overridevirtual |
See Node::translateAbsolute().
Reimplemented from nkGraphics::Node.
|
overridevirtual |
See Node::setOrientationRelative().
Reimplemented from nkGraphics::Node.
|
overridevirtual |
See Node::setOrientationAbsolute().
Reimplemented from nkGraphics::Node.
|
overridevirtual |
Reimplemented from nkGraphics::Node.
|
overridevirtual |
Reimplemented from nkGraphics::Node.
|
overridevirtual |
Reimplemented from nkGraphics::Node.
|
overridevirtual |
Reimplemented from nkGraphics::Node.
|
overridevirtual |
See Node::applyScale().
Reimplemented from nkGraphics::Node.
| void nkGraphics::Camera::setName | ( | nkMemory::StringView | name | ) |
Sets the name of the camera.
| name | The name to assign. |
| void nkGraphics::Camera::setAsPerspective | ( | float | fovRadian, |
| float | aspectRatioWidthOverHeight | ||
| ) |
Sets the camera up for perspective projection.
| fovRadian | The vertical field of view, in radian. |
| aspectRatioWidthOverHeight | The aspect ratio, given as width / height. |
| void nkGraphics::Camera::setAsPerspectiveReverseZ | ( | float | fovRadian, |
| float | aspectRatioWidthOverHeight | ||
| ) |
Sets the camera up for perspective projection, with a reverse Z logic (near = 1, far = 0). This redistributes the Z buffer precision, allowing to use a far bigger range for the camera.
The rendering needs to be accomodated to support this, by :
| fovRadian | The vertical field of view, in radian. |
| aspectRatioWidthOverHeight | The aspect ratio, given as width / height. |
| void nkGraphics::Camera::setAsPerspectiveReverseInfiniteZ | ( | float | fovRadian, |
| float | aspectRatioWidthOverHeight | ||
| ) |
Sets the camera up for perspective projection, with a reverse Z logic (near = 1, far = 0). All the details from setAsPerspectiveReverseZ() apply, this time considering far as being infinite.
This means the far value within the set range won't be used. While the infinite Z can be used in most cases once the rendering is adapted to the reverse Z values, it might still be attractive to use a finite Z value :
| fovRadian | The vertical field of view, in radian. |
| aspectRatioWidthOverHeight | The aspect ratio, given as width / height. |
| void nkGraphics::Camera::setAsPerspectiveOffCenter | ( | float | fovLeftRadian, |
| float | fovRightRadian, | ||
| float | fovTopRadian, | ||
| float | fovBottomRadian | ||
| ) |
Sets the camera up for off-center perspective projection.
| fovLeftRadian | The horizontal left field of view angle from the theoretical projection center, in radians. |
| fovRightRadian | The horizontal right field of view angle from the theoretical projection center, in radians. |
| fovTopRadian | The vertical top field of view angle from the theoretical projection center, in radians. |
| fovBottomRadian | The vertical bottom field of view angle from the theoretical projection center, in radians. |
| void nkGraphics::Camera::setAsPerspectiveOffCenterReverseZ | ( | float | fovLeftRadian, |
| float | fovRightRadian, | ||
| float | fovTopRadian, | ||
| float | fovBottomRadian | ||
| ) |
Sets the camera up for off-center perspective projection, with a reverse Z logic (near = 1, far = 0). Please check setAsPerspectiveReverseZ() to understand the benefits of doing so.
| fovLeftRadian | The horizontal left field of view angle from the theoretical projection center, in radians. |
| fovRightRadian | The horizontal right field of view angle from the theoretical projection center, in radians. |
| fovTopRadian | The vertical top field of view angle from the theoretical projection center, in radians. |
| fovBottomRadian | The vertical bottom field of view angle from the theoretical projection center, in radians. |
| void nkGraphics::Camera::setAsPerspectiveOffCenterReverseInfiniteZ | ( | float | fovLeftRadian, |
| float | fovRightRadian, | ||
| float | fovTopRadian, | ||
| float | fovBottomRadian | ||
| ) |
Sets the camera up for off-center perspective projection, with a reverse and infinite Z logic (near = 1, far = 0). Please check setAsPerspectiveReverseInfiniteZ() to understand the benefits of doing so.
| fovLeftRadian | The horizontal left field of view angle from the theoretical projection center, in radians. |
| fovRightRadian | The horizontal right field of view angle from the theoretical projection center, in radians. |
| fovTopRadian | The vertical top field of view angle from the theoretical projection center, in radians. |
| fovBottomRadian | The vertical bottom field of view angle from the theoretical projection center, in radians. |
| void nkGraphics::Camera::setAsOrthographic | ( | float | height, |
| float | aspectRatioWidthOverHeight | ||
| ) |
Sets the camera up for orthographic projection.
| height | The projection's height, in world units. |
| aspectRatioWidthOverHeight | The aspect ratio, given as width / height. |
| void nkGraphics::Camera::setAsOrthographicReverseZ | ( | float | height, |
| float | aspectRatioWidthOverHeight | ||
| ) |
Sets the camera up for orthographic projection, with a reverse Z logic (near = 1, far = 0). While the orthographic projection depth is linear and does not benefit from a reversed Z, this method can allow to match an orthographic projection with a rendering pipeline set for reverse Z projections.
| height | The projection's height, in world units. |
| aspectRatioWidthOverHeight | The aspect ratio, given as width / height. |
| void nkGraphics::Camera::setRange | ( | float | near, |
| float | far | ||
| ) |
Sets the projection's distance range interval.
| near | The near plane distance in world units. |
| far | The far plane distance in world units. |
| void nkGraphics::Camera::prepareForContext | ( | RenderContext * | context | ) |
Prepare the camera to be used by a render context. Will update values like the aspect ratio to be compatible with the rendering surface associated.
| context | The context to adapt to. |
| void nkGraphics::Camera::setAutoUpdateOnContextSwitch | ( | bool | value | ) |
Sets whether the camera should be updated for the context given before rendering. For instance, this will update the aspect ratio to fit the dimension of the render target.
| value | Whether the camera should be updated (true) or not (false) when a context switch is done. |
| void nkGraphics::Camera::setHidden | ( | bool | value | ) |
Sets whether the camera is hidden from project exporting. If enabled, the camera won't be exported in the decl files of the project. This can be useful when a camera is created programmatically in an application, and should not be duplicated in the declaration files.
| value | If the camera should be hidden (true) or not (false). |
| void nkGraphics::Camera::updateViewMatrix | ( | ) |
Updates the view matrix after new changes in parameters occurred.
| void nkGraphics::Camera::updateProjectionMatrix | ( | ) |
Updates the projection matrix after new changes in parameters occurred.
| void nkGraphics::Camera::lookAt | ( | const nkMaths::Vector & | point, |
| const nkMaths::Vector & | enforcedUp = nkMaths::Vector(0, 0, 0, 0) |
||
| ) |
Sets the camera to look at a coordinate.
| point | The point to look at. |
| enforcedUp | The up direction to take. If left blank, an automatic up is computed. |
| void nkGraphics::Camera::getNearPlanePoints | ( | nkMaths::Vector & | a, |
| nkMaths::Vector & | b, | ||
| nkMaths::Vector & | c, | ||
| nkMaths::Vector & | d | ||
| ) |
Fills up the 4 points of the near plane.
| a | The first point. |
| b | The second point. |
| c | The third point. |
| d | The fourth point. |
| void nkGraphics::Camera::getFarPlanePoints | ( | nkMaths::Vector & | a, |
| nkMaths::Vector & | b, | ||
| nkMaths::Vector & | c, | ||
| nkMaths::Vector & | d | ||
| ) |
Fills up the 4 points of the far plane.
| a | The first point. |
| b | The second point. |
| c | The third point. |
| d | The fourth point. |
| void nkGraphics::Camera::getFrustumCornersDirectionsWorld | ( | nkMaths::Vector & | a, |
| nkMaths::Vector & | b, | ||
| nkMaths::Vector & | c, | ||
| nkMaths::Vector & | d | ||
| ) |
Fills up the directions of the frustum corners, in world space. Can be seen as the directions from the near plane points, to their attached far plane points.
| a | The first direction. |
| b | The second direction. |
| c | The third direction. |
| d | The fourth direction. |
| void nkGraphics::Camera::getFrustumCornersDirectionsView | ( | nkMaths::Vector & | a, |
| nkMaths::Vector & | b, | ||
| nkMaths::Vector & | c, | ||
| nkMaths::Vector & | d | ||
| ) |
Fills up the directions of the frustum corners, in view space. Can be seen as the directions from the near plane points, to their attached far plane points.
| a | The first direction. |
| b | The second direction. |
| c | The third direction. |
| d | The fourth direction. |
| nkMaths::Vector nkGraphics::Camera::getDirectionAtPixelWorld | ( | int | x, |
| int | y, | ||
| RenderContext * | fromContext = nullptr |
||
| ) |
Returns the direction, in world space, for one pixel.
| x | The x coordinate of the pixel. |
| y | The y coordinate of the pixel. |
| fromContext | The context from which the pixel size should be retrieved. If left nullptr, the active context will be queried. |
| nkMaths::Vector nkGraphics::Camera::getDirectionAtScreenCoordWorld | ( | float | x, |
| float | y | ||
| ) |
Returns the direction, in world space, for a given position on screen.
| x | The x coordinate, in [0, 1]. |
| y | The y coordinate, in [0, 1]. |
| nkMaths::Vector nkGraphics::Camera::getDirectionAtPixelView | ( | int | x, |
| int | y, | ||
| RenderContext * | fromContext = nullptr |
||
| ) |
Returns the direction, in view space, for one pixel.
| x | The x coordinate of the pixel. |
| y | The y coordinate of the pixel. |
| fromContext | The context from which the pixel size should be retrieved. If left nullptr, the active context will be queried. |
| nkMaths::Vector nkGraphics::Camera::getDirectionAtScreenCoordView | ( | float | x, |
| float | y | ||
| ) |
Returns the direction, in view space, for a given position on screen. , in [
| x | The x coordinate0, 1]. |
| y | The y coordinate, in [0, 1]. |
|
overridevirtual |
Exports an item into a tree describing its structure and its data.
| rootNode | The node into which the object has to write its related information. |
Reimplemented from nkGraphics::Node.
|
overridevirtual |
Imports information from a tree which is supposed to describe its structure and data.
| rootNode | The root node of the tree holding the information. |
Reimplemented from nkGraphics::Node.
|
static |
Creates a standalone resource, linking it to a system, but no manager. This method can be used to allocate a resource and manually manage its lifetime.
| system | The system to create the resource into. If left to nullptr, then the Singleton instance will be used. |