omegalib  13.1
omicron::AlignedBox3 Class Reference

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

#include <AlignedBox.h>

Public Types

enum  Extent { EXTENT_NULL, EXTENT_FINITE, EXTENT_INFINITE }
 
enum  CornerEnum {
  FAR_LEFT_BOTTOM = 0, FAR_LEFT_TOP = 1, FAR_RIGHT_TOP = 2, FAR_RIGHT_BOTTOM = 3,
  NEAR_RIGHT_BOTTOM = 7, NEAR_LEFT_BOTTOM = 6, NEAR_LEFT_TOP = 5, NEAR_RIGHT_TOP = 4
}
 

Public Member Functions

 AlignedBox3 ()
 
 AlignedBox3 (Extent e)
 
 AlignedBox3 (const AlignedBox3 &rkBox)
 
 AlignedBox3 (const Vector3f &min, const Vector3f &max)
 
 AlignedBox3 (float mx, float my, float mz, float Mx, float My, float Mz)
 
AlignedBox3operator= (const AlignedBox3 &rhs)
 
 ~AlignedBox3 ()
 
const Vector3fgetMinimum (void) const
 Gets the minimum corner of the box. More...
 
Vector3fgetMinimum (void)
 Gets a modifiable version of the minimum corner of the box. More...
 
const Vector3fgetMaximum (void) const
 Gets the maximum corner of the box. More...
 
Vector3fgetMaximum (void)
 Gets a modifiable version of the maximum corner of the box. More...
 
void setMinimum (const Vector3f &vec)
 Sets the minimum corner of the box. More...
 
void setMinimum (real x, real y, real z)
 
void setMinimumX (real x)
 Changes one of the components of the minimum corner of the box used to resize only one dimension of the box. More...
 
void setMinimumY (real y)
 
void setMinimumZ (real z)
 
void setMaximum (const Vector3f &vec)
 Sets the maximum corner of the box. More...
 
void setMaximum (real x, real y, real z)
 
void setMaximumX (real x)
 Changes one of the components of the maximum corner of the box used to resize only one dimension of the box. More...
 
void setMaximumY (real y)
 
void setMaximumZ (real z)
 
void setExtents (const Vector3f &min, const Vector3f &max)
 Sets both minimum and maximum extents at once. More...
 
void setExtents (real mx, real my, real mz, real Mx, real My, real Mz)
 
const Vector3fgetAllCorners (void) const
 Returns a pointer to an array of 8 corner points, useful for collision vs. More...
 
Vector3f getCorner (CornerEnum cornerToGet) const
 gets the position of one of the corners More...
 
void merge (const AlignedBox3 &rhs)
 Merges the passed in box into the current box. More...
 
void merge (const Vector3f &point)
 Extends the box to encompass the specified point (if needed). More...
 
void transformAffine (const AffineTransform3 &tf)
 Transforms the box according to the matrix supplied. More...
 
void setNull ()
 Sets the box to a 'null' value i.e. More...
 
bool isNull (void) const
 Returns true if the box is null i.e. More...
 
bool isFinite (void) const
 Returns true if the box is finite. More...
 
void setInfinite ()
 Sets the box to 'infinite'. More...
 
bool isInfinite (void) const
 Returns true if the box is infinite. More...
 
bool intersects (const AlignedBox3 &b2) const
 Returns whether or not this box intersects another. More...
 
AlignedBox3 intersection (const AlignedBox3 &b2) const
 Calculate the area of intersection of this box and another. More...
 
float volume (void) const
 Calculate the volume of this box. More...
 
void scale (const Vector3f &s)
 Scales the AABB by the vector given. More...
 
bool intersects (const Sphere &s) const
 Tests whether this box intersects a sphere. More...
 
bool intersects (const Plane &p) const
 Tests whether this box intersects a plane. More...
 
bool intersects (const Vector3f &v) const
 Tests whether the vector point is within this box. More...
 
Vector3f getCenter (void) const
 Gets the centre of the box. More...
 
Vector3f getSize (void) const
 Gets the size of the box. More...
 
Vector3f getHalfSize (void) const
 Gets the half-size of the box. More...
 
bool contains (const Vector3f &v) const
 Tests whether the given point contained by this box. More...
 
bool contains (const AlignedBox3 &other) const
 Tests whether another box contained by this box. More...
 
bool operator== (const AlignedBox3 &rhs) const
 Tests 2 boxes for equality. More...
 
bool operator!= (const AlignedBox3 &rhs) const
 Tests 2 boxes for inequality. More...
 
Vector3foperator[] (const size_t i)
 
const Vector3foperator[] (const size_t i) const
 

Static Public Attributes

static const AlignedBox3 BOX_NULL
 
static const AlignedBox3 BOX_INFINITE
 

Protected Attributes

Vector3f mMinimum
 
Vector3f mMaximum
 
Extent mExtent
 
Vector3fmpCorners
 

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 Enumeration Documentation

Enumerator
FAR_LEFT_BOTTOM 
FAR_LEFT_TOP 
FAR_RIGHT_TOP 
FAR_RIGHT_BOTTOM 
NEAR_RIGHT_BOTTOM 
NEAR_LEFT_BOTTOM 
NEAR_LEFT_TOP 
NEAR_RIGHT_TOP 
Enumerator
EXTENT_NULL 
EXTENT_FINITE 
EXTENT_INFINITE 

Constructor & Destructor Documentation

omicron::AlignedBox3::AlignedBox3 ( )
inline
omicron::AlignedBox3::AlignedBox3 ( Extent  e)
inline
omicron::AlignedBox3::AlignedBox3 ( const AlignedBox3 rkBox)
inline
omicron::AlignedBox3::AlignedBox3 ( const Vector3f min,
const Vector3f max 
)
inline
omicron::AlignedBox3::AlignedBox3 ( float  mx,
float  my,
float  mz,
float  Mx,
float  My,
float  Mz 
)
inline
omicron::AlignedBox3::~AlignedBox3 ( )
inline

Member Function Documentation

bool omicron::AlignedBox3::contains ( const Vector3f v) const
inline

Tests whether the given point contained by this box.

bool omicron::AlignedBox3::contains ( const AlignedBox3 other) const
inline

Tests whether another box contained by this box.

const Vector3f* omicron::AlignedBox3::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
as this implementation uses a static member, make sure to use your own copy !
Vector3f omicron::AlignedBox3::getCenter ( void  ) const
inline

Gets the centre of the box.

Vector3f omicron::AlignedBox3::getCorner ( CornerEnum  cornerToGet) const
inline

gets the position of one of the corners

Vector3f omicron::AlignedBox3::getHalfSize ( void  ) const
inline

Gets the half-size of the box.

const Vector3f& omicron::AlignedBox3::getMaximum ( void  ) const
inline

Gets the maximum corner of the box.

Vector3f& omicron::AlignedBox3::getMaximum ( void  )
inline

Gets a modifiable version of the maximum corner of the box.

const Vector3f& omicron::AlignedBox3::getMinimum ( void  ) const
inline

Gets the minimum corner of the box.

Vector3f& omicron::AlignedBox3::getMinimum ( void  )
inline

Gets a modifiable version of the minimum corner of the box.

Vector3f omicron::AlignedBox3::getSize ( void  ) const
inline

Gets the size of the box.

AlignedBox3 omicron::AlignedBox3::intersection ( const AlignedBox3 b2) const
inline

Calculate the area of intersection of this box and another.

bool omicron::AlignedBox3::intersects ( const AlignedBox3 b2) const
inline

Returns whether or not this box intersects another.

bool omicron::AlignedBox3::intersects ( const Sphere s) const
inline

Tests whether this box intersects a sphere.

bool omicron::AlignedBox3::intersects ( const Plane p) const
inline

Tests whether this box intersects a plane.

bool omicron::AlignedBox3::intersects ( const Vector3f v) const
inline

Tests whether the vector point is within this box.

bool omicron::AlignedBox3::isFinite ( void  ) const
inline

Returns true if the box is finite.

bool omicron::AlignedBox3::isInfinite ( void  ) const
inline

Returns true if the box is infinite.

bool omicron::AlignedBox3::isNull ( void  ) const
inline

Returns true if the box is null i.e.

empty.

void omicron::AlignedBox3::merge ( const AlignedBox3 rhs)
inline

Merges the passed in box into the current box.

The result is the box which encompasses both.

void omicron::AlignedBox3::merge ( const Vector3f point)
inline

Extends the box to encompass the specified point (if needed).

bool omicron::AlignedBox3::operator!= ( const AlignedBox3 rhs) const
inline

Tests 2 boxes for inequality.

AlignedBox3& omicron::AlignedBox3::operator= ( const AlignedBox3 rhs)
inline
bool omicron::AlignedBox3::operator== ( const AlignedBox3 rhs) const
inline

Tests 2 boxes for equality.

Vector3f& omicron::AlignedBox3::operator[] ( const size_t  i)
inline
const Vector3f& omicron::AlignedBox3::operator[] ( const size_t  i) const
inline
void omicron::AlignedBox3::scale ( const Vector3f s)
inline

Scales the AABB by the vector given.

void omicron::AlignedBox3::setExtents ( const Vector3f min,
const Vector3f max 
)
inline

Sets both minimum and maximum extents at once.

void omicron::AlignedBox3::setExtents ( real  mx,
real  my,
real  mz,
real  Mx,
real  My,
real  Mz 
)
inline
void omicron::AlignedBox3::setInfinite ( )
inline

Sets the box to 'infinite'.

void omicron::AlignedBox3::setMaximum ( const Vector3f vec)
inline

Sets the maximum corner of the box.

void omicron::AlignedBox3::setMaximum ( real  x,
real  y,
real  z 
)
inline
void omicron::AlignedBox3::setMaximumX ( real  x)
inline

Changes one of the components of the maximum corner of the box used to resize only one dimension of the box.

void omicron::AlignedBox3::setMaximumY ( real  y)
inline
void omicron::AlignedBox3::setMaximumZ ( real  z)
inline
void omicron::AlignedBox3::setMinimum ( const Vector3f vec)
inline

Sets the minimum corner of the box.

void omicron::AlignedBox3::setMinimum ( real  x,
real  y,
real  z 
)
inline
void omicron::AlignedBox3::setMinimumX ( real  x)
inline

Changes one of the components of the minimum corner of the box used to resize only one dimension of the box.

void omicron::AlignedBox3::setMinimumY ( real  y)
inline
void omicron::AlignedBox3::setMinimumZ ( real  z)
inline
void omicron::AlignedBox3::setNull ( )
inline

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

not a box.

void omicron::AlignedBox3::transformAffine ( const AffineTransform3 tf)
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. Transforms the box according to the affine matrix supplied.
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.
Note
The matrix must be an affine matrix.
See also
Matrix4f::isAffine.
float omicron::AlignedBox3::volume ( void  ) const
inline

Calculate the volume of this box.

Member Data Documentation

const AlignedBox3 omicron::AlignedBox3::BOX_INFINITE
static
const AlignedBox3 omicron::AlignedBox3::BOX_NULL
static
Extent omicron::AlignedBox3::mExtent
protected
Vector3f omicron::AlignedBox3::mMaximum
protected
Vector3f omicron::AlignedBox3::mMinimum
protected
Vector3f* omicron::AlignedBox3::mpCorners
mutableprotected

The documentation for this class was generated from the following file: