+void Object::render(Renderer &renderer, const Tag &tag) const
+{
+ const RenderPass *pass = get_pass(tag, 0);
+ if(!pass)
+ return;
+
+ const Mesh *mesh = lods.front().mesh.get();
+ if (!mesh)
+ throw logic_error("no mesh");
+
+ Renderer::Push push(renderer);
+ pass->apply(renderer);
+
+ setup_render(renderer, tag);
+ mesh->draw(renderer);
+ finish_render(renderer, tag);
+}
+
+void Object::render(Renderer &renderer, const ObjectInstance &inst, const Tag &tag) const
+{
+ unsigned lod = min<unsigned>(inst.get_level_of_detail(renderer), lods.size()-1);
+ const RenderPass *pass = get_pass(tag, lod);
+ if(!pass)
+ return;
+
+ const Mesh *mesh = lods[lod].mesh.get();
+ if (!mesh)
+ throw logic_error("no mesh");
+
+ Renderer::Push push(renderer);
+ pass->apply(renderer);
+
+ setup_render(renderer, tag);
+ inst.setup_render(renderer, tag);
+ mesh->draw(renderer);
+ inst.finish_render(renderer, tag);
+ finish_render(renderer, tag);
+}
+
+const RenderPass *Object::get_pass(const Tag &tag, unsigned lod) const
+{
+ const Technique *tech = lods[lod].technique.get();
+ if(!tech)
+ throw logic_error("no technique");
+ return tech->find_pass(tag);
+}
+
+void Object::resource_loaded(Resource &res)
+{
+ if(&res==lods.front().mesh.get() && bounding_sphere.is_empty())
+ update_bounding_sphere();
+}
+
+void Object::resource_removed(Resource &res)
+{
+ if(&res==lods.front().mesh.get())
+ lod0_watched = false;
+}
+
+
+Object::Loader::Loader(Object &o):
+ LodLoader(o, 0, 0)
+{
+ init();
+}