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;
28 unsigned inst_counter;
31 Loader(Scene &s, Collection &c): Loader(s, c, 0) { }
32 Loader(Scene &s, Collection &c, ContentMap &m) : Loader(s, c, &m) { }
34 Loader(Scene &, Collection &, ContentMap *);
36 void object(const std::string &);
37 void object_tagged(const std::string &, const std::string &);
38 void scene(const std::string &);
42 class GenericLoader: public DataFile::DynamicObjectLoader<Scene>
47 GenericLoader(DataFile::Collection &c): DynamicObjectLoader<Scene>(&c) { }
50 virtual const TypeRegistry &get_type_registry() const { return get_scene_registry(); }
54 mutable Matrix culling_matrix;
55 mutable Vector4 frustum_edges[6];
60 Scene &operator=(const Scene &);
62 virtual ~Scene() = default;
64 virtual void add(Renderable &) = 0;
65 virtual void remove(Renderable &) = 0;
68 bool setup_frustum(const Renderer &) const;
69 bool frustum_cull(const Renderable &) const;
73 static void register_type(const std::string &);
75 static GenericLoader::TypeRegistry &get_scene_registry();
79 void Scene::register_type(const std::string &kw)
81 get_scene_registry().register_type<T>(kw);