goat3d

view src/goat3d_impl.h @ 74:ab66cdabf6f2

loading scene files (no vis yet)
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 06 May 2014 13:26:52 +0300
parents 99715321ad6d
children 76dea247f75c
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"
30 namespace g3dimpl {
31 class Scene;
32 }
34 struct goat3d {
35 g3dimpl::Scene *scn;
36 unsigned int flags;
37 char *search_path;
38 };
41 namespace g3dimpl {
43 extern int goat_log_level;
45 #if __cplusplus >= 201103L
46 #define MOVE(x) std::move(x)
47 #else
48 #define MOVE(x) x
49 #endif
51 #define VECDATA(type, data, num) \
52 MOVE(std::vector<type>((type*)(data), (type*)(data) + (num)))
54 std::string clean_filename(const char *str);
57 class Scene {
58 private:
59 std::string name;
60 Vector3 ambient;
62 std::vector<Material*> materials;
63 std::vector<Mesh*> meshes;
64 std::vector<Light*> lights;
65 std::vector<Camera*> cameras;
66 std::vector<Node*> nodes;
68 public:
69 goat3d *goat;
71 Scene();
72 ~Scene();
74 void clear();
76 void set_name(const char *name);
77 const char *get_name() const;
79 void set_ambient(const Vector3 &amb);
80 const Vector3 &get_ambient() const;
82 void add_material(Material *mat);
83 Material *get_material(int idx) const;
84 Material *get_material(const char *name) const;
85 int get_material_count() const;
87 void add_mesh(Mesh *mesh);
88 Mesh *get_mesh(int idx) const;
89 Mesh *get_mesh(const char *name) const;
90 int get_mesh_count() const;
92 void add_light(Light *light);
93 Light *get_light(int idx) const;
94 Light *get_light(const char *name) const;
95 int get_light_count() const;
97 void add_camera(Camera *cam);
98 Camera *get_camera(int idx) const;
99 Camera *get_camera(const char *name) const;
100 int get_camera_count() const;
102 void add_node(Node *node);
103 Node *get_node(int idx) const;
104 Node *get_node(const char *name) const;
105 int get_node_count() const;
107 bool load(goat3d_io *io);
108 bool save(goat3d_io *io) const;
110 bool loadxml(goat3d_io *io);
111 bool savexml(goat3d_io *io) const;
113 bool load_anim(goat3d_io *io);
114 bool save_anim(goat3d_io *io) const;
116 bool load_anim_xml(goat3d_io *io);
117 bool save_anim_xml(goat3d_io *io) const;
118 };
120 void io_fprintf(goat3d_io *io, const char *fmt, ...);
121 void io_vfprintf(goat3d_io *io, const char *fmt, va_list ap);
123 } // namespace g3dimpl
125 #endif // GOAT3D_IMPL_H_