1 #ifndef MSP_GL_OBJECT_H_
2 #define MSP_GL_OBJECT_H_
6 #include "renderable.h"
7 #include "renderpass.h"
8 #include "resourcewatcher.h"
20 Combines a Mesh with a Technique to give it an appearance. The Technique will
21 define which render passes the Object supports.
23 In many cases, it's desirable to include multiple copies of an Object in a
24 Scene, with different model matrices. ObjectInstances can be used to alter the
25 rendering of an object on a per-instance basis.
27 class Object: public Renderable, private ResourceWatcher
30 class Loader: public DataFile::CollectionObjectLoader<Object>
34 Loader(Object &, Collection &);
37 virtual void finish();
40 void mesh_inline_lod(unsigned);
41 void mesh(const std::string &);
42 void mesh_lod(unsigned, const std::string &);
43 void technique_inline();
44 void technique(const std::string &);
48 std::vector<RefPtr<const Mesh> > meshes;
49 RefPtr<const Technique> technique;
50 Geometry::BoundingSphere<float, 3> bounding_sphere;
54 Object(const Mesh *, const Technique *);
57 void set_mesh(const Mesh *m) { set_mesh(0, m); }
58 void set_mesh(unsigned, const Mesh *);
60 void update_bounding_sphere();
62 const Mesh *get_mesh(unsigned = 0) const;
63 void set_technique(const Technique *);
64 const Technique *get_technique() const { return technique.get(); }
66 virtual const Geometry::BoundingSphere<float, 3> *get_bounding_sphere() const { return &bounding_sphere; }
68 virtual void render(const Tag &tag = Tag()) const;
70 virtual void render(Renderer &, const Tag & = Tag()) const;
72 /** Renders an instance of the object. The instance's hook functions are
73 called before and after drawing the mesh. */
74 virtual void render(Renderer &, const ObjectInstance &, const Tag & = Tag()) const;
77 virtual void setup_render(Renderer &, const Tag &) const { }
78 virtual void finish_render(Renderer &, const Tag &) const { }
81 const RenderPass *get_pass(const Tag &) const;
83 virtual void resource_loaded(Resource &);