Object::Object():
meshes(1, static_cast<Mesh *>(0)),
+ main_texture(0),
material(0)
{
normal_pass=&passes[0];
textures[i]->bind();
}
}
- else if(!textures.empty())
- textures.front()->bind();
+ else if(main_texture)
+ main_texture->bind();
if(material)
material->apply();
void Object::finish_render(const ObjectPass &pass) const
{
if(pass.shprog)
- Program::unbind();
- for(unsigned i=textures.size(); i--;)
{
- TexUnit::activate(i);
- Texture::unbind();
+ Program::unbind();
+ for(unsigned i=textures.size(); i--;)
+ {
+ TexUnit::activate(i);
+ Texture::unbind();
+ }
}
+ else if(main_texture)
+ Texture::unbind();
}
void Object::render(const ObjectPass &pass, const ObjectInstance *inst) const
add("mesh", &Loader::mesh);
add("pass", &Loader::pass);
add("shader", &Loader::shader);
+ add("shader_texture", &Loader::shader_texture);
add("texture", &Loader::texture);
}
-Object::Loader::~Loader()
+void Object::Loader::finish()
{
for(map<unsigned, ObjectPass>::iterator i=obj.passes.begin(); i!=obj.passes.end(); ++i)
if(i->second.shdata)
}
}
-void Object::Loader::texture(const string &n)
+void Object::Loader::shader_texture(const string &n)
{
unsigned eqsign=n.find('=');
if(eqsign!=string::npos)
}
}
+void Object::Loader::texture(const string &n)
+{
+ if(obj.main_texture)
+ throw Exception("Only one main texture may be specified");
+
+ obj.main_texture=coll.get<Texture>(n);
+ obj.textures.push_back(obj.main_texture);
+ textures.push_back("texture");
+}
+
} // namespace GL
} // namespace Msp
class Object: public Renderable
{
private:
- std::vector<Mesh *> meshes;
- std::vector<Texture *> textures;
+ std::vector<const Mesh *> meshes;
+ std::vector<const Texture *> textures;
+ const Texture *main_texture;
std::map<unsigned, ObjectPass> passes;
- Material *material;
+ const Material *material;
ObjectPass *normal_pass;
public:
public:
Loader(Object &, Collection &);
- ~Loader();
Object &get_object() const { return obj; }
Collection &get_collection() const { return coll; }
private:
+ virtual void finish();
void lod_mesh(unsigned, const std::string &);
void material_inline();
void mesh(const std::string &);
void pass(const std::string &);
void shader(const std::string &);
+ void shader_texture(const std::string &);
void texture(const std::string &);
};