HDK
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GLTF_Reader.h
Go to the documentation of this file.
1 #ifndef __GLTF_Reader_h__
2 #define __GLTF_Reader_h__
3 
4 #include "GLTFZ_API.h"
5 #include "GLTF_IO.h"
6 #include "GLTF_Types.h"
7 
8 #include <UT/UT_StringHolder.h>
9 #include <UT/UT_UniquePtr.h>
10 
11 class GLTF_CgltfWrapper;
12 class GLTF_ErrorManager;
13 
15 {
16 // File Reading
17 public:
18 
20  GLTF_Reader(const char *filePath);
22 
23  bool loadFile(GLTF_ErrorManager& errors);
24 
25  bool closeFile();
26 
27  bool isOpen() const;
28 
29  bool loadBuffer(const GLTF_Index buf_idx,
30  GLTF_ErrorManager& errors);
31 
32  bool loadAccessorData(const GLTF_Index accessor_idx,
33  unsigned char** out_data,
34  GLTF_ErrorManager& errors);
35 
36  bool loadBufferViewData(
37  const GLTF_Index bv_idx,
38  unsigned char** out_data,
39  GLTF_ErrorManager& errors);
40 
41  bool loadAnimationData(
42  const GLTF_Index anim_idx,
43  GLTF_ErrorManager& errors);
44 
45  void setFilePath(const char* path)
46  { myFilePath = path; }
47  const UT_StringHolder& filePath() const { return myFilePath; }
48 
49  bool isImporterExtensionSupported(
50  const UT_StringHolder& name) const;
51 
53  {
54  return myIO.getCgltfData();
55  }
56  const cgltf_data* getCgltfData() const
57  {
58  return myIO.getCgltfData();
59  }
60 
61 // Getters
62 public:
63 
65  {
66  ALL,
67  SKINNED_MESH
68  };
69 
70  bool getAnimationNames(
71  UT_StringArray& names,
72  GLTF_ErrorManager& errors);
73 
74  bool getScenes(
75  UT_StringArray& names,
77  GLTF_ErrorManager& errors);
78 
79  bool getNodes(
80  UT_StringArray& names,
82  GLTF_ErrorManager& errors,
83  NodeFilter filter=NodeFilter::ALL);
84 
85  bool getMeshes(
86  UT_StringArray& names,
88  GLTF_ErrorManager& errors);
89 
90  bool getPrimitives(
91  GLTF_Index mesh_id,
92  UT_Array<GLTF_Index>& prim_ids,
93  GLTF_ErrorManager& errors);
94 
95  bool getMaterials(
96  GLTF_Index material_id,
97  UT_StringArray& names,
98  UT_Array<GLTF_Index>& mat_ids,
99  GLTF_ErrorManager& errors) const;
100 
101  bool getRequiredExtensions(
102  UT_StringArray& ext_names) const;
103 
104  // Gets the global transform of a node
105  bool getNodeTransform(
106  const GLTF_Index node_idx,
108  GLTF_ErrorManager& errors);
109 
110 public:
111 
112  // Validity
113  bool checkAnimIsValid(
114  const GLTF_Index anim_id) const;
115 
116 private:
117 
119 
120  UT_StringHolder myFilePath;
121 };
122 
123 #endif // __GLTF_Reader_h__
GLsizei const GLchar *const * path
Definition: glcorearb.h:3341
void setFilePath(const char *path)
Definition: GLTF_Reader.h:45
const cgltf_data * getCgltfData() const
Definition: GLTF_Reader.h:56
GLuint const GLchar * name
Definition: glcorearb.h:786
GA_API const UT_StringHolder transform
const UT_StringHolder & filePath() const
Definition: GLTF_Reader.h:47
std::size_t GLTF_Index
Definition: GLTF_Types.h:13
void getAnimationNames(const cgltf_data &data, UT_StringArray &names)
cgltf_data * getCgltfData()
Definition: GLTF_Reader.h:52
#define GLTFZ_API
Definition: GLTFZ_API.h:37
GLuint * ids
Definition: glcorearb.h:652
GLint GLint GLint GLint GLint GLint GLint GLbitfield GLenum filter
Definition: glcorearb.h:1297