- Main Page
- Namespaces
- Classes
- Files
- Directories
- Related Pages

- Alphabetical List
- Class List
- Class Hierarchy
- Class Members

# Ogre::AxisAlignedBox Class Reference

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

`#include <OgreAxisAlignedBox.h>`

List of all members.

## Public Types
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
| AxisAlignedBox ()
| AxisAlignedBox (const AxisAlignedBox &rkBox)
| AxisAlignedBox (const Vector3 &min, const Vector3 &max)
| AxisAlignedBox (Real mx, Real my, Real mz, Real Mx, Real My, Real Mz)
AxisAlignedBox & | operator= (const AxisAlignedBox &rhs)
| ~AxisAlignedBox ()
const Vector3 & | getMinimum (void) const
| Gets the minimum corner of the box.
Vector3 & | getMinimum (void)
| Gets a modifiable version of the minimum corner of the box.
const Vector3 & | getMaximum (void) const
| Gets the maximum corner of the box.
Vector3 & | getMaximum (void)
| Gets a modifiable version of 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 | setMinimumX (Real x)
| Changes one of the components of the minimum corner of the box used to resize only one dimension of the box.
void | setMinimumY (Real y)
void | setMinimumZ (Real z)
void | setMaximum (const Vector3 &vec)
| Sets the maximum corner of the box.
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.
void | setMaximumY (Real y)
void | setMaximumZ (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 Vector3 * | getAllCorners (void) const
| Returns a pointer to an array of 8 corner points, useful for collision vs.
Vector3 | getCorner (CornerEnum cornerToGet) const
| gets the position of one of the corners
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 Matrix4 &matrix)
| Transforms the box according to the matrix supplied.
void | transformAffine (const Matrix4 &m)
| Transforms the box according to the affine 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 | isFinite (void) const
| Returns true if the box is finite.
void | setInfinite ()
| Sets the box to 'infinite'.
bool | isInfinite (void) const
| Returns true if the box is infinite.
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.
Vector3 | getSize (void) const
| Gets the size of the box.
Vector3 | getHalfSize (void) const
| Gets the half-size of the box.
bool | contains (const Vector3 &v) const
| Tests whether the given point contained by this box.
bool | contains (const AxisAlignedBox &other) const
| Tests whether another box contained by this box.
bool | operator== (const AxisAlignedBox &rhs) const
| Tests 2 boxes for equality.
bool | operator!= (const AxisAlignedBox &rhs) const
| Tests 2 boxes for inequality.
## Protected Types
enum | Extent { EXTENT_NULL, EXTENT_FINITE, EXTENT_INFINITE }
## Protected Attributes
Vector3 | mMinimum
Vector3 | mMaximum
Extent | mExtent
Vector3 * | mpCorners
## Friends
_OgreExport friend std::ostream & | operator<< (std::ostream &o, const 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.

Definition at line 49 of file OgreAxisAlignedBox.h.

## Member Enumeration Documentation

enum Ogre::AxisAlignedBox::Extent`[protected]`

Enumerator:

  EXTENT_NULL |
  EXTENT_FINITE |
  EXTENT_INFINITE |

Definition at line 52 of file OgreAxisAlignedBox.h.

enum Ogre::AxisAlignedBox::CornerEnum

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 |

Definition at line 75 of file OgreAxisAlignedBox.h.

## Constructor & Destructor Documentation

Ogre::AxisAlignedBox::AxisAlignedBox | ( |  | ) |

Definition at line 85 of file OgreAxisAlignedBox.h.

Ogre::AxisAlignedBox::AxisAlignedBox | ( | const AxisAlignedBox & | rkBox | ) |

Definition at line 93 of file OgreAxisAlignedBox.h.

References isInfinite(), isNull(), mMaximum, and mMinimum.

Ogre::AxisAlignedBox::AxisAlignedBox | ( | const Vector3 & | min,
|  | const Vector3 & | max |
| ) |  |  |

Definition at line 103 of file OgreAxisAlignedBox.h.

Ogre::AxisAlignedBox::AxisAlignedBox | ( | Real | mx,
|  | Real | my,
|  | Real | mz,
|  | Real | Mx,
|  | Real | My,
|  | Real | Mz |
| ) |  |  |

Definition at line 108 of file OgreAxisAlignedBox.h.

Ogre::AxisAlignedBox::~AxisAlignedBox | ( |  | ) |

Definition at line 128 of file OgreAxisAlignedBox.h.

## Member Function Documentation

AxisAlignedBox& Ogre::AxisAlignedBox::operator= | ( | const AxisAlignedBox & | rhs | ) |

Definition at line 115 of file OgreAxisAlignedBox.h.

References isInfinite(), isNull(), mMaximum, and mMinimum.

const Vector3& Ogre::AxisAlignedBox::getMinimum | ( | void |  | ) | const

Gets the minimum corner of the box.

Definition at line 137 of file OgreAxisAlignedBox.h.

Referenced by intersection().

Vector3& Ogre::AxisAlignedBox::getMinimum | ( | void |  | ) |

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

Definition at line 145 of file OgreAxisAlignedBox.h.

const Vector3& Ogre::AxisAlignedBox::getMaximum | ( | void |  | ) | const

Gets the maximum corner of the box.

Definition at line 152 of file OgreAxisAlignedBox.h.

Referenced by intersection().

Vector3& Ogre::AxisAlignedBox::getMaximum | ( | void |  | ) |

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

Definition at line 160 of file OgreAxisAlignedBox.h.

void Ogre::AxisAlignedBox::setMinimum | ( | const Vector3 & | vec | ) |

Sets the minimum corner of the box.

Definition at line 168 of file OgreAxisAlignedBox.h.

void Ogre::AxisAlignedBox::setMinimum | ( | Real | x,
|  | Real | y,
|  | Real | z |
| ) |  |  |

Definition at line 174 of file OgreAxisAlignedBox.h.

References Ogre::Vector3::x.

void Ogre::AxisAlignedBox::setMinimumX | ( | Real | x | ) |

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

Definition at line 185 of file OgreAxisAlignedBox.h.

void Ogre::AxisAlignedBox::setMinimumY | ( | Real | y | ) |

Definition at line 190 of file OgreAxisAlignedBox.h.

void Ogre::AxisAlignedBox::setMinimumZ | ( | Real | z | ) |

Definition at line 195 of file OgreAxisAlignedBox.h.

void Ogre::AxisAlignedBox::setMaximum | ( | const Vector3 & | vec | ) |

Sets the maximum corner of the box.

Definition at line 202 of file OgreAxisAlignedBox.h.

void Ogre::AxisAlignedBox::setMaximum | ( | Real | x,
|  | Real | y,
|  | Real | z |
| ) |  |  |

Definition at line 208 of file OgreAxisAlignedBox.h.

References Ogre::Vector3::x.

void Ogre::AxisAlignedBox::setMaximumX | ( | Real | x | ) |

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

Definition at line 219 of file OgreAxisAlignedBox.h.

void Ogre::AxisAlignedBox::setMaximumY | ( | Real | y | ) |

Definition at line 224 of file OgreAxisAlignedBox.h.

void Ogre::AxisAlignedBox::setMaximumZ | ( | Real | z | ) |

Definition at line 229 of file OgreAxisAlignedBox.h.

void Ogre::AxisAlignedBox::setExtents | ( | const Vector3 & | min,
|  | const Vector3 & | max |
| ) |  |  |

Sets both minimum and maximum extents at once.

Definition at line 236 of file OgreAxisAlignedBox.h.

References Ogre::Vector3::x, Ogre::Vector3::y, and Ogre::Vector3::z.

void Ogre::AxisAlignedBox::setExtents | ( | Real | mx,
|  | Real | my,
|  | Real | mz,
|  | Real | Mx,
|  | Real | My,
|  | Real | Mz |
| ) |  |  |

Definition at line 246 of file OgreAxisAlignedBox.h.

const Vector3* Ogre::AxisAlignedBox::getAllCorners | ( | void |  | ) | const

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 !

Definition at line 289 of file OgreAxisAlignedBox.h.

Vector3 Ogre::AxisAlignedBox::getCorner | ( | CornerEnum | cornerToGet | ) | const

gets the position of one of the corners

Definition at line 317 of file OgreAxisAlignedBox.h.

void Ogre::AxisAlignedBox::merge | ( | const AxisAlignedBox & | rhs | ) |

Merges the passed in box into the current box.

The result is the box which encompasses both.

Definition at line 367 of file OgreAxisAlignedBox.h.

References Ogre::Vector3::makeCeil(), Ogre::Vector3::makeFloor(), mExtent, mMaximum, and mMinimum.

Referenced by Ogre::VisibleObjectsBoundsInfo::merge().

void Ogre::AxisAlignedBox::merge | ( | const Vector3 & | point | ) |

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

Definition at line 399 of file OgreAxisAlignedBox.h.

void Ogre::AxisAlignedBox::transform | ( | const Matrix4 & | matrix | ) |

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.

Definition at line 428 of file OgreAxisAlignedBox.h.

References Ogre::Vector3::x, Ogre::Vector3::y, and Ogre::Vector3::z.

void Ogre::AxisAlignedBox::transformAffine | ( | const Matrix4 & | m | ) |

Transforms the box according to the affine 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.

Note:
  The matrix must be an affine matrix.

See also:
  Matrix4::isAffine.

Definition at line 495 of file OgreAxisAlignedBox.h.

References Ogre::Math::Abs(), Ogre::Matrix4::isAffine(), Ogre::Matrix4::transformAffine(), Ogre::Vector3::x, Ogre::Vector3::y, and Ogre::Vector3::z.

void Ogre::AxisAlignedBox::setNull | ( |  | ) |

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

not a box.

Definition at line 517 of file OgreAxisAlignedBox.h.

Referenced by Ogre::VisibleObjectsBoundsInfo::reset().

bool Ogre::AxisAlignedBox::isNull | ( | void |  | ) | const

Returns true if the box is null i.e.

empty.

Definition at line 524 of file OgreAxisAlignedBox.h.

Referenced by AxisAlignedBox(), contains(), intersection(), Ogre::PlaneBoundedVolume::intersects(), intersects(), and operator=().

bool Ogre::AxisAlignedBox::isFinite | ( | void |  | ) | const

Returns true if the box is finite.

Definition at line 531 of file OgreAxisAlignedBox.h.

void Ogre::AxisAlignedBox::setInfinite | ( |  | ) |

Sets the box to 'infinite'.

Definition at line 538 of file OgreAxisAlignedBox.h.

bool Ogre::AxisAlignedBox::isInfinite | ( | void |  | ) | const

Returns true if the box is infinite.

Definition at line 545 of file OgreAxisAlignedBox.h.

Referenced by AxisAlignedBox(), contains(), intersection(), Ogre::PlaneBoundedVolume::intersects(), intersects(), and operator=().

bool Ogre::AxisAlignedBox::intersects | ( | const AxisAlignedBox & | b2 | ) | const

Returns whether or not this box intersects another.

Definition at line 551 of file OgreAxisAlignedBox.h.

References isInfinite(), isNull(), mMaximum, mMinimum, Ogre::Vector3::x, Ogre::Vector3::y, and Ogre::Vector3::z.

AxisAlignedBox Ogre::AxisAlignedBox::intersection | ( | const AxisAlignedBox & | b2 | ) | const

Calculate the area of intersection of this box and another.

Definition at line 582 of file OgreAxisAlignedBox.h.

References getMaximum(), getMinimum(), isInfinite(), isNull(), Ogre::Vector3::makeCeil(), Ogre::Vector3::makeFloor(), Ogre::Vector3::x, Ogre::Vector3::y, and Ogre::Vector3::z.

Real Ogre::AxisAlignedBox::volume | ( | void |  | ) | const

Calculate the volume of this box.

Definition at line 615 of file OgreAxisAlignedBox.h.

References Ogre::Math::POS_INFINITY, Ogre::Vector3::x, Ogre::Vector3::y, and Ogre::Vector3::z.

void Ogre::AxisAlignedBox::scale | ( | const Vector3 & | s | ) |

Scales the AABB by the vector given.

Definition at line 638 of file OgreAxisAlignedBox.h.

bool Ogre::AxisAlignedBox::intersects | ( | const Sphere & | s | ) | const

Tests whether this box intersects a sphere.

Definition at line 651 of file OgreAxisAlignedBox.h.

References Ogre::Math::intersects().

bool Ogre::AxisAlignedBox::intersects | ( | const Plane & | p | ) | const

Tests whether this box intersects a plane.

Definition at line 656 of file OgreAxisAlignedBox.h.

References Ogre::Math::intersects().

bool Ogre::AxisAlignedBox::intersects | ( | const Vector3 & | v | ) | const

Tests whether the vector point is within this box.

Definition at line 661 of file OgreAxisAlignedBox.h.

References Ogre::Vector3::x, Ogre::Vector3::y, and Ogre::Vector3::z.

Vector3 Ogre::AxisAlignedBox::getCenter | ( | void |  | ) | const

Gets the centre of the box.

Definition at line 682 of file OgreAxisAlignedBox.h.

Referenced by Ogre::PlaneBoundedVolume::intersects().

Vector3 Ogre::AxisAlignedBox::getSize | ( | void |  | ) | const

Gets the size of the box.

Definition at line 692 of file OgreAxisAlignedBox.h.

References Ogre::Math::POS_INFINITY, and Ogre::Vector3::ZERO.

Vector3 Ogre::AxisAlignedBox::getHalfSize | ( | void |  | ) | const

Gets the half-size of the box.

Definition at line 714 of file OgreAxisAlignedBox.h.

References Ogre::Math::POS_INFINITY, and Ogre::Vector3::ZERO.

Referenced by Ogre::PlaneBoundedVolume::intersects().

bool Ogre::AxisAlignedBox::contains | ( | const Vector3 & | v | ) | const

Tests whether the given point contained by this box.

Definition at line 738 of file OgreAxisAlignedBox.h.

References Ogre::Vector3::x, Ogre::Vector3::y, and Ogre::Vector3::z.

bool Ogre::AxisAlignedBox::contains | ( | const AxisAlignedBox & | other | ) | const

Tests whether another box contained by this box.

Definition at line 752 of file OgreAxisAlignedBox.h.

References isInfinite(), isNull(), mMaximum, mMinimum, Ogre::Vector3::x, Ogre::Vector3::y, and Ogre::Vector3::z.

bool Ogre::AxisAlignedBox::operator== | ( | const AxisAlignedBox & | rhs | ) | const

Tests 2 boxes for equality.

Definition at line 770 of file OgreAxisAlignedBox.h.

References mExtent, mMaximum, and mMinimum.

bool Ogre::AxisAlignedBox::operator!= | ( | const AxisAlignedBox & | rhs | ) | const

Tests 2 boxes for inequality.

Definition at line 784 of file OgreAxisAlignedBox.h.

## Friends And Related Function Documentation

_OgreExport friend std::ostream& operator<< | ( | std::ostream & | o,
|  | const AxisAlignedBox | aab |
| ) |  |  | `[friend]`

Definition at line 342 of file OgreAxisAlignedBox.h.

## Member Data Documentation

Vector3 Ogre::AxisAlignedBox::mMinimum`[protected]`

Definition at line 59 of file OgreAxisAlignedBox.h.

Referenced by AxisAlignedBox(), contains(), intersects(), merge(), operator=(), and operator==().

Vector3 Ogre::AxisAlignedBox::mMaximum`[protected]`

Definition at line 60 of file OgreAxisAlignedBox.h.

Referenced by AxisAlignedBox(), contains(), intersects(), merge(), operator=(), and operator==().

Extent Ogre::AxisAlignedBox::mExtent`[protected]`

Definition at line 61 of file OgreAxisAlignedBox.h.

Referenced by merge(), and operator==().

Vector3* Ogre::AxisAlignedBox::mpCorners`[mutable, protected]`

Definition at line 62 of file OgreAxisAlignedBox.h.

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

- OgreAxisAlignedBox.h

Copyright © 2000-2005 by The OGRE Team
This work is licensed under a Creative Commons Attribution-ShareAlike 2.5 License.
Last modified Mon Jun 16 12:49:09 2008