class
#include <esp/gfx/RenderCamera.h>
RenderCamera
Derived classes
- class CubeMapCamera
Public types
- enum class Flag: unsigned int { FrustumCulling = 1 << 0, ObjectsOnly = 1 << 1, UseDrawableIdAsObjectId = 1 << 2, ClearDepth = 1 << 3, ClearColor = 1 << 4, ClearObjectId = 1 << 5 }
- Rendering Flags.
-
using Flags = Corrade::
Containers:: EnumSet<Flag> -
using DrawableTransforms = std::
vector<std:: pair<std:: reference_wrapper<Magnum:: SceneGraph:: Drawable3D>, Magnum:: Matrix4>>
Constructors, destructors, conversion operators
-
RenderCamera(scene::
SceneNode& node, esp::scene::SceneNodeSemanticDataIDX semanticDataIDX) explicit - Constructor.
-
RenderCamera(scene::
SceneNode& node, esp::scene::SceneNodeSemanticDataIDX semanticDataIDX, const vec3f& eye, const vec3f& target, const vec3f& up) - Constructor.
-
RenderCamera(scene::
SceneNode& node, esp::scene::SceneNodeSemanticDataIDX semanticDataIDX, const Magnum:: Vector3& eye, const Magnum:: Vector3& target, const Magnum:: Vector3& up) - Constructor.
- ~RenderCamera() defaulted override
- destructor do nothing, let magnum handle the camera
Public functions
-
auto resetViewingParameters(const Magnum::
Vector3& eye, const Magnum:: Vector3& target, const Magnum:: Vector3& up) -> RenderCamera& virtual - Reset the initial viewing parameters of the camera.
-
auto isInSceneGraph(const scene::
SceneGraph& sceneGraph) -> bool - Tell if the camera is attached to the scene graph.
-
auto node() -> scene::
SceneNode& - Get the scene node being attached to.
-
auto node() const -> const scene::
SceneNode& - Get a const ref to the scene node being attached to.
-
auto object() -> scene::
SceneNode& -
auto object() const -> const scene::
SceneNode& -
auto setProjectionMatrix(int width,
int height,
Mn::
Matrix4& projMat) -> RenderCamera& - Set precalculated projection matrix for this RenderCamera.
-
auto setProjectionMatrix(int width,
int height,
float znear,
float zfar,
Mn::
Deg hfov) -> RenderCamera& - Set precalculated projection matrix for this RenderCamera.
- auto setOrthoProjectionMatrix(int width, int height, float znear, float zfar, float scale) -> RenderCamera&
- Set projection matrix for Orthographic camera.
-
auto draw(MagnumDrawableGroup& drawables,
Flags flags = {}) -> uint32_
t - Overload function to render the drawables.
-
auto draw(DrawableTransforms& drawableTransforms,
Flags flags = {}) -> uint32_
t - Function to render drawables via the DrawableTransforms. These have already been filtered and culled, if enabled.
- auto cull(DrawableTransforms& drawableTransforms) -> size_t
- performs the frustum culling
- auto removeNonObjects(DrawableTransforms& drawableTransforms) -> size_t
- Cull Drawables for SceneNodes which are not OBJECT type.
- auto filterTransforms(DrawableTransforms& drawableTransforms, Flags flags = {}) -> size_t
- auto getSemanticDataIDX() const -> int
- This returns the index of the semantic data the drawable should use to populate the shader from the scene node.
-
auto unproject(const Mn::
Vector2i& viewportPosition, bool normalized = true) -> esp:: geo:: Ray - Unproject a 2D viewport point to a 3D ray with origin at camera position. Ray direction is optionally normalized. Non-normalized rays originate at the camera location and terminate at a view plane one unit down the Z axis.
- auto getPreviousNumVisibleDrawables() const -> size_t
- Query the cached number of Drawables visible after frustum culling for the most recent render pass.
Protected variables
-
Mn::
Matrix4 invertedProjectionMatrix - size_t previousNumVisibleDrawables_
- bool useDrawableIds_
- esp::scene::SceneNodeSemanticDataIDX semanticInfoIDX_
- esp::scene::SceneNodeSemanticDataIDX semanticIDXToUse_
Enum documentation
enum class esp:: gfx:: RenderCamera:: Flag: unsigned int
Rendering Flags.
Enumerators | |
---|---|
FrustumCulling |
Cull Drawables with bounding boxes not intersecting the camera frustum. |
ObjectsOnly |
Cull Drawables not attached to SceneNodes with scene::SceneNodeType::OBJECT. |
UseDrawableIdAsObjectId |
Use drawable id as the object id in the following rendering pass Internally, it is not a state machine, which means user needs to set it every frame if she needs the drawable ids. If not set, by default, it would use the semantic id (if "per vertex object id" is not set) |
ClearDepth |
Clear depth, used in the sub-class CubeMapCamera |
ClearColor |
Clear color, used in the sub-class CubeMapCamera |
ClearObjectId |
Clear object id, used in the sub-class CubeMapCamera |
Function documentation
esp:: gfx:: RenderCamera:: RenderCamera(scene:: SceneNode& node,
esp::scene::SceneNodeSemanticDataIDX semanticDataIDX) explicit
Constructor.
Parameters | |
---|---|
node | the scene node to which the camera is attached |
semanticDataIDX | The type of semantic id data rendered by this camera. Ignored if not rendering semantic data. |
esp:: gfx:: RenderCamera:: RenderCamera(scene:: SceneNode& node,
esp::scene::SceneNodeSemanticDataIDX semanticDataIDX,
const vec3f& eye,
const vec3f& target,
const vec3f& up)
Constructor.
Parameters | |
---|---|
node | the scene node to which the camera is attached |
semanticDataIDX | The type of semantic id data rendered by this camera. Ignored if not rendering semantic data. |
eye | the eye position (in PARENT node space) |
target | the target position (in PARENT node space) |
up | the up direction (in PARENT node space) NOTE: it will override any relative transformation w.r.t its parent node |
esp:: gfx:: RenderCamera:: RenderCamera(scene:: SceneNode& node,
esp::scene::SceneNodeSemanticDataIDX semanticDataIDX,
const Magnum:: Vector3& eye,
const Magnum:: Vector3& target,
const Magnum:: Vector3& up)
Constructor.
Parameters | |
---|---|
node | the scene node to which the camera is attached |
semanticDataIDX | The type of semantic id data rendered by this camera. Ignored if not rendering semantic data. |
eye | the eye position (in PARENT node space) |
target | the target position (in PARENT node space) |
up | the up direction (in PARENT node space) NOTE: it will override any relative transformation w.r.t its parent node |
RenderCamera& esp:: gfx:: RenderCamera:: resetViewingParameters(const Magnum:: Vector3& eye,
const Magnum:: Vector3& target,
const Magnum:: Vector3& up) virtual
Reset the initial viewing parameters of the camera.
Parameters | |
---|---|
eye | the eye position (in PARENT node space) |
target | the target position (in PARENT node space) |
up | the up direction (in PARENT node space) |
Returns | Reference to self (for method chaining) NOTE: it will override any relative transformation w.r.t its parent node |
bool esp:: gfx:: RenderCamera:: isInSceneGraph(const scene:: SceneGraph& sceneGraph)
Tell if the camera is attached to the scene graph.
Returns | true if it is attached to this scene graph, otherwise false |
---|
scene:: SceneNode& esp:: gfx:: RenderCamera:: object()
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
const scene:: SceneNode& esp:: gfx:: RenderCamera:: object() const
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.
RenderCamera& esp:: gfx:: RenderCamera:: setProjectionMatrix(int width,
int height,
Mn:: Matrix4& projMat)
Set precalculated projection matrix for this RenderCamera.
Parameters | |
---|---|
width | The width of the viewport |
height | The height of the viewport |
projMat | The projection matrix to use. |
Returns | A reference to this RenderCamera |
RenderCamera& esp:: gfx:: RenderCamera:: setProjectionMatrix(int width,
int height,
float znear,
float zfar,
Mn:: Deg hfov)
Set precalculated projection matrix for this RenderCamera.
Parameters | |
---|---|
width | The width of the viewport |
height | The height of the viewport |
znear | The location of the near clipping plane |
zfar | The location of the far clipping plane |
hfov | The horizontal field of view. |
Returns | A reference to this RenderCamera |
RenderCamera& esp:: gfx:: RenderCamera:: setOrthoProjectionMatrix(int width,
int height,
float znear,
float zfar,
float scale)
Set projection matrix for Orthographic camera.
Parameters | |
---|---|
width | The width of the viewport |
height | The height of the viewport |
znear | The location of the near clipping plane |
zfar | The location of the far clipping plane |
scale | A multiplier to scale the size of the resultant image. |
Returns | A reference to this RenderCamera |
uint32_ t esp:: gfx:: RenderCamera:: draw(MagnumDrawableGroup& drawables,
Flags flags = {})
Overload function to render the drawables.
Parameters | |
---|---|
drawables | a drawable group containing all the drawables |
flags | state flags to direct drawing |
Returns | the number of drawables that are drawn |
uint32_ t esp:: gfx:: RenderCamera:: draw(DrawableTransforms& drawableTransforms,
Flags flags = {})
Function to render drawables via the DrawableTransforms. These have already been filtered and culled, if enabled.
Parameters | |
---|---|
drawableTransforms | a vector of pairs of drawables and their transformation matrices. |
flags | state flags to direct drawing |
Returns | the number of drawables that are drawn |
size_t esp:: gfx:: RenderCamera:: cull(DrawableTransforms& drawableTransforms)
performs the frustum culling
Parameters | |
---|---|
drawableTransforms | a vector of pairs of Drawable3D object and its absolute transformation |
Returns | the number of drawables that are not culled |
NOTE: user are not encouraged to call this function directly. The preferred way is to enable the frustum culling by calling setFrustumCullingEnabled and then call draw
size_t esp:: gfx:: RenderCamera:: removeNonObjects(DrawableTransforms& drawableTransforms)
Cull Drawables for SceneNodes which are not OBJECT type.
Parameters | |
---|---|
drawableTransforms | a vector of pairs of Drawable3D object and its absolute transformation |
Returns | the number of drawables that are not culled |
esp:: geo:: Ray esp:: gfx:: RenderCamera:: unproject(const Mn:: Vector2i& viewportPosition,
bool normalized = true)
Unproject a 2D viewport point to a 3D ray with origin at camera position. Ray direction is optionally normalized. Non-normalized rays originate at the camera location and terminate at a view plane one unit down the Z axis.
Parameters | |
---|---|
viewportPosition | The 2D point on the viewport to unproject ([0,width], [0,height]). |
normalized | If true(default), normalize ray direction. |
Returns | a esp:: |
Variable documentation
Mn:: Matrix4 esp:: gfx:: RenderCamera:: invertedProjectionMatrix protected
cached inverted projection matrix to save compute on repeated calls (e.g. to unproject) without moving the camera
esp::scene::SceneNodeSemanticDataIDX esp:: gfx:: RenderCamera:: semanticInfoIDX_ protected
index of semantic id type held in scene nodes that this camera is made to render for semantic sensors. This may be overridden by object picking code.
esp::scene::SceneNodeSemanticDataIDX esp:: gfx:: RenderCamera:: semanticIDXToUse_ protected
the index to actually use to render semantic info. This will usually be the same as semanticInfoIDX above, but will hold a different value if being overridden by object picking.