]> git.tdb.fi Git - libs/gl.git/blob - source/render/objectinstance.h
Check the flat qualifier from the correct member
[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.  A model matrix is provided through
13 the Placeable base class.
14
15 The state used to render the object can be customized by overriding the
16 setup_render() and finish_render() functions.
17 */
18 class ObjectInstance: public PlacedRenderable
19 {
20 public:
21         class Loader: public DataFile::ObjectLoader<ObjectInstance>
22         {
23         public:
24                 Loader(ObjectInstance &);
25
26         private:
27                 void transform();
28         };
29
30 protected:
31         const Object &object;
32
33 public:
34         ObjectInstance(const Object &);
35
36         const Object &get_object() const { return object; }
37
38         virtual const Geometry::BoundingSphere<float, 3> *get_bounding_sphere() const { return object.get_bounding_sphere(); }
39
40         virtual void render(Renderer &, Tag = Tag()) const;
41
42         /** Hook function, called from Object just before rendering the mesh.
43         Renderer state will have been pushed before this is called. */
44         virtual void setup_render(Renderer &, Tag) const;
45
46         /** Hook function, called from Object right after rendering the mesh.  Since
47         Object takes care of pushing Renderer state, this rarely needs to do
48         anything. */
49         virtual void finish_render(Renderer &, Tag) const { }
50
51         /** Returns the level of detail to render this instance with.  This function
52         should apply LoD bias from the Renderer if desired. */
53         virtual unsigned get_level_of_detail(const Renderer &) const;
54 };
55
56 } // namespace GL
57 } // namespaec Msp
58
59 #endif