HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GLTF_Types.h
Go to the documentation of this file.
1 #ifndef __GLTF_Types_h__
2 #define __GLTF_Types_h__
3 
4 #include "GLTFZ_API.h"
5 
6 #include <cstddef>
7 
8 #include <SYS/SYS_Hash.h>
9 #include <UT/UT_Options.h>
10 #include <UT/UT_StringHolder.h>
11 #include <UT/UT_Vector3.h>
12 
13 typedef std::size_t GLTF_Index;
14 
16 {
17  Invalid,
18  Position,
19  Normal,
20  Tangent,
21  TexCoord,
22  Color,
23  Joints,
24  Weights,
25  Custom
26 };
27 
28 enum class GLTF_DataType
29 {
30  Invalid,
31  Scalar,
32  Vec2,
33  Vec3,
34  Vec4,
35  Mat2,
36  Mat3,
37  Mat4
38 };
39 
41 {
42  INVALID,
43  INT8,
44  UINT8,
45  INT16,
46  UINT16,
47  UINT32,
48  FLOAT32
49 };
50 
52 {
53  Invalid,
54  Triangles,
55  PolyLines,
56  Points
57 };
58 
60 {
61  Embedded,
63 };
64 
66 {
69  PNG,
70  JPEG
71 };
72 
74 {
77 };
78 
79 enum class GLTF_TextureType
80 {
83  Normal,
84  Occlusion,
87  Emissive
88 };
89 
91 {
92  Clockwise,
94 };
95 
97 {
99 };
100 
102 {
104 };
105 
106 // GLTFZ prefix to avoid conflicting with deprecated GLTF_LightType defined in
107 // the old API ($GLTF).
108 enum class GLTFZ_LightType
109 {
110  DIRECTIONAL,
111  POINT,
112  SPOT
113 };
114 
116 {
117  GLTF_AnimClip() = default;
119  GLTF_Index in_id,
120  const UT_StringHolder& in_name,
121  fpreal in_startTime,
122  fpreal in_endTime)
123  : id(in_id)
124  , name(in_name)
125  , startTime(in_startTime)
126  , endTime(in_endTime)
127  { }
128 
133 };
134 
136 {
137  float offset[2];
138  float rotation;
139  float scale[2];
140 
142  {
143  offset[0]=0.0f;
144  offset[1]=0.0f;
145  rotation=0.0f;
146  scale[0]=1.0f;
147  scale[1]=1.0f;
148  }
149 
150  GLTF_TextureTransform(const float (&_offset)[2], const float _rotation,
151  const float (&_scale)[2])
152  {
153  offset[0] = _offset[0];
154  offset[1] = _offset[1];
155  rotation = _rotation;
156  scale[0] = _scale[0];
157  scale[1] = _scale[1];
158  }
159 
161  {
162  offset[0] = o.offset[0];
163  offset[1] = o.offset[1];
164  rotation = o.rotation;
165  scale[0] = o.scale[0];
166  scale[1] = o.scale[1];
167  }
168 
170  {
171  offset[0] = o.offset[0];
172  offset[1] = o.offset[1];
173  rotation = o.rotation;
174  scale[0] = o.scale[0];
175  scale[1] = o.scale[1];
176  return *this;
177  }
178 
179  bool operator==(const GLTF_TextureTransform& other) const
180  {
181  return (
182  offset[0] == other.offset[0] &&
183  offset[1] == other.offset[1] &&
184  rotation == other.rotation &&
185  scale[0] == other.scale[0] &&
186  scale[1] == other.scale[1]);
187  }
188 
189  bool operator!=(const GLTF_TextureTransform& other) const
190  {
191  return !(*this == other);
192  }
193 };
194 
196 {
204 
207 
208  bool dracoAttribute = false;
211 
212  bool operator==(const GLTF_AttributeInfo& other) const
213  {
214  return (name == other.name &&
215  meshId == other.meshId &&
216  primitiveId == other.primitiveId &&
217  attributeCount == other.attributeCount &&
218  componentSize == other.componentSize &&
219  attributeType == other.attributeType &&
220  dataType == other.dataType &&
221  positionMin == other.positionMin &&
222  positionMax == other.positionMax &&
223  dracoAttribute == other.dracoAttribute &&
225  }
226 
227  void init(
228  const UT_StringHolder& _name,
229  GLTF_Index mesh_id,
230  GLTF_Index prim_id,
231  GLTF_Index attr_count,
232  GLTF_AttributeType attr_type,
233  GLTF_DataType data_type,
234  int component_size)
235  {
236  name = _name;
237  meshId = mesh_id;
238  primitiveId = prim_id;
239  attributeCount = attr_count;
240  componentSize = component_size;
241  attributeType = attr_type;
242  dataType = data_type;
243  }
244 
246  const UT_StringHolder& _name,
247  GLTF_Index mesh_id,
248  GLTF_Index prim_id,
249  GLTF_Index attr_count,
250  GLTF_AttributeType attr_type)
251  {
252  name = _name;
253  meshId = mesh_id;
254  primitiveId = prim_id;
255  attributeCount = attr_count;
256  componentSize = 2;
257  attributeType = attr_type;
259  }
260 
262  const UT_StringHolder& _name,
263  GLTF_Index mesh_id,
264  GLTF_Index prim_id,
265  GLTF_Index attr_count,
266  GLTF_AttributeType attr_type)
267  {
268  name = _name;
269  meshId = mesh_id;
270  primitiveId = prim_id;
271  attributeCount = attr_count;
272  componentSize = 3;
273  attributeType = attr_type;
275  }
276 
278  const UT_StringHolder& _name,
279  GLTF_Index mesh_id,
280  GLTF_Index prim_id,
281  GLTF_Index attr_count,
282  GLTF_AttributeType attr_type)
283  {
284  name = _name,
285  meshId = mesh_id;
286  primitiveId = prim_id;
287  attributeCount = attr_count;
288  componentSize = 4;
289  attributeType = attr_type;
291  }
292 
293  friend std::size_t hash_value(const GLTF_AttributeInfo& info);
294 };
295 
296 inline std::size_t
298 {
299  auto hash = SYShash(info.name);
300  SYShashCombine(hash, info.meshId);
301  SYShashCombine(hash, info.primitiveId);
302 
303  return hash;
304 }
305 
306 #endif // __GLTF_Types_h__
GLTF_Index attributeCount
Definition: GLTF_Types.h:200
void initAsVec3(const UT_StringHolder &_name, GLTF_Index mesh_id, GLTF_Index prim_id, GLTF_Index attr_count, GLTF_AttributeType attr_type)
Definition: GLTF_Types.h:261
GLTF_Index dracoAttributeId
Definition: GLTF_Types.h:209
GLTF_Index primitiveId
Definition: GLTF_Types.h:199
GLTF_TextureTransform & operator=(const GLTF_TextureTransform &o)
Definition: GLTF_Types.h:169
void initAsVec2(const UT_StringHolder &_name, GLTF_Index mesh_id, GLTF_Index prim_id, GLTF_Index attr_count, GLTF_AttributeType attr_type)
Definition: GLTF_Types.h:245
bool operator!=(const GLTF_TextureTransform &other) const
Definition: GLTF_Types.h:189
UT_Vector3F positionMax
Definition: GLTF_Types.h:206
constexpr size_t SYShash(const SYS_Flicks f)
Definition: SYS_Flicks.h:46
GLTF_CameraProjection
Definition: GLTF_Types.h:73
GLTF_AttributeType
Definition: GLTF_Types.h:15
UT_StringHolder name
Definition: GLTF_Types.h:130
GLTF_DataType
Definition: GLTF_Types.h:28
GLTF_ResourceExportLocation
Definition: GLTF_Types.h:59
bool operator==(const GLTF_TextureTransform &other) const
Definition: GLTF_Types.h:179
GLTF_TextureType
Definition: GLTF_Types.h:79
friend std::size_t hash_value(const GLTF_AttributeInfo &info)
Definition: GLTF_Types.h:297
UT_StringHolder name
Definition: GLTF_Types.h:197
GLTF_ComponentType dracoAttributeDataType
Definition: GLTF_Types.h:210
GLTF_WindingOrder windingOrder
Definition: GLTF_Types.h:98
GLTF_ComponentType
Definition: GLTF_Types.h:40
GLTF_TextureTransform(const float(&_offset)[2], const float _rotation, const float(&_scale)[2])
Definition: GLTF_Types.h:150
GLTF_Index meshId
Definition: GLTF_Types.h:198
void initAsVec4(const UT_StringHolder &_name, GLTF_Index mesh_id, GLTF_Index prim_id, GLTF_Index attr_count, GLTF_AttributeType attr_type)
Definition: GLTF_Types.h:277
fpreal endTime
Definition: GLTF_Types.h:132
GLintptr offset
Definition: glcorearb.h:665
std::size_t hash_value(const GLTF_AttributeInfo &info)
Definition: GLTF_Types.h:297
GLTF_TextureTransform(const GLTF_TextureTransform &o)
Definition: GLTF_Types.h:160
bool operator==(const GLTF_AttributeInfo &other) const
Definition: GLTF_Types.h:212
GLuint id
Definition: glcorearb.h:655
GLuint const GLchar * name
Definition: glcorearb.h:786
std::size_t GLTF_Index
Definition: GLTF_Types.h:13
void init(const UT_StringHolder &_name, GLTF_Index mesh_id, GLTF_Index prim_id, GLTF_Index attr_count, GLTF_AttributeType attr_type, GLTF_DataType data_type, int component_size)
Definition: GLTF_Types.h:227
A map of string to various well defined value types.
Definition: UT_Options.h:87
GLTF_ImageExportFormat
Definition: GLTF_Types.h:65
fpreal64 fpreal
Definition: SYS_Types.h:283
GLTF_Index id
Definition: GLTF_Types.h:129
GLTF_AnimClip()=default
GLTF_AttributeType attributeType
Definition: GLTF_Types.h:202
GLTF_PrimitiveType
Definition: GLTF_Types.h:51
UT_Options materialOverrides
Definition: GLTF_Types.h:103
GLTFZ_LightType
Definition: GLTF_Types.h:108
GLTF_DataType dataType
Definition: GLTF_Types.h:203
GLTF_Index componentSize
Definition: GLTF_Types.h:201
GLTF_WindingOrder
Definition: GLTF_Types.h:90
fpreal startTime
Definition: GLTF_Types.h:131
UT_Vector3F positionMin
Definition: GLTF_Types.h:205
GLTF_AnimClip(GLTF_Index in_id, const UT_StringHolder &in_name, fpreal in_startTime, fpreal in_endTime)
Definition: GLTF_Types.h:118