]> git.tdb.fi Git - libs/gl.git/blobdiff - source/scene.cpp
Check the flat qualifier from the correct member
[libs/gl.git] / source / scene.cpp
diff --git a/source/scene.cpp b/source/scene.cpp
deleted file mode 100644 (file)
index 9d301fb..0000000
+++ /dev/null
@@ -1,92 +0,0 @@
-#include <msp/datafile/collection.h>
-#include "animatedobject.h"
-#include "camera.h"
-#include "renderer.h"
-#include "scene.h"
-
-using namespace std;
-
-namespace Msp {
-namespace GL {
-
-Scene::~Scene()
-{
-       for(list<Renderable *>::iterator i=owned_data.begin(); i!=owned_data.end(); ++i)
-               delete *i;
-}
-
-bool Scene::setup_frustum(const Renderer &renderer) const
-{
-       const Camera *camera = renderer.get_camera();
-       if(!camera)
-               return false;
-
-       culling_matrix = renderer.get_matrix();
-
-       if(camera->is_orthographic())
-       {
-               float h = camera->get_orthographic_height();
-               frustum_edges[0] = Vector4(0, 1, 0, -h);
-               frustum_edges[1] = Vector4(0, -1, 0, -h);
-
-               float w = camera->get_orthographic_width();
-               frustum_edges[2] = Vector4(1, 0, 0, -w);
-               frustum_edges[3] = Vector4(-1, 0, 0, -w);
-       }
-       else
-       {
-               float y = tan(camera->get_field_of_view()/2.0f);
-               float s = sqrt(y*y+1);
-               frustum_edges[0] = Vector4(0, 1/s, y/s, 0);
-               frustum_edges[1] = Vector4(0, -1/s, y/s, 0);
-
-               float x = y*camera->get_aspect();
-               s = sqrt(x*x+1);
-               frustum_edges[2] = Vector4(1/s, 0, x/s, 0);
-               frustum_edges[3] = Vector4(-1/s, 0, x/s, 0);
-       }
-
-       frustum_edges[4] = Vector4(0, 0, -1, -camera->get_far_clip());
-       frustum_edges[5] = Vector4(0, 0, 1, camera->get_near_clip());
-
-       return true;
-}
-
-bool Scene::frustum_cull(const Renderable &renderable) const
-{
-       const Matrix *matrix = renderable.get_matrix();
-       const Geometry::BoundingSphere<float, 3> *bsphere = renderable.get_bounding_sphere();
-       if(!matrix || !bsphere)
-               return false;
-
-       Vector4 center = culling_matrix*(*matrix*compose(bsphere->get_center(), 1.0f));
-       Vector3 x_axis = (matrix->column(0)*bsphere->get_radius()).slice<3>(0);
-       float radius_sq = inner_product(x_axis, x_axis);
-
-       for(unsigned i=0; i<6; ++i)
-       {
-               float distance = inner_product(center, frustum_edges[i]);
-               if(distance>0 && distance*distance>radius_sq)
-                       return true;
-       }
-
-       return false;
-}
-
-
-Scene::Loader::Loader(Scene &s, Collection &c):
-       DataFile::CollectionObjectLoader<Scene>(s, &c)
-{
-       add("object", &Loader::object);
-}
-
-void Scene::Loader::object(const string &n)
-{
-       RefPtr<AnimatedObject> anob = new AnimatedObject(get_collection().get<GL::Object>(n));
-       load_sub(*anob);
-       obj.add(*anob);
-       obj.owned_data.push_back(anob.release());
-}
-
-} // namespace GL
-} // namespace Msp