goat3d

view src/goat3d_impl.h @ 54:dad392c710df

added copyright headers and license files + readme
author John Tsiombikas <nuclear@member.fsf.org>
date Thu, 17 Apr 2014 08:50:36 +0300
parents fa5c52ea9d59
children 99715321ad6d
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 {
32 extern int goat_log_level;
34 #if __cplusplus >= 201103L
35 #define MOVE(x) std::move(x)
36 #else
37 #define MOVE(x) x
38 #endif
40 #define VECDATA(type, data, num) \
41 MOVE(std::vector<type>((type*)(data), (type*)(data) + (num)))
43 std::string clean_filename(const char *str);
46 class Scene {
47 private:
48 std::string name;
49 Vector3 ambient;
51 std::vector<Material*> materials;
52 std::vector<Mesh*> meshes;
53 std::vector<Light*> lights;
54 std::vector<Camera*> cameras;
55 std::vector<Node*> nodes;
57 public:
58 Scene();
59 ~Scene();
61 void clear();
63 void set_name(const char *name);
64 const char *get_name() const;
66 void set_ambient(const Vector3 &amb);
67 const Vector3 &get_ambient() const;
69 void add_material(Material *mat);
70 Material *get_material(int idx) const;
71 Material *get_material(const char *name) const;
72 int get_material_count() const;
74 void add_mesh(Mesh *mesh);
75 Mesh *get_mesh(int idx) const;
76 Mesh *get_mesh(const char *name) const;
77 int get_mesh_count() const;
79 void add_light(Light *light);
80 Light *get_light(int idx) const;
81 Light *get_light(const char *name) const;
82 int get_light_count() const;
84 void add_camera(Camera *cam);
85 Camera *get_camera(int idx) const;
86 Camera *get_camera(const char *name) const;
87 int get_camera_count() const;
89 void add_node(Node *node);
90 Node *get_node(int idx) const;
91 Node *get_node(const char *name) const;
92 int get_node_count() const;
94 bool load(goat3d_io *io);
95 bool save(goat3d_io *io) const;
97 bool loadxml(goat3d_io *io);
98 bool savexml(goat3d_io *io) const;
100 bool load_anim(goat3d_io *io);
101 bool save_anim(const XFormNode *node, goat3d_io *io) const;
103 bool load_anim_xml(goat3d_io *io);
104 bool save_anim_xml(const XFormNode *node, goat3d_io *io) const;
105 };
107 void io_fprintf(goat3d_io *io, const char *fmt, ...);
108 void io_vfprintf(goat3d_io *io, const char *fmt, va_list ap);
110 } // namespace g3dimpl
112 #endif // GOAT3D_IMPL_H_