Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

peon::AxisAlignedBox Class Reference

A 3D box aligned with the x/y/z axes. More...

#include <AxisAlignedBox.h>

List of all members.

Public Member Functions

 AxisAlignedBox (const Vector3 &min, const Vector3 &max)
 AxisAlignedBox (Real mx, Real my, Real mz, Real Mx, Real My, Real Mz)
const Vector3getMinimum (void) const
 Gets the minimum corner of the box.
const Vector3getMaximum (void) const
 Gets the maximum corner of the box.
void setMinimum (const Vector3 &vec)
 Sets the minimum corner of the box.
void setMinimum (Real x, Real y, Real z)
void setMaximum (const Vector3 &vec)
 Sets the maximum corner of the box.
void setMaximum (Real x, Real y, Real z)
void setExtents (const Vector3 &min, const Vector3 &max)
 Sets both minimum and maximum extents at once.
void setExtents (Real mx, Real my, Real mz, Real Mx, Real My, Real Mz)
const Vector3getAllCorners (void) const
 Returns a pointer to an array of 8 corner points, useful for collision vs.
void merge (const AxisAlignedBox &rhs)
 Merges the passed in box into the current box.
void merge (const Vector3 &point)
 Extends the box to encompass the specified point (if needed).
void transform (const Matrix44 &matrix)
 Transforms the box according to the matrix supplied.
void setNull ()
 Sets the box to a 'null' value i.e.
bool isNull (void) const
 Returns true if the box is null i.e.
bool intersects (const AxisAlignedBox &b2) const
 Returns whether or not this box intersects another.
AxisAlignedBox intersection (const AxisAlignedBox &b2) const
 Calculate the area of intersection of this box and another.
Real volume (void) const
 Calculate the volume of this box.
void scale (const Vector3 &s)
 Scales the AABB by the vector given.
bool intersects (const Sphere &s) const
 Tests whether this box intersects a sphere.
bool intersects (const Plane &p) const
 Tests whether this box intersects a plane.
bool intersects (const Vector3 &v) const
 Tests whether the vector point is within this box.
Vector3 getCenter (void) const
 Gets the centre of the box.

Protected Member Functions

void updateCorners (void)
 Internal method for updating corner points.

Protected Attributes

Vector3 mMinimum
Vector3 mMaximum
bool mNull
Vector3 mCorners [8]

Friends

std::ostream & operator<< (std::ostream &o, AxisAlignedBox aab)


Detailed Description

A 3D box aligned with the x/y/z axes.

Remarks:
This class represents a simple box which is aligned with the axes. Internally it only stores 2 points as the extremeties of the box, one which is the minima of all 3 axes, and the other which is the maxima of all 3 axes. This class is typically used for an axis-aligned bounding box (AABB) for collision and visibility determination.


Member Function Documentation

const Vector3* peon::AxisAlignedBox::getAllCorners void   )  const [inline]
 

Returns a pointer to an array of 8 corner points, useful for collision vs.

non-aligned objects.

Remarks:
If the order of these corners is important, they are as follows: The 4 points of the minimum Z face (note that because Ogre uses right-handed coordinates, the minimum Z is at the 'back' of the box) starting with the minimum point of all, then anticlockwise around this face (if you are looking onto the face from outside the box). Then the 4 points of the maximum Z face, starting with maximum point of all, then anticlockwise around this face (looking onto the face from outside the box). Like this:
			       1-----2
			      /|    /|
			     / |   / |
			    5-----4  |
			    |  0--|--3
			    | /   | /
			    |/    |/
			    6-----7
			    

bool peon::AxisAlignedBox::isNull void   )  const [inline]
 

Returns true if the box is null i.e.

empty.

void peon::AxisAlignedBox::merge const AxisAlignedBox rhs  )  [inline]
 

Merges the passed in box into the current box.

The result is the box which encompasses both.

void peon::AxisAlignedBox::setNull  )  [inline]
 

Sets the box to a 'null' value i.e.

not a box.

void peon::AxisAlignedBox::transform const Matrix44 matrix  )  [inline]
 

Transforms the box according to the matrix supplied.

Remarks:
By calling this method you get the axis-aligned box which surrounds the transformed version of this box. Therefore each corner of the box is transformed by the matrix, then the extents are mapped back onto the axes to produce another AABB. Useful when you have a local AABB for an object which is then transformed.


The documentation for this class was generated from the following file:
Generated on Wed Nov 9 09:37:07 2005 for Peon by  doxygen 1.4.3