Skylicht Engine
Loading...
Searching...
No Matches
CMeshManager.h
1#pragma once
2
3#include "RenderMesh/CMesh.h"
4#include "Entity/CEntityPrefab.h"
5#include "Utils/CSingleton.h"
6#include "Instancing/SMeshInstancing.h"
7
8#include "Importer/IMeshImporter.h"
9#include "Exporter/IMeshExporter.h"
10
11namespace Skylicht
12{
15
46 class SKYLICHT_API CMeshManager
47 {
48 public:
49 DECLARE_SINGLETON(CMeshManager)
50
51 protected:
52 struct SPrefabInfo
53 {
54 bool NormalMap;
55 bool FlipNormalMap;
56 bool Texcoord2;
57 bool Batching;
58
59 CEntityPrefab* Prefab;
60
61 SPrefabInfo()
62 {
63 NormalMap = true;
64 FlipNormalMap = true;
65 Texcoord2 = false;
66 Batching = false;
67 Prefab = NULL;
68 }
69 };
70
71 std::map<std::string, std::vector<SPrefabInfo*>> m_meshPrefabs;
72
73 std::vector<SMeshInstancing*> m_instancingData;
74
75 public:
76 CMeshManager();
77
78 virtual ~CMeshManager();
79
80 static std::vector<std::string> getMeshExts();
81
82 static bool isMeshExt(const char* ext);
83
84 bool isMeshLoaded(const char* resource);
85
86 CEntityPrefab* loadModel(const char* resource, const char* texturePath, bool loadNormalMap = true, bool flipNormalMap = true, bool loadTexcoord2 = false, bool createBatching = false);
87
88 CEntityPrefab* loadModel(const char* resource, const char* texturePath, IMeshImporter* importer, bool loadNormalMap = true, bool flipNormalMap = true, bool loadTexcoord2 = false, bool createBatching = false);
89
90 bool exportModel(CEntity** entities, u32 count, const char* output);
91
92 bool exportModel(CEntity** entities, u32 count, const char* output, IMeshExporter* exporter);
93
94 void releaseResource(const char* resource);
95
96 void releasePrefab(CEntityPrefab* prefab);
97
98 void releaseAllPrefabs();
99
100 void releaseAllInstancingMesh();
101
102 SMeshInstancing* createGetInstancingMesh(CMesh* mesh);
103
104 SMeshInstancing* createGetInstancingMesh(CMesh* mesh, IShaderInstancing* shaderInstancing);
105
106 void changeInstancingTransformBuffer(SMeshInstancing* mesh, IVertexBuffer* transform, IVertexBuffer* lighting);
107
108 void changeInstancingMaterialBuffer(SMeshInstancing* mesh, IVertexBuffer* materials);
109
110 protected:
111
112 bool canCreateInstancingMesh(CMesh* mesh);
113
114 bool compareMeshBuffer(CMesh* mesh, SMeshInstancing* data);
115
116 SMeshInstancing* createInstancingData(CMesh* mesh);
117
118 SMeshInstancing* createInstancingData(CMesh* mesh, IShaderInstancing* shaderInstancing);
119 };
120}
This is the object class that describes an entity.
Definition CEntity.h:58
This object class is created to store data in an array of multiple CEntities.
Definition CEntityPrefab.h:38
Definition CMesh.h:75
Definition IMeshExporter.h:32
Definition IMeshImporter.h:32
Abstract base class for GPU instancing logic in Skylicht-Engine.
Definition IShaderInstancing.h:45
Definition IVertexBuffer.h:17
#define DECLARE_SINGLETON(className)
Declare the standard singleton accessors for a class.
Definition CSingleton.h:36
Everything in the Skylicht Engine. You can start by looking at the topics.
Definition AudioDebugLog.h:29
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
Definition SMeshInstancing.h:39