]> git.tdb.fi Git - libs/gl.git/blob - source/scene.h
Allow tagging objects in a scene file for retrieval after loading
[libs/gl.git] / source / scene.h
1 #ifndef MSP_GL_SCENE_H_
2 #define MSP_GL_SCENE_H_
3
4 #include <vector>
5 #include <msp/datafile/objectloader.h>
6 #include "matrix.h"
7 #include "renderable.h"
8 #include "vector.h"
9
10 namespace Msp {
11 namespace GL {
12
13 /**
14 Scenes are containers for other Renderables.  This is a base class that can't
15 be instantiated.  Examples of available Scene types are SimpleScene,
16 InstancedScene and OrderedScene.
17 */
18 class Scene: public Renderable
19 {
20 public:
21         class Loader: public DataFile::CollectionObjectLoader<Scene>
22         {
23         public:
24                 typedef std::map<std::string, Renderable *> ContentMap;
25
26         private:
27                 ContentMap *content;
28
29         public:
30                 Loader(Scene &, Collection &);
31                 Loader(Scene &, Collection &, ContentMap &);
32         private:
33                 void init();
34
35                 void object(const std::string &);
36                 void object_tagged(const std::string &, const std::string &);
37         };
38
39 protected:
40         // XXX If a loaded renderable is removed from the scene it needs to be removed from here as well
41         std::vector<Renderable *> owned_data;
42         mutable Matrix culling_matrix;
43         mutable Vector4 frustum_edges[6];
44
45         Scene() { }
46 private:
47         Scene(const Scene &);
48         Scene &operator=(const Scene &);
49 public:
50         virtual ~Scene();
51
52         virtual void add(Renderable &) = 0;
53         virtual void remove(Renderable &) = 0;
54
55 protected:
56         bool setup_frustum(const Renderer &) const;
57         bool frustum_cull(const Renderable &) const;
58 };
59
60 } // namespace GL
61 } // namespace Msp
62
63 #endif