metadata, walk polygons, stuff...
[laserbrain_demo] / src / scene.h
1 #ifndef SCENE_H_
2 #define SCENE_H_
3
4 #include <vector>
5 #include <list>
6 #include "mesh.h"
7 #include "snode.h"
8 #include "texture.h"
9
10 enum {
11         SCNLOAD_FLIPYZ = 1,
12         SCNLOAD_FLIPTEX = 2
13 };
14
15 class Scene {
16 private:
17         bool own_texset;
18
19 public:
20         // meshes objects and nodes are owned by Scene
21         std::vector<Mesh*> meshes;
22         std::vector<Object*> objects;
23         SceneNode *nodes;
24
25         Mesh *walk_mesh;
26
27         TextureSet *texset;     // only owned by Scene if own_texset is true
28
29         explicit Scene(TextureSet *tset = 0);
30         ~Scene();
31
32         Scene(const Scene &rhs) = delete;
33         Scene &operator =(const Scene &rhs) = delete;
34
35         void destroy();
36
37         bool load(const char *fname, unsigned int flags = 0);
38
39         void add_object(Object *obj);
40         bool remove_object(Object *obj);
41         bool have_object(Object *obj) const;
42
43         void add_mesh(Mesh *m);
44         bool remove_mesh(Mesh *m);
45         bool have_mesh(Mesh *m) const;
46
47         void add_node(SceneNode *n);
48         bool remove_node(SceneNode *n);
49         bool have_node(SceneNode *n) const;
50
51         /* find and remove all nodes whose names match the regexp
52          * XXX at the moment this has the effect of flattening the hierarchy in the
53          * result scene. If we ever need verbatim extraction of whole subtrees we'll
54          * need to change the algorithm.
55          */
56         Scene *extract_nodes(const char *qstr);
57
58         /* bake all node transformations to their respective meshes and make the
59          * node transformations identity.
60          * XXX this assumes no mesh is shared by two nodes.
61          */
62         void apply_xform();
63
64         void update(float dt);
65         void draw() const;
66 };
67
68 #endif  // SCENE_H_