+++ /dev/null
-
-/*] 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_RAY_HH_
-#define _MOOF_RAY_HH_
-
-#include <Moof/Drawable.hh>
-#include <Moof/Math.hh>
-#include <Moof/OpenGL.hh>
-#include <Moof/Texture.hh>
-
-
-namespace Mf {
-
-
-/**
- * A line that goes to infinity.
- */
-
-template <int D>
-struct Ray : public Drawable
-{
- typedef cml::vector< Scalar, cml::fixed<D> > Vector;
-
- // solution = point + t*direction
- Vector point;
- Vector direction;
-
- struct Contact
- {
- Scalar distance; // distance from the origin to the nearest point
- Vector normal; // surface normal at contact point
-
- bool operator < (const Contact& rhs)
- {
- return distance < rhs.distance;
- }
- };
-
- void solve(Vector& p, Scalar t) const
- {
- p = point + t*direction;
- }
-
- void draw(Scalar alpha = 0.0) const
- {
- Vector end = point + 1000.0 * direction;
- // FIXME this is kinda cheesy
-
- Mf::Texture::resetBind();
- glBegin(GL_LINES);
- glVertex(point);
- glVertex(end);
- glEnd();
- }
-
- void normalize()
- {
- direction.normalize();
- }
-};
-
-
-typedef Ray<2> Ray2;
-typedef Ray<3> Ray3;
-
-
-} // namespace Mf
-
-#endif // _MOOF_RAY_HH_
-