Distributed under the LGPL
*/
+#include <msp/datafile/collection.h>
#include <msp/strings/formatter.h>
#include "except.h"
#include "material.h"
Object::Loader::Loader(Object &o, Collection &c):
- obj(o),
- coll(c)
+ DataFile::CollectionObjectLoader<Object>(o, &c)
{
add("lod_mesh", &Loader::lod_mesh);
add("material", &Object::material);
void Object::Loader::lod_mesh(unsigned l, const string &n)
{
obj.meshes.resize(l+1, 0);
- obj.meshes[l]=coll.get<Mesh>(n);
+ obj.meshes[l]=coll->get<Mesh>(n);
}
void Object::Loader::material_inline()
{
RefPtr<Material> mat=new Material;
load_sub(*mat);
- coll.add(format("_%p", mat.get()), mat.get());
+ coll->add(format("_%p", mat.get()), mat.get());
obj.material=mat.release();
}
void Object::Loader::mesh(const string &n)
{
- obj.meshes[0]=coll.get<Mesh>(n);
+ obj.meshes[0]=coll->get<Mesh>(n);
}
void Object::Loader::shader_texture(const string &n)
if(eqsign==string::npos)
throw InvalidParameterValue("Must specify texture slot name");
- obj.textures[obj.technique->get_texture_index(n.substr(0, eqsign))]=coll.get<Texture>(n.substr(eqsign+1));
+ obj.textures[obj.technique->get_texture_index(n.substr(0, eqsign))]=coll->get<Texture>(n.substr(eqsign+1));
}
void Object::Loader::technique(const string &n)
{
- obj.technique=coll.get<Technique>(n);
+ obj.technique=coll->get<Technique>(n);
obj.textures.resize(obj.technique->get_n_textures());
obj.material=obj.technique->get_material();
}
if(obj.main_texture)
throw Exception("Only one main texture may be specified");
- Texture *tex=coll.get<Texture>(n);
+ Texture *tex=coll->get<Texture>(n);
if(obj.technique)
obj.textures[obj.technique->get_texture_index("texture")]=tex;
obj.main_texture=tex;