material editing in scene metafile
[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         // merge scn into this scene, leaving scn empty and safe to destroy
40         bool merge(Scene *scn);
41
42         void add_object(Object *obj);
43         bool remove_object(Object *obj);
44         bool have_object(Object *obj) const;
45
46         void add_mesh(Mesh *m);
47         bool remove_mesh(Mesh *m);
48         bool have_mesh(Mesh *m) const;
49
50         void add_node(SceneNode *n);
51         bool remove_node(SceneNode *n);
52         bool have_node(SceneNode *n) const;
53
54         /* find and remove all nodes whose names match the regexp
55          * XXX at the moment this has the effect of flattening the hierarchy in the
56          * result scene. If we ever need verbatim extraction of whole subtrees we'll
57          * need to change the algorithm.
58          */
59         Scene *extract_nodes(const char *qstr);
60
61         /* bake all node transformations to their respective meshes and make the
62          * node transformations identity.
63          * XXX this assumes no mesh is shared by two nodes.
64          */
65         void apply_xform();
66
67         void update(float dt);
68         void draw() const;
69 };
70
71 #endif  // SCENE_H_