X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fobject.cpp;h=5aec7e744a3ce308c8b818edb76c8ce4a8a39abd;hb=0fc02952ed449ff85f5f9e96ea2fc724c8456891;hp=86857a9842f10d7523cc1361527df29a07f0941f;hpb=df1f68d366e145716225f1a4dd223b0129280fb2;p=libs%2Fgl.git diff --git a/source/object.cpp b/source/object.cpp index 86857a98..5aec7e74 100644 --- a/source/object.cpp +++ b/source/object.cpp @@ -1,13 +1,5 @@ -/* $Id$ - -This file is part of libmspgl -Copyright © 2007-2011 Mikko Rasa, Mikkosoft Productions -Distributed under the LGPL -*/ - #include -#include -#include "except.h" +#include #include "material.h" #include "mesh.h" #include "object.h" @@ -34,7 +26,7 @@ Object::~Object() void Object::set_mesh(unsigned i, const Mesh *m) { if(i>meshes.size()) - throw InvalidParameterValue("LODs must be continuous"); + throw invalid_argument("Object::set_mesh"); if(i==meshes.size()) meshes.push_back(m); @@ -43,6 +35,14 @@ void Object::set_mesh(unsigned i, const Mesh *m) meshes[i].keep(); } +const Mesh *Object::get_mesh(unsigned i) const +{ + if(i>=meshes.size()) + return 0; + + return meshes[i].get(); +} + void Object::set_technique(const Technique *t) { technique = t; @@ -117,8 +117,6 @@ Object::Loader::Loader(Object &o, Collection &c): void Object::Loader::init() { - allow_pointer_reload = false; - add("mesh", &Loader::mesh_inline); add("mesh", &Loader::mesh_inline_lod); add("mesh", &Loader::mesh); @@ -140,7 +138,7 @@ void Object::Loader::mesh_inline() void Object::Loader::mesh_inline_lod(unsigned l) { if(l>obj.meshes.size()) - throw InvalidParameterValue("LODs must be continuous"); + throw invalid_argument("Object::Loader::mesh_inline_lod"); RefPtr msh = new Mesh; load_sub(*msh); @@ -152,12 +150,12 @@ void Object::Loader::mesh_inline_lod(unsigned l) void Object::Loader::mesh(const std::string &n) { - obj.set_mesh(get_collection().get(n)); + obj.set_mesh(&get_collection().get(n)); } void Object::Loader::mesh_lod(unsigned l, const string &n) { - obj.set_mesh(l, get_collection().get(n)); + obj.set_mesh(l, &get_collection().get(n)); } void Object::Loader::technique_inline() @@ -172,7 +170,7 @@ void Object::Loader::technique_inline() void Object::Loader::technique(const std::string &n) { - obj.set_technique(get_collection().get(n)); + obj.set_technique(&get_collection().get(n)); } } // namespace GL