Vulkan Schnee 0.0.1
High-performance rendering engine
Loading...
Searching...
No Matches
MeshComponent.h
Go to the documentation of this file.
1#pragma once
2
4#include "Engine/Core/Asset.h"
8
9#include <string>
10#include <vector>
11
12#ifdef ENABLE_TRACY
13#include <tracy/Tracy.hpp>
14#endif
15
16namespace Engine::Assets
17{
18 class Mesh;
19} // namespace Engine::Assets
20
21namespace Engine::Entities
22{
23 class SceneNode;
24} // namespace Engine::Entities
25
26namespace Engine::Core
27{
28 class Engine;
29 class SceneNode;
30 class Mesh;
31 class RenderingDataManager;
32} // namespace EngineCore
33
34namespace Engine::Components
35{
36 class Collision;
37 class MaterialShader;
38
43 class Mesh : public Logic
44 {
45 public:
46 static constexpr const char* ComponentName = "Mesh";
47
48 private:
49 std::string name = "game object";
50 bool visible = true;
51
52 public:
57 Entities::Scene * owningScene,
58 entt::entity & actor,
59 Asset::Path asset,
60 std::shared_ptr<Entities::SceneNode> sceneNode,
61 bool isVisible_ = true,
62 const std::string & name_ = "game object"
63 );
64
69 Entities::Scene * owningScene,
70 entt::entity & actor,
71 Asset::Path asset,
72 std::shared_ptr<Entities::SceneNode> sceneNode,
73 Core::RenderingDataManager * renderingDataManager,
74 bool isVisible_ = true,
75 const std::string & name_ = "game object"
76 );
77
78 ~Mesh() override = default;
79
80 void beginPlay() override;
81 void endPlay() override;
82
87 [[nodiscard]] bool isVisible() const;
88
93 [[nodiscard]] Assets::MeshAssetRef getMeshAsset() const;
94
99 [[nodiscard]] glm::mat4 getWorldTransform() const;
104 [[nodiscard]] glm::mat4 getLocalTransform() const;
105
111
116 [[nodiscard]] std::string getAssetName() const;
117
119 void attachCollisionChildren(const std::vector<Collision *> & collisions);
120 void detachCollisionChild(const Collision * collision);
121 [[nodiscard]] const std::vector<Collision *> & getCollisionChildren() const;
122 [[nodiscard]] bool ownsCollisionChild(const Logic * component) const;
123
125
126 protected:
127 [[nodiscard]] std::shared_ptr<Entities::SceneNode> getSceneNode() const;
128 [[nodiscard]] Ecs::StaticMeshData * getStaticMeshData() const;
129
130 entt::entity componentEntity = entt::null;
131 std::optional<std::shared_ptr<Entities::SceneNode>> sceneNode;
132
134
135 private:
136 Core::RenderingDataManager * renderingDataManager_ = nullptr;
137 std::vector<Collision *> collisionChildren_;
138 };
139} // namespace EngineCore
The mesh asset stores geometry data and.
Definition MeshAsset.h:20
Base class for collision shape components.
Logic(Entities::Scene *owningScene)
std::vector< Collision * > collisionChildren_
Assets::MeshAssetRef getMeshAsset() const
Gets the asset used by this mesh rendering component.
bool ownsCollisionChild(const Logic *component) const
void beginPlay() override
Called when the component is added to the scene or the game starts.
void attachCollisionChild(Collision *collision)
std::optional< std::shared_ptr< Entities::SceneNode > > sceneNode
static constexpr const char * ComponentName
void attachCollisionChildren(const std::vector< Collision * > &collisions)
glm::mat4 getWorldTransform() const
Getter for the world transform of the mesh component.
std::string getAssetName() const
Gets the asset name of this mesh component (e.g. "rat")
~Mesh() override=default
const std::vector< Collision * > & getCollisionChildren() const
bool isVisible() const
If this mesh component should be considered for rendering.
Rendering::PipelineNames getMaterialNames() const
Gets the material name of this mesh component.
Ecs::StaticMeshData * getStaticMeshData() const
virtual void onMeshAssetResolved(Assets::MeshAssetRef meshAsset)
Ecs::StaticMeshData * staticMeshData
Core::RenderingDataManager * renderingDataManager_
glm::mat4 getLocalTransform() const
Gets the local model matrix which isn't affected by its parent.
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.
void detachCollisionChild(const Collision *collision)
void endPlay() override
Called when the component is removed or the game ends.
std::shared_ptr< Entities::SceneNode > getSceneNode() const
Represents a node in the scene graph, containing information about its position, rotation,...
Definition SceneGraph.h:18
A scene is the overarching structure which can spawn, contain and destroy actors or entities.
Definition Scene.h:56
Asset::Ref< Asset::Path, Mesh > MeshAssetRef
Core audio subsystem owning the miniaudio engine and managing playback.
Definition AudioConfig.h:9