]> git.tdb.fi Git - libs/gl.git/blob - source/object.h
Move some declarations around a bit
[libs/gl.git] / source / object.h
1 #ifndef MSP_GL_OBJECT_H_
2 #define MSP_GL_OBJECT_H_
3
4 #include <vector>
5 #include "bindable.h"
6 #include "renderable.h"
7 #include "renderpass.h"
8
9 namespace Msp {
10 namespace GL {
11
12 class Material;
13 class Mesh;
14 class ObjectInstance;
15 class Technique;
16 class Texture;
17
18 /**
19 Stores a Mesh together with a Technique to determine its appearance.
20
21 It is possible to use a single Object for rendering multiple identical or
22 similar objects.  See class ObjectInstance.
23 */
24 class Object: public Renderable
25 {
26 public:
27         class Loader: public DataFile::CollectionObjectLoader<Object>
28         {
29         public:
30                 Loader(Object &);
31                 Loader(Object &, Collection &);
32         private:
33                 void init();
34
35         private:
36                 void mesh_inline();
37                 void mesh_inline_lod(unsigned);
38                 void mesh(const std::string &);
39                 void mesh_lod(unsigned, const std::string &);
40                 void technique_inline();
41                 void technique(const std::string &);
42         };
43
44 private:
45         std::vector<RefPtr<const Mesh> > meshes;
46         RefPtr<const Technique> technique;
47
48 public:
49         Object();
50         Object(const Mesh *, const Technique *);
51         ~Object();
52
53         void set_mesh(const Mesh *m) { set_mesh(0, m); }
54         void set_mesh(unsigned, const Mesh *);
55         const Mesh *get_mesh(unsigned = 0) const;
56         void set_technique(const Technique *);
57         const Technique *get_technique() const { return technique.get(); }
58
59         /**
60         Renders the object.  A tag can be provided to render a non-default pass.
61         */
62         virtual void render(const Tag &tag = Tag()) const;
63
64         virtual void render(Renderer &, const Tag & = Tag()) const;
65
66         /**
67         Renders the object with an instance.  The instance's hook functions are
68         called before and after drawing the mesh.  A tag may also be given to render
69         a non-default pass.
70         */
71         virtual void render(Renderer &, const ObjectInstance &, const Tag & = Tag()) const;
72
73 private:
74         const RenderPass *get_pass(const Tag &) const;
75 };
76
77 } // namespace GL
78 } // namespace Msp
79
80 #endif