Vp::SceneCamera
Viewport entity representing a Camera node in Core/GUI. More...
#include "Viewport/entity/nodes/SceneCamera.h"
Inherits from Vp::SceneModel, Vp::TexturedObject, Vp::SceneSelectable, Vp::GameObject, Vp::Entity
Public Functions
Name | |
---|---|
SceneCamera(Core::Mesh * mesh, PhongShader * shader) | |
~SceneCamera() override | |
virtual void | onSceneAdd(Scene & scene) override<br>Called when the entity is added to a scene. |
virtual void | onSceneRemove(Scene & scene) override<br>Called when the entity is removed from a scene. |
virtual void | render(const glm::mat4 & model, const glm::mat4 & view, const glm::mat4 & projection, const RenderContext & context) override<br>IMPLEMENTATION NOTE: Derived entity classes should expect a certain kind of shader and be able to directly static cast to it. |
void | setCoordinateSystem(Core::CameraCoordSystem & coordinateSystem) |
virtual void | update(Scene & scene) override |
Protected Functions
Name | |
---|---|
void | updateNearFrustumIndicator(const glm::mat4 & model, const glm::mat4 & projViewInv) |
Public Attributes
Name | |
---|---|
bool | m_fillFrustum |
glm::vec4 | m_frustumColor |
const float | m_frustumNearLinesOpacity |
glm::vec3 | m_frustumOutlineColor |
glm::mat4 | m_projectionMatrix |
bool | m_showCamera <br>Show/Hide the camera model, use this instead of this->m_visible. |
bool | m_showFrustum |
std::weak_ptr< TexturedObject > | m_trackedCameraModel <br>When tracking projection, the model of the camera is hidden and is replaced by this model, which ignores reference space and is positioned in a special manner. |
std::weak_ptr< ColoredObject > | m_trackedFrustumNear <br>Lines from the camera to the near plane, adjusted to ignore reference space, only visible during tracking. |
glm::mat4 | m_viewMatrix |
bool | m_visualizeDepth |
Protected Attributes
Name | |
---|---|
Core::CameraCoordSystem | m_coordinateSystem |
std::weak_ptr< FrustumObject > | m_frustum <br>The transparent frustum fill. |
std::weak_ptr< ColoredObject > | m_frustumNear <br>Lines from the camera to the near plane, hidden during tracking. |
std::shared_ptr< Core::Mesh > | m_frustumNearMesh |
std::weak_ptr< FrustumObject > | m_frustumOutline <br>Opaque frustum bounds outline. |
bool | m_isTracking |
std::shared_ptr< Core::Mesh > | m_trackedFrustumNearMesh |
Additional inherited members
Public Functions inherited from Vp::SceneModel
Name | |
---|---|
SceneModel(Core::Mesh * mesh, PhongShader * shader) | |
SceneModel(std::string modelAlias, PhongShader * shader)<br>Load mesh using an alias. | |
std::string | getModel() |
void | setModel(std::string modelAlias) |
Public Attributes inherited from Vp::SceneModel
Name | |
---|---|
std::weak_ptr< ColoredObject > | m_axes <br>Visualisation of the basis vectors. |
std::string | m_modelAlias |
float | m_programOpacity <br>Runtime opacity factor. |
float | m_scale <br>Optional scaling factor of the model, eg. an implicit model transformation. |
bool | m_showAxes |
Public Functions inherited from Vp::TexturedObject
Name | |
---|---|
TexturedObject(Core::Mesh * mesh, PhongShader * shader) | |
virtual void | prepareRenderContext(RenderContext & context, const DisplayOptions & displayOptions) override |
Public Attributes inherited from Vp::TexturedObject
Name | |
---|---|
glm::vec3 | m_tint |
float | m_tintStrength |
Public Attributes inherited from Vp::SceneSelectable
Name | |
---|---|
Core::ID | m_guiNodeId <br>ID of the gui node object is representing. |
Public Functions inherited from Vp::GameObject
Name | |
---|---|
GameObject() =default<br>Creates an empty GameObject. | |
GameObject(Core::Mesh * mesh, ObjectShader * shader) | |
virtual void | dispose() override |
virtual void | prepareRenderContext(RenderContext & context, const DisplayOptions & displayOptions) override |
Public Attributes inherited from Vp::GameObject
Name | |
---|---|
Core::Mesh * | m_mesh |
float | m_opacity |
Public Classes inherited from Vp::Entity
Name | |
---|---|
struct | RenderContext |
Public Types inherited from Vp::Entity
Name | |
---|---|
enum class | RenderType { NORMAL, CUSTOM, SILHOUETTE} |
Public Functions inherited from Vp::Entity
Name | |
---|---|
Entity() | |
virtual | ~Entity() =default |
RenderContext | createRenderContext(const DisplayOptions & displayOptions) |
virtual void | dispose() =0 |
DisplayType | getDisplayType() const |
glm::vec3 | getHighlightColor() const |
bool | isHighlighted() const |
virtual void | prepareRenderContext(RenderContext & context, const DisplayOptions & displayOptions) =0 |
void | setDisplayType(DisplayType type) |
void | setHighlightColor(glm::vec3 highlightColor) |
void | setHighlighted(bool highlight) |
Public Attributes inherited from Vp::Entity
Name | |
---|---|
bool | m_backFaceCull |
unsigned int | m_explicitTransparencyOrder <br>Explicit order for ordered transparency. |
bool | m_highlight <br>Whether to paint this entity with an outline, can be used for selection or just highlighting. |
glm::vec3 | m_highlightColor |
bool | m_highlightUseDepth <br>Whether the highlight outline should respect the scene's depth buffer. |
bool | m_ignoreReferenceSpace <br>When true, the "global"/"reference space" model matrix passed to viewport drawing methods is ignored. |
bool | m_ignoreUserClipping <br>Whether to ignore user clip planes defined in DisplayOptions. |
glm::mat4 | m_lastModelMatrix <br>Potentially modifed model matrix last passed to the shader. |
glm::mat4 | m_modelMatrix <br>Model "world" transformation of the entity. |
glm::mat4 | m_modMatrix <br>Modification transformation, precedes any other transformations, modifies entity vertex data as if the modified data came directly from a source (model file). |
bool | m_opaque |
bool | m_selectable <br>Whether this entity should be written into the selection stencil buffer. |
int | m_selectionId <br>Id of the object, -1 if not assigned, for selection purposes. |
Shader * | m_shader |
bool | m_visible |
bool | m_wboit <br>Whether this entity should be rendered using order independent transparency, relevant if using a shader that supports wboit. |
int | m_wboitFunc <br>Index of the weight function to be used in wboit. |
Protected Attributes inherited from Vp::Entity
Name | |
---|---|
DisplayType | m_displayType |
Detailed Description
class Vp::SceneCamera;
class Vp::SceneCamera;
Viewport entity representing a Camera node in Core/GUI.
This entity represents the camera model and manages several additional entities to represent various frustum indicators.
Public Functions Documentation
function SceneCamera
SceneCamera(
Core::Mesh * mesh,
PhongShader * shader
)
SceneCamera(
Core::Mesh * mesh,
PhongShader * shader
)
function ~SceneCamera
~SceneCamera() override
~SceneCamera() override
function onSceneAdd
virtual void onSceneAdd(
Scene & scene
) override
virtual void onSceneAdd(
Scene & scene
) override
Called when the entity is added to a scene.
Parameters:
- scene Scene to which it has been added
Reimplements: Vp::Entity::onSceneAdd
function onSceneRemove
virtual void onSceneRemove(
Scene & scene
) override
virtual void onSceneRemove(
Scene & scene
) override
Called when the entity is removed from a scene.
Parameters:
- scene Scene from which it has been removed
Reimplements: Vp::Entity::onSceneRemove
function render
virtual void render(
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
const RenderContext & context
) override
virtual void render(
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
const RenderContext & context
) override
IMPLEMENTATION NOTE: Derived entity classes should expect a certain kind of shader and be able to directly static cast to it.
Parameters:
- model Implicit model matrix, multiplies the entity's model transform from the left.
- view View matrix
- projection Projection matrix
- context Additional per-instance rendering parameters generated by createRenderContext() or prepareRenderContext().
Reimplements: Vp::GameObject::render
Currently there is no error checking and wrongly passed shader type will CAUSE UNDEFINED BEHAVIOUR!
Using dynamic casts instead might be undesirable (slow) here (this might just be a premature optimalization) Generally the shader passed to this method is the m_shader of this entity. However we need functionality that allows us to change the shader temporarily (like for drawing silhouettes) Because of this the shader can also sometimes be something else, usually some derived type of the one the entity expects. I couldn't find a way to inform what kinds of shaders an entity is able to use in its render methods. The type of the shader must be the base Shader class and so some kind of casting must occur.
Another option could be to use some kind of a typeid/enum system that tells us what type a shader is (rather than use dynamic cast). But that approach ignores inheritance which we need and having multiple types of shaders and entity member variable seems very inflexible.
The true elegant solution probably doesn't involve inheritance at all and rather uses composition, together with an ECS or something. But it was decided to not dive into that realm and so we are stuck with this seemingly simple but not very flexible inheritance structure.
function setCoordinateSystem
void setCoordinateSystem(
Core::CameraCoordSystem & coordinateSystem
)
void setCoordinateSystem(
Core::CameraCoordSystem & coordinateSystem
)
function update
virtual void update(
Scene & scene
) override
virtual void update(
Scene & scene
) override
Reimplements: Vp::GameObject::update
Protected Functions Documentation
function updateNearFrustumIndicator
void updateNearFrustumIndicator(
const glm::mat4 & model,
const glm::mat4 & projViewInv
)
void updateNearFrustumIndicator(
const glm::mat4 & model,
const glm::mat4 & projViewInv
)
Public Attributes Documentation
variable m_fillFrustum
bool m_fillFrustum {true};
bool m_fillFrustum {true};
variable m_frustumColor
glm::vec4 m_frustumColor {0.35f, 0.27f, 0.06f, 0.22f};
glm::vec4 m_frustumColor {0.35f, 0.27f, 0.06f, 0.22f};
variable m_frustumNearLinesOpacity
const float m_frustumNearLinesOpacity = 0.4f;
const float m_frustumNearLinesOpacity = 0.4f;
variable m_frustumOutlineColor
glm::vec3 m_frustumOutlineColor {1.0f, 0.0f, 0.0f};
glm::vec3 m_frustumOutlineColor {1.0f, 0.0f, 0.0f};
variable m_projectionMatrix
glm::mat4 m_projectionMatrix {1.f};
glm::mat4 m_projectionMatrix {1.f};
variable m_showCamera
bool m_showCamera {true};
bool m_showCamera {true};
Show/Hide the camera model, use this instead of this->m_visible.
variable m_showFrustum
bool m_showFrustum {true};
bool m_showFrustum {true};
variable m_trackedCameraModel
std::weak_ptr< TexturedObject > m_trackedCameraModel;
std::weak_ptr< TexturedObject > m_trackedCameraModel;
When tracking projection, the model of the camera is hidden and is replaced by this model, which ignores reference space and is positioned in a special manner.
variable m_trackedFrustumNear
std::weak_ptr< ColoredObject > m_trackedFrustumNear;
std::weak_ptr< ColoredObject > m_trackedFrustumNear;
Lines from the camera to the near plane, adjusted to ignore reference space, only visible during tracking.
variable m_viewMatrix
glm::mat4 m_viewMatrix {1.f};
glm::mat4 m_viewMatrix {1.f};
variable m_visualizeDepth
bool m_visualizeDepth {false};
bool m_visualizeDepth {false};
Protected Attributes Documentation
variable m_coordinateSystem
Core::CameraCoordSystem m_coordinateSystem {Core::g_openGL};
Core::CameraCoordSystem m_coordinateSystem {Core::g_openGL};
variable m_frustum
std::weak_ptr< FrustumObject > m_frustum;
std::weak_ptr< FrustumObject > m_frustum;
The transparent frustum fill.
variable m_frustumNear
std::weak_ptr< ColoredObject > m_frustumNear;
std::weak_ptr< ColoredObject > m_frustumNear;
Lines from the camera to the near plane, hidden during tracking.
variable m_frustumNearMesh
std::shared_ptr< Core::Mesh > m_frustumNearMesh;
std::shared_ptr< Core::Mesh > m_frustumNearMesh;
variable m_frustumOutline
std::weak_ptr< FrustumObject > m_frustumOutline;
std::weak_ptr< FrustumObject > m_frustumOutline;
Opaque frustum bounds outline.
variable m_isTracking
bool m_isTracking {false};
bool m_isTracking {false};
variable m_trackedFrustumNearMesh
std::shared_ptr< Core::Mesh > m_trackedFrustumNearMesh;
std::shared_ptr< Core::Mesh > m_trackedFrustumNearMesh;
Updated on 2025-05-31 at 12:55:31 +0000