HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GLTF_Translator.h
Go to the documentation of this file.
1 #ifndef __GLTF_Translator_h__
2 #define __GLTF_Translator_h__
3 
4 #include "GLTFZ_API.h"
5 
6 #include "GLTF_Types.h"
7 
8 #include <GA/GA_Types.h>
9 #include <UT/UT_Array.h>
10 #include <GU/GU_DetailHandle.h>
11 #include <UT/UT_Map.h>
12 #include <UT/UT_Matrix4.h>
13 #include <UT/UT_Quaternion.h>
14 #include <UT/UT_Vector.h>
15 #include <UT/UT_VectorTypes.h>
16 
17 class GEO_PrimCamera;
18 class GLTF_ErrorManager;
19 class GLTF_Reader;
20 class GLTF_Writer;
21 class GU_Detail;
22 class GU_PrimPacked;
23 class IMG_Format;
24 class OBJ_Camera;
25 class OBJ_Light;
26 class OBJ_Node;
27 class OP_Node;
28 class SOP_Node;
29 class UT_OptionsHolder;
30 
32 {
33 public:
34  enum class ImportSpace
35  {
36  World,
37  Object
38  };
39 
40  enum class ImportLevel
41  {
42  Unknown,
43  Scene,
44  Node,
45  Mesh,
46  Primitive
47  };
48 
50  {
51  PackedPrimitive,
52  FlattenedGeometry
53  };
54 
56  {
57  bool promotePointAttribs = false;
58  bool addNameAttrib = false;
59  bool importApplicationSpecificAttribs = true;
60  };
61 
63  {
65  };
66 
68  {
71  ImportSpace myImportSpace = ImportSpace::World;
72  NodeGeometryImportMethod myNodeGeometryImportMethod =
73  NodeGeometryImportMethod::PackedPrimitive;
75 
76  bool myImportNames = true;
77  // This should be set by the user to inform the translator from what
78  // level we are importing from
80 
81  bool myImportExtras = true;
82  };
83 
84  struct Node
85  {
87 
88  bool myIsRoot;
89 
90  // You must check myIsRoot before trying to use myParent
93 
95 
98 
101 
105  };
106 
107  static void init();
108  static void uninit();
109 
110  static bool importSkeleton(GU_Detail *gdp,
111  GLTF_Reader* gltf_reader,
112  const GLTF_Index root_node,
113  UT_Map<GLTF_Index, Node>& joints,
114  GLTF_ErrorManager& errors);
115 
116  static bool importSkinnedMesh(GU_Detail *gdp,
117  GLTF_Reader *gltf_reader,
118  const GLTF_Index node_idx,
119  const ImportOptions& options,
120  GLTF_ErrorManager& errors);
121 
122  // Creates detail attributes to build a skeleton of the character's capture pose.
123  static bool createCapturePoseAttributes(GU_Detail *gdp,
124  const GLTF_Reader &gltf_reader,
125  const GLTF_Index node_idx,
126  GLTF_ErrorManager& errors);
127 
128  // Materials
129  static bool importMaterial(GU_Detail* gdp,
130  const GLTF_Reader* gltf_reader,
131  const GLTF_Index mat_idx,
132  const ImportOptions& options,
133  GLTF_ErrorManager& errors);
134 
135  static bool importMeshPrimitive(GU_Detail *prim_gdp,
136  GLTF_Reader& gltf_reader,
137  const GLTF_Index mesh_idx,
138  const GLTF_Index prim_idx,
139  const ImportOptions& options,
140  GLTF_ErrorManager& errors);
141 
142  static GU_DetailHandle importMeshPrimitive(
143  GLTF_Reader& gltf_reader,
144  const GLTF_Index mesh_idx,
145  const GLTF_Index prim_idx,
146  const ImportOptions& options,
147  GLTF_ErrorManager& errors);
148 
149 private:
150 
151  static bool addPointAttribute(GU_Detail *gdp,
152  GLTF_Reader &gltf_reader,
153  const GLTF_Index attrib_access_idx,
154  const char* attrib_name,
155  GLTF_ErrorManager& errors);
156 
157  static bool doesURIContainEmbeddedData(
158  const UT_StringHolder& uri);
159 
160  static bool addGltfDetailAttrib(GU_Detail* gdp,
161  GLTF_Reader& gltf_reader,
162  const UT_StringHolder& attrib_name,
163  const UT_StringHolder& value,
164  GLTF_ErrorManager& errors);
165 
166  static bool addGltfPrimitiveAttrib(GU_Detail* gdp,
167  GLTF_Reader& gltf_reader,
168  const UT_StringHolder& attrib_name,
169  const UT_StringHolder& value,
170  GLTF_ErrorManager& errors);
171 
172  static bool addGltfExtrasDictAttrib(GU_Detail* gdp,
173  GLTF_Reader& gltf_reader,
174  const UT_StringHolder& attrib_name,
175  const UT_OptionsHolder& dict_value,
176  GA_AttributeOwner owner,
177  GLTF_ErrorManager& errors);
178 };
179 
180 #endif // __GLTF_Translator_h__
MeshImportOptions myMeshImportOptions
UT_Vector3F myRestTranslation
Definition: Mesh.h:240
Unsorted map container.
Definition: UT_Map.h:114
UT_Matrix4F myMatrixTransform
MaterialImportOptions myMaterialImportOptions
GLsizei const GLfloat * value
Definition: glcorearb.h:824
UT_Quaternion myRestRotation
GA_Size GA_Offset
Definition: GA_Types.h:653
UT_StringHolder myPath
UT_Array< GLTF_Index > myChildren
std::size_t GLTF_Index
Definition: GLTF_Types.h:13
GA_AttributeOwner
Definition: GA_Types.h:35
UT_StringHolder myName
#define GLTFZ_API
Definition: GLTFZ_API.h:37