Vp::Entity
A scene entity base class.
#include "Viewport/entity/Entity.h"
Inherited by Vp::GameObject
Public Functions
Name | |
---|---|
Entity() | |
virtual | ~Entity() =default |
virtual void | dispose() =0 |
virtual DisplayType | getDisplayType() const |
virtual glm::vec3 | getHighlightColor() const |
virtual bool | isHighlighted() const |
virtual void | onSceneAdd(Scene & scene)<br>Called when the entity is added to a scene. |
virtual void | onSceneRemove(Scene & scene)<br>Called when the entity is removed from a scene. |
void | render(glm::mat4 view, glm::mat4 projection) |
void | render(glm::mat4 view, glm::mat4 projection, bool silhouette) |
virtual void | setDisplayType(DisplayType type) |
virtual void | setHighlightColor(glm::vec3 highlightColor) |
virtual void | setHighlighted(bool highlight) |
virtual void | update(Scene & scene) =0 |
Protected Functions
Name | |
---|---|
void | render(Shader * shader, glm::mat4 view, glm::mat4 projection) |
virtual void | render(Shader * shader, glm::mat4 view, glm::mat4 projection, bool silhouette) =0<br>IMPLEMENTATION NOTE: Derived entity classes should expect a certain kind of shader and be able to directly static cast to it. |
Public Attributes
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. |
glm::mat4 | m_modelMatrix <br>Model transformation of the entity. |
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
Name | |
---|---|
DisplayType | m_displayType |
Public Functions Documentation
function Entity
Entity()
Entity()
function ~Entity
virtual ~Entity() =default
virtual ~Entity() =default
function dispose
virtual void dispose() =0
virtual void dispose() =0
Reimplemented by: Vp::GameObject::dispose
function getDisplayType
inline virtual DisplayType getDisplayType() const
inline virtual DisplayType getDisplayType() const
function getHighlightColor
inline virtual glm::vec3 getHighlightColor() const
inline virtual glm::vec3 getHighlightColor() const
function isHighlighted
inline virtual bool isHighlighted() const
inline virtual bool isHighlighted() const
function onSceneAdd
inline virtual void onSceneAdd(
Scene & scene
)
inline virtual void onSceneAdd(
Scene & scene
)
Called when the entity is added to a scene.
Parameters:
- scene Scene to which it has been added
Reimplemented by: Vp::SceneCamera::onSceneAdd, Vp::SceneModel::onSceneAdd
function onSceneRemove
inline virtual void onSceneRemove(
Scene & scene
)
inline virtual void onSceneRemove(
Scene & scene
)
Called when the entity is removed from a scene.
Parameters:
- scene Scene from which it has been removed
Reimplemented by: Vp::SceneCamera::onSceneRemove, Vp::SceneModel::onSceneRemove
function render
inline void render(
glm::mat4 view,
glm::mat4 projection
)
inline void render(
glm::mat4 view,
glm::mat4 projection
)
function render
inline void render(
glm::mat4 view,
glm::mat4 projection,
bool silhouette
)
inline void render(
glm::mat4 view,
glm::mat4 projection,
bool silhouette
)
function setDisplayType
inline virtual void setDisplayType(
DisplayType type
)
inline virtual void setDisplayType(
DisplayType type
)
function setHighlightColor
inline virtual void setHighlightColor(
glm::vec3 highlightColor
)
inline virtual void setHighlightColor(
glm::vec3 highlightColor
)
function setHighlighted
inline virtual void setHighlighted(
bool highlight
)
inline virtual void setHighlighted(
bool highlight
)
function update
virtual void update(
Scene & scene
) =0
virtual void update(
Scene & scene
) =0
Reimplemented by: Vp::FrustumObject::update, Vp::GameObject::update, Vp::SceneCamera::update, Vp::SceneModel::update
Protected Functions Documentation
function render
inline void render(
Shader * shader,
glm::mat4 view,
glm::mat4 projection
)
inline void render(
Shader * shader,
glm::mat4 view,
glm::mat4 projection
)
function render
virtual void render(
Shader * shader,
glm::mat4 view,
glm::mat4 projection,
bool silhouette
) =0
virtual void render(
Shader * shader,
glm::mat4 view,
glm::mat4 projection,
bool silhouette
) =0
IMPLEMENTATION NOTE: Derived entity classes should expect a certain kind of shader and be able to directly static cast to it.
Reimplemented by: Vp::ColoredObject::render, Vp::FrustumObject::render, Vp::GameObject::render, Vp::SceneModel::render, Vp::TexturedObject::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.
Public Attributes Documentation
variable m_backFaceCull
bool m_backFaceCull;
bool m_backFaceCull;
variable m_explicitTransparencyOrder
unsigned int m_explicitTransparencyOrder;
unsigned int m_explicitTransparencyOrder;
Explicit order for ordered transparency.
variable m_highlight
bool m_highlight;
bool m_highlight;
Whether to paint this entity with an outline, can be used for selection or just highlighting.
variable m_highlightColor
glm::vec3 m_highlightColor;
glm::vec3 m_highlightColor;
variable m_highlightUseDepth
bool m_highlightUseDepth;
bool m_highlightUseDepth;
Whether the highlight outline should respect the scene's depth buffer.
variable m_modelMatrix
glm::mat4 m_modelMatrix {1};
glm::mat4 m_modelMatrix {1};
Model transformation of the entity.
variable m_opaque
bool m_opaque;
bool m_opaque;
variable m_selectable
bool m_selectable;
bool m_selectable;
Whether this entity should be written into the selection stencil buffer.
variable m_selectionId
int m_selectionId {-1};
int m_selectionId {-1};
Id of the object, -1 if not assigned, for selection purposes.
variable m_shader
Shader * m_shader {nullptr};
Shader * m_shader {nullptr};
variable m_visible
bool m_visible;
bool m_visible;
variable m_wboit
bool m_wboit;
bool m_wboit;
Whether this entity should be rendered using order independent transparency, relevant if using a shader that supports wboit.
variable m_wboitFunc
int m_wboitFunc;
int m_wboitFunc;
Index of the weight function to be used in wboit.
Protected Attributes Documentation
variable m_displayType
DisplayType m_displayType {DisplayType::Default};
DisplayType m_displayType {DisplayType::Default};
Updated on 2024-11-06 at 20:16:53 +0000