Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
Engine::Components::Mesh Class Reference

A component which can be attached as many times to an actor as one wants. It makes it possible to render a mesh attached to an object. More...

#include <MeshComponent.h>

Inheritance diagram for Engine::Components::Mesh:
Collaboration diagram for Engine::Components::Mesh:

Public Member Functions

 Mesh (Entities::Scene *owningScene, entt::entity &actor, Asset::MeshPath asset, std::shared_ptr< Entities::SceneNode > sceneNode, bool isVisible_=true, const std::string &name_="game object")
 Production constructor - uses EngineManager singleton to get RenderingDataManager.
 Mesh (Entities::Scene *owningScene, entt::entity &actor, Assets::GltfRenderableHandle renderable, std::shared_ptr< Entities::SceneNode > sceneNode, bool isVisible_=true, const std::string &name_="game object")
 Mesh (Entities::Scene *owningScene, entt::entity &actor, Assets::GeometryMeshHandle mesh, std::shared_ptr< Entities::SceneNode > sceneNode, bool isVisible_=true, const std::string &name_="game object")
 Mesh (Entities::Scene *owningScene, entt::entity &actor, Asset::MeshPath asset, std::shared_ptr< Entities::SceneNode > sceneNode, Core::RenderingDataManager *renderingDataManager, bool isVisible_=true, const std::string &name_="game object")
 Testable constructor - allows injecting RenderingDataManager for testing.
 Mesh (Entities::Scene *owningScene, entt::entity &actor, Assets::GltfRenderableHandle renderable, std::shared_ptr< Entities::SceneNode > sceneNode, Core::RenderingDataManager *renderingDataManager, bool isVisible_=true, const std::string &name_="game object")
 Mesh (Entities::Scene *owningScene, entt::entity &actor, Assets::GeometryMeshHandle mesh, std::shared_ptr< Entities::SceneNode > sceneNode, Core::RenderingDataManager *renderingDataManager, bool isVisible_=true, const std::string &name_="game object")
 ~Mesh () override=default
void beginPlay () override
 Called when the component is added to the scene or the game starts.
void endPlay () override
 Called when the component is removed or the game ends.
bool drawImGui () override
 Draw the debug UI.
bool isVisible () const
 If this mesh component should be considered for rendering.
Assets::MeshAssetRef getMeshAsset () const
 Gets the asset used by this mesh rendering component.
glm::mat4 getWorldTransform () const
 Getter for the world transform of the mesh component.
glm::mat4 getLocalTransform () const
 Gets the local model matrix which isn't affected by its parent.
Rendering::PipelineNames getMaterialNames () const
 Gets the material name of this mesh component.
void setMaterialOverride (Assets::MaterialHandle material)
void clearMaterialOverride ()
std::optional< Assets::MaterialHandlegetMaterialOverride () const
std::string getAssetName () const
 Gets the asset name of this mesh component (e.g. "rat")
void attachCollisionChild (Collision *collision)
void attachCollisionChildren (const std::vector< Collision * > &collisions)
void detachCollisionChild (const Collision *collision)
const std::vector< Collision * > & getCollisionChildren () const
bool ownsCollisionChild (const Logic *component) const
virtual void onMeshAssetResolved (Assets::MeshAssetRef meshAsset)
Public Member Functions inherited from Engine::Components::Logic
 Logic (Entities::Scene *owningScene)
 Logic (const Entities::SpawnContext &context)
virtual ~Logic ()=default
virtual std::string getComponentName () const
 Gets the component type name for debugging/UI.
virtual bool drawImGuiName ()
 Used to alter the name of the entity in the outliner.
virtual void tick (double deltaTime)
 Called every frame if ticking is enabled.
bool hasBegunPlay () const
bool canTick () const
 Checks if the component is currently set to tick.
void setCanTick (bool enable)
 Enables or disables ticking for this component.
Entities::EntitygetOwningEntity () const
 Gets the entity this component belongs to.

Static Public Attributes

static constexpr const char * ComponentName = "Mesh"
Static Public Attributes inherited from Engine::Components::Logic
static constexpr bool IsUnique = false
 Defines whether multiple instances of this component can exist on the same entity. Defaults to false (multiple allowed). Override in derived classes with static constexpr bool IsUnique = true; if needed.
static constexpr const char * ComponentName = "Logic"
 Fallback component type name. Derived classes may override getComponentName() for custom labels.

Protected Member Functions

std::shared_ptr< Entities::SceneNodegetSceneNode () const
Ecs::StaticMeshDatagetStaticMeshData () const
Protected Member Functions inherited from Engine::Components::Logic
Entities::ScenegetScene () const
 Gets the scene this component belongs to.
Core::SceneManagergetSceneManager () const
 Helper to get the SceneManager from the owning scene.

Protected Attributes

entt::entity componentEntity = entt::null
std::optional< std::shared_ptr< Entities::SceneNode > > sceneNode
Ecs::StaticMeshDatastaticMeshData = nullptr

Private Member Functions

void initializeMeshData (Entities::Scene *owningScene, entt::entity &actor, Asset::MeshPath asset, std::optional< Assets::GltfRenderableHandle > renderable, Assets::GeometryMeshHandle mesh)

Private Attributes

std::string name = "game object"
bool visible = true
Core::RenderingDataManager * renderingDataManager_ = nullptr
std::vector< Collision * > collisionChildren_
std::optional< Assets::MaterialHandlematerialOverride_

Detailed Description

A component which can be attached as many times to an actor as one wants. It makes it possible to render a mesh attached to an object.

Definition at line 44 of file MeshComponent.h.

Constructor & Destructor Documentation

◆ Mesh() [1/6]

Engine::Components::Mesh::Mesh ( Entities::Scene * owningScene,
entt::entity & actor,
Asset::MeshPath asset,
std::shared_ptr< Entities::SceneNode > sceneNode,
bool isVisible_ = true,
const std::string & name_ = "game object" )

Production constructor - uses EngineManager singleton to get RenderingDataManager.

References sceneNode.

◆ Mesh() [2/6]

Engine::Components::Mesh::Mesh ( Entities::Scene * owningScene,
entt::entity & actor,
Assets::GltfRenderableHandle renderable,
std::shared_ptr< Entities::SceneNode > sceneNode,
bool isVisible_ = true,
const std::string & name_ = "game object" )

References sceneNode.

◆ Mesh() [3/6]

Engine::Components::Mesh::Mesh ( Entities::Scene * owningScene,
entt::entity & actor,
Assets::GeometryMeshHandle mesh,
std::shared_ptr< Entities::SceneNode > sceneNode,
bool isVisible_ = true,
const std::string & name_ = "game object" )

References sceneNode.

◆ Mesh() [4/6]

Engine::Components::Mesh::Mesh ( Entities::Scene * owningScene,
entt::entity & actor,
Asset::MeshPath asset,
std::shared_ptr< Entities::SceneNode > sceneNode,
Core::RenderingDataManager * renderingDataManager,
bool isVisible_ = true,
const std::string & name_ = "game object" )

Testable constructor - allows injecting RenderingDataManager for testing.

References sceneNode.

◆ Mesh() [5/6]

Engine::Components::Mesh::Mesh ( Entities::Scene * owningScene,
entt::entity & actor,
Assets::GltfRenderableHandle renderable,
std::shared_ptr< Entities::SceneNode > sceneNode,
Core::RenderingDataManager * renderingDataManager,
bool isVisible_ = true,
const std::string & name_ = "game object" )

References sceneNode.

◆ Mesh() [6/6]

Engine::Components::Mesh::Mesh ( Entities::Scene * owningScene,
entt::entity & actor,
Assets::GeometryMeshHandle mesh,
std::shared_ptr< Entities::SceneNode > sceneNode,
Core::RenderingDataManager * renderingDataManager,
bool isVisible_ = true,
const std::string & name_ = "game object" )

References sceneNode.

◆ ~Mesh()

Engine::Components::Mesh::~Mesh ( )
overridedefault

Member Function Documentation

◆ attachCollisionChild()

void Engine::Components::Mesh::attachCollisionChild ( Collision * collision)

◆ attachCollisionChildren()

void Engine::Components::Mesh::attachCollisionChildren ( const std::vector< Collision * > & collisions)

◆ beginPlay()

void Engine::Components::Mesh::beginPlay ( )
overridevirtual

Called when the component is added to the scene or the game starts.

Reimplemented from Engine::Components::Logic.

◆ clearMaterialOverride()

void Engine::Components::Mesh::clearMaterialOverride ( )

◆ detachCollisionChild()

void Engine::Components::Mesh::detachCollisionChild ( const Collision * collision)

◆ drawImGui()

bool Engine::Components::Mesh::drawImGui ( )
overridevirtual

Draw the debug UI.

Reimplemented from Engine::Components::Logic.

◆ endPlay()

void Engine::Components::Mesh::endPlay ( )
overridevirtual

Called when the component is removed or the game ends.

Reimplemented from Engine::Components::Logic.

◆ getAssetName()

std::string Engine::Components::Mesh::getAssetName ( ) const
nodiscard

Gets the asset name of this mesh component (e.g. "rat")

Returns
asset name string, or empty if not available

◆ getCollisionChildren()

const std::vector< Collision * > & Engine::Components::Mesh::getCollisionChildren ( ) const
nodiscard

◆ getLocalTransform()

glm::mat4 Engine::Components::Mesh::getLocalTransform ( ) const
nodiscard

Gets the local model matrix which isn't affected by its parent.

Returns
glm local model matrix

◆ getMaterialNames()

Rendering::PipelineNames Engine::Components::Mesh::getMaterialNames ( ) const
nodiscard

Gets the material name of this mesh component.

Returns
name of the material used or defaults ot normals if none is used

◆ getMaterialOverride()

std::optional< Assets::MaterialHandle > Engine::Components::Mesh::getMaterialOverride ( ) const
nodiscard

◆ getMeshAsset()

Assets::MeshAssetRef Engine::Components::Mesh::getMeshAsset ( ) const
nodiscard

Gets the asset used by this mesh rendering component.

Returns
Pointer to the mesh asset used by this mesh renderer

◆ getSceneNode()

std::shared_ptr< Entities::SceneNode > Engine::Components::Mesh::getSceneNode ( ) const
nodiscardprotected

◆ getStaticMeshData()

Ecs::StaticMeshData * Engine::Components::Mesh::getStaticMeshData ( ) const
nodiscardprotected

◆ getWorldTransform()

glm::mat4 Engine::Components::Mesh::getWorldTransform ( ) const
nodiscard

Getter for the world transform of the mesh component.

Returns
model matrix which is affected by the scene graph hierarchy

◆ initializeMeshData()

void Engine::Components::Mesh::initializeMeshData ( Entities::Scene * owningScene,
entt::entity & actor,
Asset::MeshPath asset,
std::optional< Assets::GltfRenderableHandle > renderable,
Assets::GeometryMeshHandle mesh )
private

◆ isVisible()

bool Engine::Components::Mesh::isVisible ( ) const
nodiscard

If this mesh component should be considered for rendering.

Returns
visible = true

◆ onMeshAssetResolved()

virtual void Engine::Components::Mesh::onMeshAssetResolved ( Assets::MeshAssetRef meshAsset)
virtual

◆ ownsCollisionChild()

bool Engine::Components::Mesh::ownsCollisionChild ( const Logic * component) const
nodiscard

References Engine::Components::Logic::Logic().

Here is the call graph for this function:

◆ setMaterialOverride()

void Engine::Components::Mesh::setMaterialOverride ( Assets::MaterialHandle material)

Member Data Documentation

◆ collisionChildren_

std::vector<Collision *> Engine::Components::Mesh::collisionChildren_
private

Definition at line 193 of file MeshComponent.h.

◆ componentEntity

entt::entity Engine::Components::Mesh::componentEntity = entt::null
protected

Definition at line 178 of file MeshComponent.h.

◆ ComponentName

const char* Engine::Components::Mesh::ComponentName = "Mesh"
staticconstexpr

Definition at line 47 of file MeshComponent.h.

◆ materialOverride_

std::optional<Assets::MaterialHandle> Engine::Components::Mesh::materialOverride_
private

Definition at line 194 of file MeshComponent.h.

◆ name

std::string Engine::Components::Mesh::name = "game object"
private

Definition at line 50 of file MeshComponent.h.

◆ renderingDataManager_

Core::RenderingDataManager* Engine::Components::Mesh::renderingDataManager_ = nullptr
private

Definition at line 192 of file MeshComponent.h.

◆ sceneNode

◆ staticMeshData

Ecs::StaticMeshData* Engine::Components::Mesh::staticMeshData = nullptr
protected

Definition at line 181 of file MeshComponent.h.

◆ visible

bool Engine::Components::Mesh::visible = true
private

Definition at line 51 of file MeshComponent.h.


The documentation for this class was generated from the following file:
  • /home/magerbeton/Documents/gl3-vulkan/Engine/include/Engine/Component/MeshComponent.h