Vp::GameObject
Regular world object entity. More...
#include "Viewport/entity/GameObject.h"
Inherits from Vp::Entity
Inherited by Vp::ColoredObject, Vp::GridObject, Vp::TexturedObject
Public Functions
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 |
void | render(const glm::mat4 & model, const glm::mat4 & view, const glm::mat4 & projection, const DisplayOptions & displayOptions)<br>Renders the entity with default rendering parameters. |
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. |
virtual void | render(const glm::mat4 & model, const glm::mat4 & view, const glm::mat4 & projection, const RenderContext & context)<br>IMPLEMENTATION NOTE: Derived entity classes should expect a certain kind of shader and be able to directly static cast to it. |
virtual void | update(Scene & scene) override |
Public Attributes
Name | |
---|---|
Core::Mesh * | m_mesh |
float | m_opacity |
Additional inherited members
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) |
DisplayType | getDisplayType() const |
glm::vec3 | getHighlightColor() const |
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 | 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::GameObject;
class Vp::GameObject;
Regular world object entity.
Represents a physical drawable object.
Public Functions Documentation
function GameObject
GameObject() =default
GameObject() =default
Creates an empty GameObject.
Before rendering a mesh and a shader need to be set!
function GameObject
GameObject(
Core::Mesh * mesh,
ObjectShader * shader
)
GameObject(
Core::Mesh * mesh,
ObjectShader * shader
)
function dispose
virtual void dispose() override
virtual void dispose() override
Reimplements: Vp::Entity::dispose
function prepareRenderContext
virtual void prepareRenderContext(
RenderContext & context,
const DisplayOptions & displayOptions
) override
virtual void prepareRenderContext(
RenderContext & context,
const DisplayOptions & displayOptions
) override
Reimplements: Vp::Entity::prepareRenderContext
Reimplemented by: Vp::GridObject::prepareRenderContext, Vp::TexturedObject::prepareRenderContext
function render
void render(
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
const DisplayOptions & displayOptions
)
void render(
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
const DisplayOptions & displayOptions
)
Renders the entity with default rendering parameters.
Parameters:
- model Implicit model matrix, multiplies the entity's model transform from the left.
- view View matrix
- projection Projection matrix
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::Entity::render
Reimplemented by: Vp::GridObject::render, Vp::SceneCamera::render, Vp::SceneModel::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 render
virtual void render(
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
const RenderContext & context
)
virtual void render(
const glm::mat4 & model,
const glm::mat4 & view,
const glm::mat4 & projection,
const RenderContext & context
)
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::Entity::render
Reimplemented by: Vp::GridObject::render, Vp::SceneCamera::render, Vp::SceneModel::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 update
virtual void update(
Scene & scene
) override
virtual void update(
Scene & scene
) override
Reimplements: Vp::Entity::update
Reimplemented by: Vp::SceneCamera::update, Vp::SceneModel::update, Vp::SceneScreen::update
Public Attributes Documentation
variable m_mesh
Core::Mesh * m_mesh;
Core::Mesh * m_mesh;
variable m_opacity
float m_opacity {0.5f};
float m_opacity {0.5f};
Updated on 2025-05-31 at 12:55:31 +0000