-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGFGHeader.h
163 lines (137 loc) · 4.13 KB
/
GFGHeader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
/**
GFGTransform Strcuture
GFGTransformList Structure
GFGNode Strcuture
GFGHierarchy Structure
GFGMeshJumpList Structure
GFGAnimationJumpList Structure
GFGMaterialHeader Structure
GFGSkeletonJumpList Structure
GFGMeshMatPair Structure
GFGMeshSkelPair Structure
GFGMeshSkelPairList Structure
GFGHeader Class
GFGHeader class hold the variable sized GFGHeader "serializes" data for file write
Various enumerations used by the GFGHeader.
For License refer to:
https://github.com/yalcinerbora/GFGFileFormat/blob/master/LICENSE
*/
#ifndef __GFG_HEADER_H__
#define __GFG_HEADER_H__
#include "GFGEnumerations.h"
#include "GFGMeshHeader.h"
#include "GFGMaterialHeader.h"
#include "GFGSkeletonHeader.h"
#include "GFGAnimationHeader.h"
// FourCC Code
static const uint32_t GFGFourCC = ' ' << 24 |
'G' << 16 |
'F' << 8 |
'G' << 0;
struct GFGTransform
{
// World(Model) Transform definiton
// Pivot point is (0, 0, 0) of the local space
// Euler Ordering X, Y, Z,
// Transform order Scale then rotate then translate
float translate[3]; // Translation
float rotate[3]; // Rotation (eul) (x, y, z axis)
float scale[3]; // Scale
};
struct GFGTransformList
{
uint32_t transformAmount;
std::vector<GFGTransform> transforms;
};
struct GFGNode
{
uint32_t parentIndex; // This index is for this array
uint32_t transformIndex; // Transform Data
uint32_t meshReference; // Index of the mesh mat
};
struct GFGHierarchy
{
uint32_t nodeAmount;
std::vector<GFGNode> nodes;
};
struct GFGMeshJumpList
{
uint32_t nodeAmount;
std::vector<uint64_t> meshLocations;
};
struct GFGAnimationJumpList
{
uint32_t nodeAmount;
std::vector<uint64_t> animationLocations;
};
struct GFGMaterialJumpList
{
uint32_t nodeAmount;
std::vector<uint64_t> materialLocations;
};
struct GFGSkeletonJumpList
{
uint32_t nodeAmount;
std::vector<uint64_t> skeletonLocations;
};
// Mesh Material Connections
// Multiple Mesh - Multiple Mat
struct GFGMeshMatPair
{
uint32_t meshIndex;
uint32_t materialIndex;
uint64_t indexOffset; // Sub portion of the mesh which will be rendered with this mat
uint64_t indexCount; // Index Count
// If mesh is not indexed these shows vertex offsets
// and vertex counts
};
struct GFGMeshMatPairList
{
uint32_t meshMatCount;
std::vector<GFGMeshMatPair> pairs;
};
// Mesh Skeleton Connections
// Multi Mesh - Multi Skeleton
struct GFGMeshSkelPair
{
uint32_t meshIndex;
uint32_t skeletonIndex;
};
struct GFGMeshSkeletonPairList
{
uint32_t meshSkelCount;
std::vector<GFGMeshSkelPair> connections;
};
// Header Block
// Variable
class GFGHeader
{
private:
protected:
public:
// This also shows order of the header
uint32_t fourCC = GFGFourCC; // From MSB to LSB " GFG"
uint64_t headerSize; // (in bytes) Header Size also show the data start location
uint64_t transformJump; // Direct Jump to transform headers (convenience)
GFGMeshJumpList meshList; // Fast Jumping to the headers (since headers are variable sized)
GFGMaterialJumpList materialList; // Fast Jumping to the headers (since headers are variable sized)
GFGSkeletonJumpList skeletonList; // Fast Jumping to the headers (since headers are variable sized)
GFGAnimationJumpList animationList; // Future Compat always zero atm
GFGHierarchy sceneHierarchy; // Scene Hierarchy
// Data Connections
GFGMeshMatPairList meshMaterialConnections;
GFGMeshSkeletonPairList meshSkeletonConnections;
// Data References
std::vector<GFGMeshHeader> meshes;
std::vector<GFGMaterialHeader> materials;
std::vector<GFGSkeletonHeader> skeletons;
std::vector<GFGAnimationHeader> animations;
// Transform
GFGTransformList transformData;
GFGTransformList bonetransformData; // This should be "bind pose"
// Utility
void CalculateDataOffsets(const std::vector<size_t>& meshVerticesByteSizeList,
const std::vector<size_t>& meshIndicesByteSizeList);
void Clear();
};
#endif //__GFG_HEADER_H__