-/* $Id$
-
-This file is part of libmspgl
-Copyright © 2007 Mikko Rasa, Mikkosoft Productions
-Distributed under the LGPL
-*/
-
#ifndef MSP_GL_SCENE_H_
#define MSP_GL_SCENE_H_
-#include <set>
+#include <vector>
+#include <msp/datafile/objectloader.h>
+#include "matrix.h"
#include "renderable.h"
+#include "vector.h"
namespace Msp {
namespace GL {
+/**
+Scenes are containers for other Renderables. This is a base class that can't
+be instantiated. Examples of available Scene types are SimpleScene,
+InstancedScene and OrderedScene.
+*/
class Scene: public Renderable
{
+public:
+ class Loader: public DataFile::CollectionObjectLoader<Scene>
+ {
+ public:
+ typedef std::map<std::string, Renderable *> ContentMap;
+
+ private:
+ ContentMap *content;
+
+ public:
+ Loader(Scene &, Collection &);
+ Loader(Scene &, Collection &, ContentMap &);
+ private:
+ void init();
+
+ void object(const std::string &);
+ void object_tagged(const std::string &, const std::string &);
+ };
+
+protected:
+ // XXX If a loaded renderable is removed from the scene it needs to be removed from here as well
+ std::vector<Renderable *> owned_data;
+ mutable Matrix culling_matrix;
+ mutable Vector4 frustum_edges[6];
+
+ Scene() { }
private:
- std::set<const Renderable *> renderables;
-
+ Scene(const Scene &);
+ Scene &operator=(const Scene &);
public:
- void add(const Renderable &);
- void remove(const Renderable &);
+ virtual ~Scene();
+
+ virtual void add(Renderable &) = 0;
+ virtual void remove(Renderable &) = 0;
- virtual bool has_pass(const Tag &) const { return true; }
- virtual void render(const Tag &tag=Tag()) const;
+protected:
+ bool setup_frustum(const Renderer &) const;
+ bool frustum_cull(const Renderable &) const;
};
} // namespace GL