]> git.tdb.fi Git - libs/gl.git/blob - source/render/objectinstance.h
Add functions to retrieve steps and postprocessors from Sequence
[libs/gl.git] / source / render / objectinstance.h
1 #ifndef MSP_GL_OBJETCINSTANCE_H_
2 #define MSP_GL_OBJETCINSTANCE_H_
3
4 #include <string>
5 #include "object.h"
6 #include "placeable.h"
7
8 namespace Msp {
9 namespace GL {
10
11 /**
12 Represents a single instance of an Object.  Thanks to being derived from
13 Placeable in can be positioned without additional effort.  Other instance
14 parameters can be set by overriding the hook functions.
15 */
16 class ObjectInstance: public PlacedRenderable
17 {
18 public:
19         class Loader: public DataFile::ObjectLoader<ObjectInstance>
20         {
21         public:
22                 Loader(ObjectInstance &);
23
24         private:
25                 void transform();
26         };
27
28 protected:
29         const Object &object;
30
31 public:
32         ObjectInstance(const Object &);
33
34         const Object &get_object() const { return object; }
35
36         virtual const Geometry::BoundingSphere<float, 3> *get_bounding_sphere() const { return object.get_bounding_sphere(); }
37
38         virtual void render(Renderer &, Tag = Tag()) const;
39
40         /** Hook function, called from Object just before rendering the mesh.
41         Renderer state will have been pushed before this is called. */
42         virtual void setup_render(Renderer &, Tag) const;
43
44         /** Hook function, called from Object right after rendering the mesh.  Since
45         Object takes care of pushing Renderer state, this rarely needs to do
46         anything. */
47         virtual void finish_render(Renderer &, Tag) const { }
48
49         virtual unsigned get_level_of_detail(const Renderer &) const;
50 };
51
52 } // namespace GL
53 } // namespaec Msp
54
55 #endif