]> git.tdb.fi Git - r2c2.git/blobdiff - source/libr2c2/object.h
Add a common base class for tangible objects
[r2c2.git] / source / libr2c2 / object.h
diff --git a/source/libr2c2/object.h b/source/libr2c2/object.h
new file mode 100644 (file)
index 0000000..206ec33
--- /dev/null
@@ -0,0 +1,35 @@
+#ifndef LIBR2C2_OBJECT_H_
+#define LIBR2C2_OBJECT_H_
+
+#include "geometry.h"
+#include "objecttype.h"
+
+namespace R2C2 {
+
+class Layout;
+
+class Object
+{
+protected:
+       Layout &layout;
+       Vector position;
+       float rotation;
+
+       Object(Layout &l): layout(l) { }
+public:
+       virtual ~Object() { }
+
+       virtual Object *clone(Layout * = 0) const = 0;
+       virtual const ObjectType &get_type() const = 0;
+       Layout &get_layout() const { return layout; }
+       virtual void set_position(const Vector &) = 0;
+       virtual void set_rotation(float) = 0;
+       const Vector &get_position() const { return position; }
+       float get_rotation() const { return rotation; }
+       virtual Object *get_parent() const { return 0; }
+       virtual bool collide_ray(const Vector &, const Vector &) const = 0;
+};
+
+} // namespace R2C2
+
+#endif