]> git.tdb.fi Git - libs/gl.git/blob - source/placeable.h
Add a new Placeable base class
[libs/gl.git] / source / placeable.h
1 #ifndef MSP_GL_PLACEABLE_H_
2 #define MSP_GL_PLACEABLE_H_
3
4 #include "matrix.h"
5 #include "renderable.h"
6
7 namespace Msp {
8 namespace GL {
9
10 /**
11 A base class for things that can be positioned and oriented in 3D space.
12 */
13 class Placeable
14 {
15 protected:
16         Matrix matrix;
17
18         Placeable() { }
19
20 public:
21         virtual void set_matrix(const Matrix &);
22
23         /** Returns the Placeable's matrix.  This function returns a pointer for
24         compatibility with Renderable.  The returned pointer is never null. */
25         virtual const Matrix *get_matrix() const { return &matrix; }
26 };
27
28
29 class PlacedRenderable: public Renderable, public Placeable
30 {
31 protected:
32         PlacedRenderable() { }
33
34 public:
35         /* Reimplement to clear ambiguity between Renderable and Placeable.  This
36         overrides both base classes' implementations. */
37         virtual const Matrix *get_matrix() const { return &matrix; }
38 };
39
40 } // namespace GL
41 } // namespace Msp
42
43 #endif