Skip to content

Vp::SceneModel

Viewport entity representing a Model node in Core/GUI.

#include "Viewport/entity/nodes/SceneModel.h"

Inherits from Vp::TexturedObject, Vp::GameObject, Vp::Entity

Inherited by Vp::SceneCamera

Public Functions

Name
SceneModel(Core::Mesh * mesh, PhongShader * shader)
SceneModel(std::string modelAlias, PhongShader * shader)<br>Load mesh using an alias.
std::stringgetModel()
virtual voidonSceneAdd(Scene & scene) override<br>Called when the entity is added to a scene.
virtual voidonSceneRemove(Scene & scene) override<br>Called when the entity is removed from a scene.
virtual voidrender(Shader * shader, glm::mat4 view, glm::mat4 projection, bool silhouette) override<br>IMPLEMENTATION NOTE: Derived entity classes should expect a certain kind of shader and be able to directly static cast to it.
voidsetModel(std::string modelAlias)
virtual voidupdate(Scene & scene) override

Public Attributes

Name
std::weak_ptr< ColoredObject >m_axes <br>Visualisation of the basis vectors.
Core::IDm_guiNodeId <br>ID of the gui node object is representing.
std::stringm_modelAlias
boolm_showAxes

Additional inherited members

Public Functions inherited from Vp::TexturedObject

Name
TexturedObject(Core::Mesh * mesh, PhongShader * shader)

Public Attributes inherited from Vp::TexturedObject

Name
glm::vec3m_tint
floatm_tintStrength

Public Functions inherited from Vp::GameObject

Name
GameObject() =default<br>Creates an empty GameObject.
GameObject(Core::Mesh * mesh, ObjectShader * shader)
virtual voiddispose() override

Public Attributes inherited from Vp::GameObject

Name
Core::Mesh *m_mesh
floatm_opacity

Public Functions inherited from Vp::Entity

Name
Entity()
virtual~Entity() =default
virtual voiddispose() =0
virtual DisplayTypegetDisplayType() const
virtual glm::vec3getHighlightColor() const
virtual boolisHighlighted() const
virtual voidsetDisplayType(DisplayType type)
virtual voidsetHighlightColor(glm::vec3 highlightColor)
virtual voidsetHighlighted(bool highlight)

Public Attributes inherited from Vp::Entity

Name
boolm_backFaceCull
unsigned intm_explicitTransparencyOrder <br>Explicit order for ordered transparency.
boolm_highlight <br>Whether to paint this entity with an outline, can be used for selection or just highlighting.
glm::vec3m_highlightColor
boolm_highlightUseDepth <br>Whether the highlight outline should respect the scene's depth buffer.
glm::mat4m_modelMatrix <br>Model transformation of the entity.
boolm_opaque
boolm_selectable <br>Whether this entity should be written into the selection stencil buffer.
intm_selectionId <br>Id of the object, -1 if not assigned, for selection purposes.
Shader *m_shader
boolm_visible
boolm_wboit <br>Whether this entity should be rendered using order independent transparency, relevant if using a shader that supports wboit.
intm_wboitFunc <br>Index of the weight function to be used in wboit.

Protected Attributes inherited from Vp::Entity

Name
DisplayTypem_displayType

Public Functions Documentation

function SceneModel

cpp
SceneModel(
    Core::Mesh * mesh,
    PhongShader * shader
)
SceneModel(
    Core::Mesh * mesh,
    PhongShader * shader
)

function SceneModel

cpp
SceneModel(
    std::string modelAlias,
    PhongShader * shader
)
SceneModel(
    std::string modelAlias,
    PhongShader * shader
)

Load mesh using an alias.

function getModel

cpp
std::string getModel()
std::string getModel()

function onSceneAdd

cpp
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

cpp
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

cpp
virtual void render(
    Shader * shader,
    glm::mat4 view,
    glm::mat4 projection,
    bool silhouette
) override
virtual void render(
    Shader * shader,
    glm::mat4 view,
    glm::mat4 projection,
    bool silhouette
) override

IMPLEMENTATION NOTE: Derived entity classes should expect a certain kind of shader and be able to directly static cast to it.

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 setModel

cpp
void setModel(
    std::string modelAlias
)
void setModel(
    std::string modelAlias
)

function update

cpp
virtual void update(
    Scene & scene
) override
virtual void update(
    Scene & scene
) override

Reimplements: Vp::GameObject::update

Public Attributes Documentation

variable m_axes

cpp
std::weak_ptr< ColoredObject > m_axes;
std::weak_ptr< ColoredObject > m_axes;

Visualisation of the basis vectors.

variable m_guiNodeId

cpp
Core::ID m_guiNodeId;
Core::ID m_guiNodeId;

ID of the gui node object is representing.

variable m_modelAlias

cpp
std::string m_modelAlias {};
std::string m_modelAlias {};

variable m_showAxes

cpp
bool m_showAxes {true};
bool m_showAxes {true};

Updated on 2024-11-06 at 20:16:53 +0000