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_Quaternion.h>
13 #include <UT/UT_Vector.h>
14 #include <UT/UT_VectorTypes.h>
15 
16 class GLTF_ErrorManager;
17 class GLTF_Reader;
18 class GU_Detail;
19 class OP_Node;
20 
22 {
23 public:
25  {
26  bool promotePointAttribs = true;
27  };
28 
30  {
32  };
33 
35  {
38  };
39 
41  {
42  ALL,
43  SKINNED_MESH
44  };
45 
46  struct Joint
47  {
48  bool myIsRoot;
51 
53 
56 
60  };
61 
62  static bool importSkeleton(GU_Detail *gdp,
63  GLTF_Reader* gltf_reader,
64  const GLTF_Index root_node,
66  GLTF_ErrorManager& errors);
67 
68  static bool importMesh(GU_Detail *gdp,
69  GLTF_Reader *gltf_reader,
70  const GLTF_Index mesh_idx,
71  const ImportOptions& options,
72  GLTF_ErrorManager& errors);
73 
74  static bool importSkinnedMesh(GU_Detail *gdp,
75  GLTF_Reader *gltf_reader,
76  const GLTF_Index node_idx,
77  const ImportOptions& options,
78  GLTF_ErrorManager& errors);
79 
80  static bool getAnimationNames(
81  const GLTF_Reader& gltf_reader,
82  UT_StringArray& names,
83  GLTF_ErrorManager& errors);
84 
85  static bool getNodes(const GLTF_Reader& gltf_reader,
86  UT_StringArray& names,
88  GLTF_ErrorManager& errors,
90 
91  // Creates detail attributes to build a skeleton of the character's capture pose.
92  static bool createCapturePoseAttributes(GU_Detail *gdp,
93  const GLTF_Reader &gltf_reader,
94  const GLTF_Index node_idx,
95  GLTF_ErrorManager& errors);
96 
97  // Finds the index of the cgltf_node object with the given name.
98  static bool getNodeIndexFromName(const GLTF_Reader *gltf_reader,
99  const char *node_name,
100  GLTF_Index &node_idx,
101  GLTF_ErrorManager& errors);
102 
103  // Finds the index of the cgltf_mesh object with the given name.
104  static bool getMeshIndexFromName(const GLTF_Reader *gltf_reader,
105  const char *mesh_name,
106  GLTF_Index &mesh_idx,
107  GLTF_ErrorManager& errors);
108 
109  // Gets the global transform of a node
110  static bool getNodeTransform(
111  const GLTF_Reader& gltf_reader,
112  const GLTF_Index node_idx,
114  GLTF_ErrorManager& errors);
115 
116  // Materials
117  static bool importMaterial(GU_Detail* gdp,
118  const GLTF_Reader* gltf_reader,
119  const GLTF_Index mat_idx,
120  const ImportOptions& options,
121  GLTF_ErrorManager& errors);
122 
123  static bool addGltfDetailAttrib(GU_Detail* gdp,
124  GLTF_Reader& gltf_reader,
125  const UT_StringHolder& attrib_name,
126  const UT_StringHolder& value,
127  GLTF_ErrorManager& errors);
128 
129 private:
130  static GU_DetailHandle importMeshPrimitive(
131  GLTF_Reader& gltf_reader,
132  const GLTF_Index mesh_idx,
133  const GLTF_Index prim_idx,
134  const ImportOptions& options,
135  GLTF_ErrorManager& errors);
136 
137  static bool addPointAttribute(GU_Detail *gdp,
138  GLTF_Reader &gltf_reader,
139  const GLTF_Index attrib_access_idx,
140  const char* attrib_name,
141  GLTF_ErrorManager& errors);
142 
143  static bool doesURIContainEmbeddedData(
144  const UT_StringHolder& uri);
145 };
146 
147 #endif // __GLTF_Translator_h__
MeshImportOptions myMeshImportOptions
Unsorted map container.
Definition: UT_Map.h:109
MaterialImportOptions myMaterialImportOptions
UT_StringHolder myName
GLsizei const GLfloat * value
Definition: glcorearb.h:824
UT_Array< GLTF_Index > myChildren
GA_Size GA_Offset
Definition: GA_Types.h:646
UT_Quaternion myRestRotation
GA_API const UT_StringHolder transform
std::size_t GLTF_Index
Definition: GLTF_Types.h:6
UT_StringHolder myPath
#define GLTFZ_API
Definition: GLTFZ_API.h:37
GLuint * ids
Definition: glcorearb.h:652
UT_Vector3D myRestTranslation
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297