Line data Source code
1 : #ifndef GLTF_H_
2 : #define GLTF_H_
3 :
4 : class gltf final : public skelloader<gltf>
5 : {
6 : public:
7 : //ordinary methods
8 : gltf(std::string name);
9 :
10 : //method overrides
11 :
12 : /**
13 : * @brief Returns that this model type does not have a flipped y coord (false)
14 : *
15 : * @return false
16 : */
17 : bool flipy() const final;
18 :
19 : /**
20 : * @brief Returns that this model is an MDL_GLTF
21 : *
22 : * Returns the enum entry MDL_GLTF from the enum in model.h
23 : *
24 : * @return enum value MDL_GLTF
25 : */
26 : int type() const final;
27 : bool loaddefaultparts() final;
28 :
29 : //static methods
30 :
31 : /**
32 : * @brief Returns name of this model format, "gltf".
33 : *
34 : * @return string array containing "gltf".
35 : */
36 : static const char *formatname();
37 :
38 : private:
39 : struct GLTFJoint final
40 : {
41 : vec pos;
42 : quat orient;
43 : };
44 :
45 : struct GLTFWeight final
46 : {
47 : int joint;
48 : float bias;
49 : vec pos;
50 : };
51 :
52 : struct GLTFVert final
53 : {
54 : vec2 tc;
55 : uint start, count;
56 : };
57 :
58 : struct GLTFHierarchy final
59 : {
60 : string name;
61 : int parent, flags, start;
62 : };
63 :
64 : class GLTFMeshGroup final : public skelmeshgroup
65 : {
66 : public:
67 : GLTFMeshGroup();
68 : //main anim loading functionality
69 0 : const skelanimspec * loadanim(const std::string &) final
70 : {
71 0 : return nullptr;
72 : };
73 :
74 : private:
75 : bool loadmesh(const char *filename, float smooth, part &p);
76 : bool load(std::string_view meshname, float smooth, part &p) final;
77 : };
78 :
79 :
80 : //extensions to skelmesh objects for gltf specifically
81 : class gltfmesh final : public skelmesh
82 : {
83 : public:
84 : gltfmesh(std::string_view name, vert *verts, uint numverts, tri *tris, uint numtris, meshgroup *m);
85 : ~gltfmesh();
86 : void cleanup();
87 : void buildverts(const std::vector<GLTFJoint> &joints);
88 : //gltf model loader
89 : void load(stream *f, char *buf, size_t bufsize, part &p, const std::string &modeldir);
90 : };
91 :
92 : static skelcommands<gltf> gltfcommands;
93 :
94 : skelmeshgroup *newmeshes() final;
95 : };
96 :
97 : #endif
|