X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fscene.cpp;h=e6c62e802f8c9672fafce477d3eae50c9f2efaac;hp=9d301fbfb0801ab3d1ea95b5104d88f81b94d902;hb=8bc776f177c7cf9d0c6fd9590273f086d38c23ca;hpb=a25a5932b80e7d1c11be6b09c5e00857b9238f60 diff --git a/source/scene.cpp b/source/scene.cpp index 9d301fbf..e6c62e80 100644 --- a/source/scene.cpp +++ b/source/scene.cpp @@ -11,7 +11,7 @@ namespace GL { Scene::~Scene() { - for(list::iterator i=owned_data.begin(); i!=owned_data.end(); ++i) + for(vector::iterator i=owned_data.begin(); i!=owned_data.end(); ++i) delete *i; } @@ -40,7 +40,7 @@ bool Scene::setup_frustum(const Renderer &renderer) const 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(); + float x = y*camera->get_aspect_ratio(); 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); @@ -75,16 +75,37 @@ bool Scene::frustum_cull(const Renderable &renderable) const Scene::Loader::Loader(Scene &s, Collection &c): - DataFile::CollectionObjectLoader(s, &c) + DataFile::CollectionObjectLoader(s, &c), + content(0) +{ + init(); +} + +Scene::Loader::Loader(Scene &s, Collection &c, ContentMap &m): + DataFile::CollectionObjectLoader(s, &c), + content(&m) +{ + init(); +} + +void Scene::Loader::init() { add("object", &Loader::object); + add("object", &Loader::object_tagged); } void Scene::Loader::object(const string &n) +{ + object_tagged(n, string()); +} + +void Scene::Loader::object_tagged(const string &n, const string &t) { RefPtr anob = new AnimatedObject(get_collection().get(n)); load_sub(*anob); obj.add(*anob); + if(content && !t.empty()) + (*content)[t] = anob.get(); obj.owned_data.push_back(anob.release()); }