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