]> Dogcows Code - chaz/yoink/blobdiff - src/moof/shape.hh
the massive refactoring effort
[chaz/yoink] / src / moof / shape.hh
diff --git a/src/moof/shape.hh b/src/moof/shape.hh
new file mode 100644 (file)
index 0000000..7f97503
--- /dev/null
@@ -0,0 +1,75 @@
+
+/*]  Copyright (c) 2009-2010, Charles McGarvey  [**************************
+**]  All rights reserved.
+*
+* vi:ts=4 sw=4 tw=75
+*
+* Distributable under the terms and conditions of the 2-clause BSD license;
+* see the file COPYING for a complete text of the license.
+*
+**************************************************************************/
+
+#ifndef _MOOF_SHAPE_HH_
+#define _MOOF_SHAPE_HH_
+
+/**
+ * \file shape.hh
+ * Declares an interface for shapes.
+ */
+
+#include <moof/drawable.hh>
+#include <moof/math.hh>
+#include <moof/opengl.hh>
+#include <moof/ray.hh>
+
+
+// frustum
+// plane (can construct from triangle2)
+// ray
+// shape<>
+// +- line<>
+// -   line2                   line<2>
+// -   line3                   line<3>
+// +- sphere<>
+// |   sphere2, circle sphere<2>
+// |   sphere3                 sphere<3>
+// +- aabb<>
+// |   aabb2, rectangle        aabb<2>
+// |   aabb3                   aabb<3>
+// +- polygon<>
+// |   triangle2               polygon<2,3>
+// |   triangle3               polygon<3,3>
+
+
+namespace moof {
+
+
+template <int D>
+class shape
+{
+public:
+
+       virtual ~shape() {}
+
+       /**
+        * Checks if this shape is intersected by a given ray.  If so, returns
+        * the distance from the start of the ray to the shape and information
+        * about the contact via the 2nd parameter.  A negative value is
+        * returned if there is no contact.
+        */
+       virtual bool intersect_ray(const ray<D>& ray,
+                                                          typename ray<D>::contact& hit) const
+       {
+               return false;
+       }
+};
+
+
+typedef shape<2>       shape2;
+typedef shape<3>       shape3;
+
+
+} // namespace moof
+
+#endif // _MOOF_SHAPE_HH_
+
This page took 0.022333 seconds and 4 git commands to generate.