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::Path 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, Asset::Path 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 () 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 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.
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)
virtual ~Logic ()=default
virtual std::string getComponentName () const
 Gets the component type name for debugging/UI.
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 Attributes

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

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 43 of file MeshComponent.h.

Constructor & Destructor Documentation

◆ Mesh() [1/2]

Engine::Components::Mesh::Mesh ( Entities::Scene * owningScene,
entt::entity & actor,
Asset::Path 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/2]

Engine::Components::Mesh::Mesh ( Entities::Scene * owningScene,
entt::entity & actor,
Asset::Path 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()

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.

◆ detachCollisionChild()

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

◆ 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

◆ 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

◆ 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:

Member Data Documentation

◆ collisionChildren_

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

Definition at line 137 of file MeshComponent.h.

◆ componentEntity

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

Definition at line 130 of file MeshComponent.h.

◆ ComponentName

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

Definition at line 46 of file MeshComponent.h.

◆ name

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

Definition at line 49 of file MeshComponent.h.

◆ renderingDataManager_

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

Definition at line 136 of file MeshComponent.h.

◆ sceneNode

std::optional<std::shared_ptr<Entities::SceneNode> > Engine::Components::Mesh::sceneNode
protected

◆ staticMeshData

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

Definition at line 133 of file MeshComponent.h.

◆ visible

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

Definition at line 50 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