rev |
line source |
nuclear@54
|
1 /*
|
nuclear@54
|
2 goat3d - 3D scene, character, and animation file format library.
|
nuclear@54
|
3 Copyright (C) 2013-2014 John Tsiombikas <nuclear@member.fsf.org>
|
nuclear@54
|
4
|
nuclear@54
|
5 This program is free software: you can redistribute it and/or modify
|
nuclear@54
|
6 it under the terms of the GNU Lesser General Public License as published by
|
nuclear@54
|
7 the Free Software Foundation, either version 3 of the License, or
|
nuclear@54
|
8 (at your option) any later version.
|
nuclear@54
|
9
|
nuclear@54
|
10 This program is distributed in the hope that it will be useful,
|
nuclear@54
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
nuclear@54
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
nuclear@54
|
13 GNU Lesser General Public License for more details.
|
nuclear@54
|
14
|
nuclear@54
|
15 You should have received a copy of the GNU Lesser General Public License
|
nuclear@54
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
|
nuclear@54
|
17 */
|
nuclear@0
|
18 #ifndef GOAT3D_IMPL_H_
|
nuclear@0
|
19 #define GOAT3D_IMPL_H_
|
nuclear@0
|
20
|
nuclear@0
|
21 #include <string>
|
nuclear@1
|
22 #include <vmath/vmath.h>
|
nuclear@0
|
23 #include "goat3d.h"
|
nuclear@0
|
24 #include "mesh.h"
|
nuclear@0
|
25 #include "light.h"
|
nuclear@0
|
26 #include "camera.h"
|
nuclear@0
|
27 #include "material.h"
|
nuclear@12
|
28 #include "node.h"
|
nuclear@75
|
29 #include "aabox.h"
|
nuclear@0
|
30
|
nuclear@47
|
31 namespace g3dimpl {
|
nuclear@74
|
32 class Scene;
|
nuclear@74
|
33 }
|
nuclear@74
|
34
|
nuclear@74
|
35 struct goat3d {
|
nuclear@74
|
36 g3dimpl::Scene *scn;
|
nuclear@74
|
37 unsigned int flags;
|
nuclear@74
|
38 char *search_path;
|
nuclear@74
|
39 };
|
nuclear@74
|
40
|
nuclear@74
|
41
|
nuclear@74
|
42 namespace g3dimpl {
|
nuclear@47
|
43
|
nuclear@15
|
44 extern int goat_log_level;
|
nuclear@15
|
45
|
nuclear@19
|
46 #if __cplusplus >= 201103L
|
nuclear@19
|
47 #define MOVE(x) std::move(x)
|
nuclear@19
|
48 #else
|
nuclear@19
|
49 #define MOVE(x) x
|
nuclear@19
|
50 #endif
|
nuclear@19
|
51
|
nuclear@19
|
52 #define VECDATA(type, data, num) \
|
nuclear@19
|
53 MOVE(std::vector<type>((type*)(data), (type*)(data) + (num)))
|
nuclear@19
|
54
|
nuclear@51
|
55 std::string clean_filename(const char *str);
|
nuclear@40
|
56
|
nuclear@19
|
57
|
nuclear@0
|
58 class Scene {
|
nuclear@0
|
59 private:
|
nuclear@0
|
60 std::string name;
|
nuclear@0
|
61 Vector3 ambient;
|
nuclear@0
|
62
|
nuclear@0
|
63 std::vector<Material*> materials;
|
nuclear@0
|
64 std::vector<Mesh*> meshes;
|
nuclear@0
|
65 std::vector<Light*> lights;
|
nuclear@0
|
66 std::vector<Camera*> cameras;
|
nuclear@12
|
67 std::vector<Node*> nodes;
|
nuclear@0
|
68
|
nuclear@75
|
69 mutable AABox bbox;
|
nuclear@75
|
70 mutable bool bbox_valid;
|
nuclear@75
|
71
|
nuclear@0
|
72 public:
|
nuclear@74
|
73 goat3d *goat;
|
nuclear@74
|
74
|
nuclear@0
|
75 Scene();
|
nuclear@0
|
76 ~Scene();
|
nuclear@0
|
77
|
nuclear@0
|
78 void clear();
|
nuclear@0
|
79
|
nuclear@0
|
80 void set_name(const char *name);
|
nuclear@0
|
81 const char *get_name() const;
|
nuclear@0
|
82
|
nuclear@0
|
83 void set_ambient(const Vector3 &amb);
|
nuclear@0
|
84 const Vector3 &get_ambient() const;
|
nuclear@0
|
85
|
nuclear@0
|
86 void add_material(Material *mat);
|
nuclear@0
|
87 Material *get_material(int idx) const;
|
nuclear@0
|
88 Material *get_material(const char *name) const;
|
nuclear@9
|
89 int get_material_count() const;
|
nuclear@0
|
90
|
nuclear@0
|
91 void add_mesh(Mesh *mesh);
|
nuclear@0
|
92 Mesh *get_mesh(int idx) const;
|
nuclear@0
|
93 Mesh *get_mesh(const char *name) const;
|
nuclear@9
|
94 int get_mesh_count() const;
|
nuclear@0
|
95
|
nuclear@0
|
96 void add_light(Light *light);
|
nuclear@0
|
97 Light *get_light(int idx) const;
|
nuclear@0
|
98 Light *get_light(const char *name) const;
|
nuclear@9
|
99 int get_light_count() const;
|
nuclear@0
|
100
|
nuclear@0
|
101 void add_camera(Camera *cam);
|
nuclear@0
|
102 Camera *get_camera(int idx) const;
|
nuclear@0
|
103 Camera *get_camera(const char *name) const;
|
nuclear@9
|
104 int get_camera_count() const;
|
nuclear@0
|
105
|
nuclear@0
|
106 void add_node(Node *node);
|
nuclear@0
|
107 Node *get_node(int idx) const;
|
nuclear@0
|
108 Node *get_node(const char *name) const;
|
nuclear@9
|
109 int get_node_count() const;
|
nuclear@0
|
110
|
nuclear@75
|
111 const AABox &get_bounds() const;
|
nuclear@75
|
112
|
nuclear@0
|
113 bool load(goat3d_io *io);
|
nuclear@0
|
114 bool save(goat3d_io *io) const;
|
nuclear@14
|
115
|
nuclear@14
|
116 bool loadxml(goat3d_io *io);
|
nuclear@14
|
117 bool savexml(goat3d_io *io) const;
|
nuclear@47
|
118
|
nuclear@47
|
119 bool load_anim(goat3d_io *io);
|
nuclear@55
|
120 bool save_anim(goat3d_io *io) const;
|
nuclear@47
|
121
|
nuclear@47
|
122 bool load_anim_xml(goat3d_io *io);
|
nuclear@55
|
123 bool save_anim_xml(goat3d_io *io) const;
|
nuclear@0
|
124 };
|
nuclear@0
|
125
|
nuclear@14
|
126 void io_fprintf(goat3d_io *io, const char *fmt, ...);
|
nuclear@14
|
127 void io_vfprintf(goat3d_io *io, const char *fmt, va_list ap);
|
nuclear@0
|
128
|
nuclear@47
|
129 } // namespace g3dimpl
|
nuclear@47
|
130
|
nuclear@0
|
131 #endif // GOAT3D_IMPL_H_
|