Ult3D
Implementation of "Ultimate 3D Game Engine Design & Architecture" by Allan Sherrod
Loading...
Searching...
No Matches
ModelData.h
Go to the documentation of this file.
1#ifndef ULT_MODEL_DATA_H_INCLUDED
2#define ULT_MODEL_DATA_H_INCLUDED
3
6
7#define ULT_RENDER_MODEL_DATA_PARAMS(model) model.GetPrimitiveType(), model.GetDescriptor(), \
8 model.GetVertices(), model.GetIndices(), \
9 model.GetVertexSizeInBytes(), \
10 model.GetTotalIndices(), \
11 model.GetVertexStride()
12
13#define ULT_MODEL_RESOURCE_MANAGER Ult::ResourceManager<Ult::ModelResource,Ult::Handle<Ult::ModelResourceTag>>
14
15namespace Ult
16{
17
19{
20}; // is empty in book
21
26{
27public:
31 ModelData();
35 ~ModelData();
36
40 void Clear();
41
45 void ClearDescriptor() { mDescriptor.Clear(); }
49 bool AddDescriptorElement(ElementType type) { return mDescriptor.AddElement(type); }
53 VertexDescriptor* GetDescriptor() { return &mDescriptor; }
54
58 bool SetIndices(int totalIndices, unsigned int* indices);
62 int GetTotalIndices() const { return mTotalIndices; }
66 unsigned int* GetIndices() { return mIndices; }
67
72 bool SetVertices(PrimitiveType type, int totalVertices, int stride, char* vertices);
76 int GetTotalVertices() const { return mTotalVertices; }
81 int GetVertexSizeInBytes() const { return mDescriptor.GetStride() * mTotalVertices; }
85 int GetVertexStride() const { return mDescriptor.GetStride(); }
89 char* GetVertices() { return mVertices; }
93 PrimitiveType GetPrimitiveType() const { return mPrimitiveType; }
94
95private:
96 unsigned int* mIndices;
97 int mTotalIndices;
98
99 char* mVertices;
100 int mTotalVertices;
101
102 VertexDescriptor mDescriptor;
103
104 PrimitiveType mPrimitiveType;
105};
106
108{
109public:
111 mModel(model)
112 {}
114 FreeMemory();
115 }
116
117 ModelData* GetModel() { return mModel; }
118
119private:
120 ModelData* mModel;
121
122 void FreeMemory() {
123 if (mModel) {
124 delete mModel;
125 }
126 mModel = nullptr;
127 }
128};
129
130} // namespace Ult
131
132#endif // ULT_MODEL_DATA_H_INCLUDED
133
Definition ModelData.h:26
int GetVertexStride() const
Definition ModelData.h:85
PrimitiveType GetPrimitiveType() const
Definition ModelData.h:93
int GetVertexSizeInBytes() const
Definition ModelData.h:81
~ModelData()
Definition ModelData.cpp:16
VertexDescriptor * GetDescriptor()
Definition ModelData.h:53
void Clear()
Definition ModelData.cpp:21
char * GetVertices()
Definition ModelData.h:89
int GetTotalVertices() const
Definition ModelData.h:76
ModelData()
Definition ModelData.cpp:7
bool SetIndices(int totalIndices, unsigned int *indices)
Definition ModelData.cpp:36
bool AddDescriptorElement(ElementType type)
Definition ModelData.h:49
int GetTotalIndices() const
Definition ModelData.h:62
void ClearDescriptor()
Definition ModelData.h:45
bool SetVertices(PrimitiveType type, int totalVertices, int stride, char *vertices)
Definition ModelData.cpp:53
unsigned int * GetIndices()
Definition ModelData.h:66
ModelData * GetModel()
Definition ModelData.h:117
ModelResource(ModelData *model)
Definition ModelData.h:110
~ModelResource()
Definition ModelData.h:113
Definition ModelData.h:19
Definition VertexDescriptor.h:18
PrimitiveType
Definition PrimitiveType.h:9
ElementType
Definition ElementType.h:9
Definition Archive.h:13