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 : int type() const final;
19 : bool loaddefaultparts() final;
20 :
21 : //static methods
22 : static const char *formatname();
23 :
24 : private:
25 : struct GLTFJoint final
26 : {
27 : vec pos;
28 : quat orient;
29 : };
30 :
31 : struct GLTFWeight final
32 : {
33 : int joint;
34 : float bias;
35 : vec pos;
36 : };
37 :
38 : struct GLTFVert final
39 : {
40 : vec2 tc;
41 : uint start, count;
42 : };
43 :
44 : struct GLTFHierarchy final
45 : {
46 : string name;
47 : int parent, flags, start;
48 : };
49 :
50 : class GLTFMeshGroup final : public skelmeshgroup
51 : {
52 : public:
53 : GLTFMeshGroup();
54 : //main anim loading functionality
55 0 : const skelanimspec * loadanim(const std::string &) final { return nullptr;};
56 :
57 : private:
58 : bool loadmesh(const char *filename, float smooth, part &p);
59 : bool load(std::string_view meshname, float smooth, part &p) final;
60 : };
61 :
62 :
63 : //extensions to skelmesh objects for gltf specifically
64 : class gltfmesh final : public skelmesh
65 : {
66 : public:
67 : gltfmesh(std::string_view name, vert *verts, uint numverts, tri *tris, uint numtris, meshgroup *m);
68 : ~gltfmesh();
69 : void cleanup();
70 : void buildverts(const std::vector<GLTFJoint> &joints);
71 : //gltf model loader
72 : void load(stream *f, char *buf, size_t bufsize, part &p, const std::string &modeldir);
73 : };
74 :
75 : static skelcommands<gltf> gltfcommands;
76 :
77 : skelmeshgroup *newmeshes() final;
78 : };
79 :
80 : #endif
|