-/*] Copyright (c) 2009-2010, Charles McGarvey [**************************
+/*] Copyright (c) 2009-2011, 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_SPHERE_HH_
#define _MOOF_SPHERE_HH_
-/**
- * \file sphere.hh
- * A round shape like a circle or sphere.
- * TODO: This class needs some work.
- */
-
#include <moof/contact.hh>
#include <moof/cullable.hh>
#include <moof/drawable.hh>
#include <moof/shape.hh>
+/**
+ * \file sphere.hh
+ * A round shape like a circle or sphere.
+ * TODO: This class needs some work.
+ */
+
namespace moof {
vector point;
scalar radius;
-
sphere() {}
sphere(const vector& p, scalar r) :
point(p),
radius(r) {}
-
void init(const vector& p, scalar r)
{
point = p;
return true;
}
-
bool intersect(const sphere<D>& sphere, contact<D>& hit) const
{
vector n = sphere.point - point;
}
// a ray inside the sphere will not intersect on its way out
- bool intersect(const ray<D>& ray, typename ray<D>::contact& hit) const
+ bool intersect(const ray<D>& ray,
+ typename moof::ray<D>::contact& hit) const
{
vector b = point - ray.point;
scalar z = dot(b, ray.direction);
}
};
+typedef sphere<2> circle;
+typedef sphere<2> sphere2;
+typedef sphere<3> sphere3;
+
template <>
-inline bool sphere<3>::is_visible(const frustum& frustum) const
+inline bool sphere3::is_visible(const frustum& frustum) const
{
return frustum.contains(*this);
}
template <>
-inline void sphere<2>::draw(scalar alpha) const
+inline void sphere2::draw(scalar alpha) const
{
GLUquadricObj* sphereObj = gluNewQuadric();
gluQuadricDrawStyle(sphereObj, GLU_LINE);
}
template <>
-inline void sphere<3>::draw(scalar alpha) const
+inline void sphere3::draw(scalar alpha) const
{
GLUquadricObj* sphereObj = gluNewQuadric();
gluQuadricDrawStyle(sphereObj, GLU_LINE);
}
-typedef sphere<2> sphere2;
-typedef sphere2 circle;
-typedef sphere<3> sphere3;
-
-
} // namespace moof
#endif // _MOOF_SPHERE_HH_