#ifndef _MOOF_AABB_HH_
#define _MOOF_AABB_HH_
-#include <Moof/Cullable.hh>
-#include <Moof/Drawable.hh>
-#include <Moof/Math.hh>
-#include <Moof/Plane.hh>
-#include <Moof/Shape.hh>
+/**
+ * \file aabb.hh
+ * Axis-aligned Bounding Box
+ */
-#include <Moof/Frustum.hh> // FIXME this file is quite broken
-#include <Moof/OpenGL.hh>
-#include <Moof/Texture.hh>
+#include <moof/cullable.hh>
+#include <moof/drawable.hh>
+#include <moof/math.hh>
+#include <moof/plane.hh>
+#include <moof/shape.hh>
+#include <moof/frustum.hh> // FIXME: this file is quite broken
+#include <moof/opengl.hh>
+#include <moof/texture.hh>
-namespace Mf {
+namespace moof {
-class Script;
+class script;
-/**
- * Axis-aligned Bounding Box
- */
template <int D = 3>
-struct Aabb : public Cullable, public Drawable, public Shape<D>
+struct aabb : public cullable, public drawable, public shape<D>
{
- typedef cml::vector< Scalar, cml::fixed<D> > Vector;
+ typedef moof::vector< scalar, fixed<D> > vector;
- Vector min;
- Vector max;
+ vector min;
+ vector max;
- Aabb() {}
+ aabb() {}
- Aabb(const Vector& a, const Vector& b)
+ aabb(const vector& a, const vector& b)
{
init(a, b);
}
- Aabb(Scalar x1, Scalar y1, Scalar x2, Scalar y2)
+ aabb(scalar x1, scalar y1, scalar x2, scalar y2)
{
- Vector a(x1, y1);
- Vector b(x2, y2);
+ vector a(x1, y1);
+ vector b(x2, y2);
init(a, b);
}
- Aabb(Scalar x1, Scalar y1, Scalar z1, Scalar x2, Scalar y2, Scalar z2)
+ aabb(scalar x1, scalar y1, scalar z1, scalar x2, scalar y2, scalar z2)
{
- Vector a(x1, y1, z1);
- Vector b(x2, y2, z2);
+ vector a(x1, y1, z1);
+ vector b(x2, y2, z2);
init(a, b);
}
- void init(const Vector2& a, const Vector2& b)
+ void init(const vector2& a, const vector2& b)
{
if (a[0] < b[0])
{
}
}
- void init(const Vector3& a, const Vector3& b)
+ void init(const vector3& a, const vector3& b)
{
if (a[0] < b[0])
{
}
- Vector getCenter() const
+ vector center() const
{
return (min + max) / 2.0;
}
- Plane getPlaneXY() const
+ plane xy_plane() const
{
- Plane plane;
- plane.normal = Vector3(0.0, 0.0, 1.0);
- plane.d = cml::dot(-plane.normal, getCenter());
+ plane plane;
+ plane.normal = vector3(0.0, 0.0, 1.0);
+ plane.d = dot(-plane.normal, center());
return plane;
}
- Plane getPlaneXZ() const
+ plane xz_plane() const
{
- Plane plane;
- plane.normal = Vector3(0.0, 1.0, 0.0);
- plane.d = cml::dot(-plane.normal, getCenter());
+ plane plane;
+ plane.normal = vector3(0.0, 1.0, 0.0);
+ plane.d = dot(-plane.normal, center());
return plane;
}
- Plane getPlaneYZ() const
+ plane yz_plane() const
{
- Plane plane;
- plane.normal = Vector3(1.0, 0.0, 0.0);
- plane.d = cml::dot(-plane.normal, getCenter());
+ plane plane;
+ plane.normal = vector3(1.0, 0.0, 0.0);
+ plane.d = dot(-plane.normal, center());
return plane;
}
- void getCorners(Vector2 corners[4]) const
+ void get_corners(vector2 corners[4]) const
{
corners[0][0] = min[0]; corners[0][1] = min[1];
corners[1][0] = max[0]; corners[1][1] = min[1];
corners[3][0] = min[0]; corners[3][1] = max[1];
}
- void getCorners(Vector3 corners[8]) const
+ void get_corners(vector3 corners[8]) const
{
corners[0][0] = min[0];
corners[0][1] = min[1];
}
- void encloseVertices(const Vector vertices[], unsigned count)
+ void enclose_vertices(const vector vertices[], unsigned count)
{
min.zero();
max.zero();
}
- void draw(Scalar alpha = 0.0) const
+ void draw(scalar alpha = 0.0) const
{
glRect(min[0], min[1], max[0], max[1]);
}
- bool isVisible(const Frustum& frustum) const
+ bool is_visible(const frustum& frustum) const
{
return true;
}
};
-void importAabbClass(Script& script);
+void import_aabb_class(script& script);
template <>
-inline void Aabb<3>::draw(Scalar alpha) const
+inline void aabb<3>::draw(scalar alpha) const
{
- Scalar vertices[] = {min[0], min[1], min[2],
+ scalar vertices[] = {min[0], min[1], min[2],
min[0], max[1], min[2],
max[0], max[1], min[2],
max[0], min[1], min[2],
glVertexPointer(3, GL_SCALAR, 0, vertices);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
- Texture::resetBind();
+ texture::reset_binding();
glDrawElements(GL_QUADS, sizeof(indices), GL_UNSIGNED_BYTE,
indices);
}
template <>
-inline bool Aabb<3>::isVisible(const Frustum& frustum) const
+inline bool aabb<3>::is_visible(const frustum& frustum) const
{
return frustum.contains(*this);
}
-typedef Aabb<2> Aabb2;
-typedef Aabb2 Rectangle;
-typedef Aabb<3> Aabb3;
+typedef aabb<2> aabb2;
+typedef aabb2 rectangle;
+typedef aabb<3> aabb3;
-} // namespace Mf
+} // namespace moof
#endif // _MOOF_AABB_HH_