#include <msp/datafile/collection.h>
#include <msp/strings/format.h>
-#include "except.h"
#include "material.h"
#include "mesh.h"
#include "object.h"
meshes(1)
{ }
+Object::Object(const Mesh *m, const Technique *t)
+{
+ set_mesh(m);
+ set_technique(t);
+}
+
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);
renderer.set_texturing(pass->get_texturing());
inst.setup_render(renderer, tag);
- unsigned lod = min<unsigned>(inst.get_level_of_detail(), meshes.size()-1);
+ unsigned lod = min<unsigned>(inst.get_level_of_detail(renderer), meshes.size()-1);
meshes[lod]->draw(renderer);
inst.finish_render(renderer, tag);
}
void Object::Loader::init()
{
- allow_pointer_reload = false;
-
add("mesh", &Loader::mesh_inline);
add("mesh", &Loader::mesh_inline_lod);
add("mesh", &Loader::mesh);
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<Mesh> msh = new Mesh;
load_sub(*msh);
void Object::Loader::mesh(const std::string &n)
{
- obj.set_mesh(get_collection().get<Mesh>(n));
+ obj.set_mesh(&get_collection().get<Mesh>(n));
}
void Object::Loader::mesh_lod(unsigned l, const string &n)
{
- obj.set_mesh(l, get_collection().get<Mesh>(n));
+ obj.set_mesh(l, &get_collection().get<Mesh>(n));
}
void Object::Loader::technique_inline()
void Object::Loader::technique(const std::string &n)
{
- obj.set_technique(get_collection().get<Technique>(n));
+ obj.set_technique(&get_collection().get<Technique>(n));
}
} // namespace GL