1 #ifndef MSP_GL_SCENE_H_
2 #define MSP_GL_SCENE_H_
5 #include <msp/datafile/dynamicobjectloader.h>
6 #include <msp/datafile/objectloader.h>
8 #include "renderable.h"
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.
18 class Scene: public Renderable
21 class Loader: public DataFile::CollectionObjectLoader<Scene>
24 typedef std::map<std::string, Renderable *> ContentMap;
29 static unsigned inline_counter;
32 Loader(Scene &s, Collection &c): Loader(s, c, 0) { }
33 Loader(Scene &s, Collection &c, ContentMap &m) : Loader(s, c, &m) { }
35 Loader(Scene &, Collection &, ContentMap *);
37 void object(const std::string &);
38 void object_tagged(const std::string &, const std::string &);
39 void scene(const std::string &);
43 class GenericLoader: public DataFile::DynamicObjectLoader<Scene>
48 GenericLoader(DataFile::Collection &c): DynamicObjectLoader<Scene>(&c) { }
51 virtual const TypeRegistry &get_type_registry() const { return get_scene_registry(); }
55 mutable Matrix culling_matrix;
56 mutable Vector4 frustum_edges[6];
61 Scene &operator=(const Scene &);
63 virtual ~Scene() = default;
65 virtual void add(Renderable &) = 0;
66 virtual void remove(Renderable &) = 0;
69 bool setup_frustum(const Renderer &) const;
70 bool frustum_cull(const Renderable &) const;
74 static void register_type(const std::string &);
76 static GenericLoader::TypeRegistry &get_scene_registry();
80 void Scene::register_type(const std::string &kw)
82 get_scene_registry().register_type<T>(kw);