]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/object.h
Add a common base class for tangible objects
[r2c2.git] / source / libr2c2 / object.h
1 #ifndef LIBR2C2_OBJECT_H_
2 #define LIBR2C2_OBJECT_H_
3
4 #include "geometry.h"
5 #include "objecttype.h"
6
7 namespace R2C2 {
8
9 class Layout;
10
11 class Object
12 {
13 protected:
14         Layout &layout;
15         Vector position;
16         float rotation;
17
18         Object(Layout &l): layout(l) { }
19 public:
20         virtual ~Object() { }
21
22         virtual Object *clone(Layout * = 0) const = 0;
23         virtual const ObjectType &get_type() const = 0;
24         Layout &get_layout() const { return layout; }
25         virtual void set_position(const Vector &) = 0;
26         virtual void set_rotation(float) = 0;
27         const Vector &get_position() const { return position; }
28         float get_rotation() const { return rotation; }
29         virtual Object *get_parent() const { return 0; }
30         virtual bool collide_ray(const Vector &, const Vector &) const = 0;
31 };
32
33 } // namespace R2C2
34
35 #endif