]> git.tdb.fi Git - libs/gl.git/blob - source/object.h
Drop Id tags and copyright notices from files
[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 private:
27         std::vector<RefPtr<const Mesh> > meshes;
28         RefPtr<const Technique> technique;
29
30 public:
31         class Loader: public DataFile::CollectionObjectLoader<Object>
32         {
33         public:
34                 Loader(Object &);
35                 Loader(Object &, Collection &);
36         private:
37                 void init();
38
39         private:
40                 void mesh_inline();
41                 void mesh_inline_lod(unsigned);
42                 void mesh(const std::string &);
43                 void mesh_lod(unsigned, const std::string &);
44                 void technique_inline();
45                 void technique(const std::string &);
46         };
47
48         Object();
49         ~Object();
50
51         void set_mesh(const Mesh *m) { set_mesh(0, m); }
52         void set_mesh(unsigned, const Mesh *);
53         const Mesh *get_mesh(unsigned = 0) const;
54         void set_technique(const Technique *);
55         const Technique *get_technique() const { return technique.get(); }
56
57         /**
58         Renders the object.  A tag can be provided to render a non-default pass.
59         */
60         virtual void render(const Tag &tag = Tag()) const;
61
62         virtual void render(Renderer &, const Tag & = Tag()) const;
63
64         /**
65         Renders the object with an instance.  The instance's hook functions are
66         called before and after drawing the mesh.  A tag may also be given to render
67         a non-default pass.
68         */
69         virtual void render(Renderer &, const ObjectInstance &, const Tag & = Tag()) const;
70
71 private:
72         const RenderPass *get_pass(const Tag &) const;
73 };
74
75 } // namespace GL
76 } // namespace Msp
77
78 #endif