#ifndef _MOOF_AABB_HH_
#define _MOOF_AABB_HH_
+#include <Moof/Cullable.hh>
#include <Moof/Drawable.hh>
#include <Moof/Math.hh>
+#include <Moof/Plane.hh>
namespace Mf {
* Axis-aligned Bounding Box
*/
-struct Aabb : public Drawable
+struct Aabb : public Cullable, public Drawable
{
Vector3 min;
Vector3 max;
(min[2] + max[2]) / 2.0);
}
- void draw(Scalar alpha) const;
+ void getOctant(Aabb& octant, int num) const;
+
+ inline Plane getPlaneXY() const
+ {
+ Plane plane;
+ plane.normal = Vector3(0.0, 0.0, 1.0);
+ plane.d = cml::dot(-plane.normal, getCenter());
+ return plane;
+ }
+
+ inline Plane getPlaneXZ() const
+ {
+ Plane plane;
+ plane.normal = Vector3(0.0, 1.0, 0.0);
+ plane.d = cml::dot(-plane.normal, getCenter());
+ return plane;
+ }
+
+ inline Plane getPlaneYZ() const
+ {
+ Plane plane;
+ plane.normal = Vector3(1.0, 0.0, 0.0);
+ plane.d = cml::dot(-plane.normal, getCenter());
+ return plane;
+ }
+
+ void getCorners(Vector3 corners[8]) const;
+
+ void encloseVertices(const Vector3 vertices[], unsigned count);
+
+ void draw(Scalar alpha = 0.0) const;
+ bool isVisible(const Camera& cam) const;
};