![]() |
OGRE 14.3
Object-Oriented Graphics Rendering Engine
|
A 3D box aligned with the x/y/z axes. More...
#include <OgreAxisAlignedBox.h>
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 } |
typedef std::array< Vector3, 8 > | Corners |
enum | Extent { EXTENT_NULL , EXTENT_FINITE , EXTENT_INFINITE } |
Public Member Functions | |
AxisAlignedBox () | |
AxisAlignedBox (const Vector3 &min, const Vector3 &max) | |
AxisAlignedBox (Extent e) | |
AxisAlignedBox (Real mx, Real my, Real mz, Real Mx, Real My, Real Mz) | |
bool | contains (const AxisAlignedBox &other) const |
Tests whether another box contained by this box. | |
bool | contains (const Vector3 &v) const |
Tests whether the given point contained by this box. | |
Real | distance (const Vector3 &v) const |
Returns the minimum distance between a given point and any part of the box. | |
Corners | getAllCorners (void) const |
Returns a pointer to an array of 8 corner points, useful for collision vs. | |
Vector3 | getCenter (void) const |
Gets the centre of the box. | |
Vector3 | getCorner (CornerEnum cornerToGet) const |
Gets the position of one of the corners. | |
Vector3 | getHalfSize (void) const |
Gets the half-size of the box. | |
Vector3 & | getMaximum (void) |
Gets a modifiable version of the maximum corner of the box. | |
const Vector3 & | getMaximum (void) const |
Gets the maximum corner of the box. | |
Vector3 & | getMinimum (void) |
Gets a modifiable version of the minimum corner of the box. | |
const Vector3 & | getMinimum (void) const |
Gets the minimum corner of the box. | |
Vector3 | getSize (void) const |
Gets the size of the box. | |
AxisAlignedBox | intersection (const AxisAlignedBox &b2) const |
Calculate the area of intersection of this box and another. | |
bool | intersects (const AxisAlignedBox &b2) const |
Returns whether or not this box intersects another. | |
bool | intersects (const Plane &p) const |
Tests whether this box intersects a plane. | |
bool | intersects (const Sphere &s) const |
Tests whether this box intersects a sphere. | |
bool | intersects (const Vector3 &v) const |
Tests whether the vector point is within this box. | |
bool | isFinite (void) const |
Returns true if the box is finite. | |
bool | isInfinite (void) const |
Returns true if the box is infinite. | |
bool | isNull (void) const |
Returns true if the box is null i.e. | |
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). | |
bool | operator!= (const AxisAlignedBox &rhs) const |
Tests 2 boxes for inequality. | |
bool | operator== (const AxisAlignedBox &rhs) const |
Tests 2 boxes for equality. | |
void | scale (const Vector3 &s) |
Scales the AABB by the vector given. | |
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) |
void | setInfinite () |
Sets the box to 'infinite'. | |
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 | 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 | setNull () |
Sets the box to a 'null' value i.e. | |
Real | squaredDistance (const Vector3 &v) const |
Returns the squared minimum distance between a given point and any part of the box. | |
void | transform (const Affine3 &m) |
Transforms the box according to the affine matrix supplied. | |
void | transform (const Matrix4 &matrix) |
Transforms the box according to the matrix supplied. | |
Real | volume (void) const |
Calculate the volume of this box. | |
Static Public Attributes | |
static const AxisAlignedBox | BOX_INFINITE |
static const AxisAlignedBox | BOX_NULL |
A 3D box aligned with the x/y/z axes.
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.
typedef std::array<Vector3, 8> Ogre::AxisAlignedBox::Corners |
|
inline |
References EXTENT_NULL, setMaximum(), and setMinimum().
Referenced by contains(), intersection(), intersects(), merge(), operator!=(), operator<<, and operator==().
|
inline |
References setMaximum(), and setMinimum().
References setExtents().
|
inline |
References setExtents().
|
inline |
Gets the minimum corner of the box.
Referenced by intersection().
|
inline |
Gets a modifiable version of the minimum corner of the box.
|
inline |
Gets the maximum corner of the box.
Referenced by intersection().
|
inline |
Gets a modifiable version of the maximum corner of the box.
|
inline |
Sets the minimum corner of the box.
References EXTENT_FINITE.
Referenced by AxisAlignedBox(), and AxisAlignedBox().
References EXTENT_FINITE.
|
inline |
Changes one of the components of the minimum corner of the box used to resize only one dimension of the box.
|
inline |
|
inline |
|
inline |
Sets the maximum corner of the box.
References EXTENT_FINITE.
Referenced by AxisAlignedBox(), and AxisAlignedBox().
References EXTENT_FINITE.
|
inline |
Changes one of the components of the maximum corner of the box used to resize only one dimension of the box.
|
inline |
|
inline |
Sets both minimum and maximum extents at once.
References EXTENT_FINITE.
Referenced by AxisAlignedBox(), AxisAlignedBox(), merge(), merge(), scale(), and transform().
|
inline |
References EXTENT_FINITE.
|
inline |
Returns a pointer to an array of 8 corner points, useful for collision vs.
non-aligned objects.
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
References EXTENT_FINITE, FAR_LEFT_BOTTOM, FAR_LEFT_TOP, FAR_RIGHT_BOTTOM, FAR_RIGHT_TOP, getCorner(), NEAR_LEFT_BOTTOM, NEAR_LEFT_TOP, NEAR_RIGHT_BOTTOM, and NEAR_RIGHT_TOP.
|
inline |
Gets the position of one of the corners.
References FAR_LEFT_BOTTOM, FAR_LEFT_TOP, FAR_RIGHT_BOTTOM, FAR_RIGHT_TOP, NEAR_LEFT_BOTTOM, NEAR_LEFT_TOP, NEAR_RIGHT_BOTTOM, and NEAR_RIGHT_TOP.
Referenced by getAllCorners().
|
inline |
Merges the passed in box into the current box.
The result is the box which encompasses both.
References AxisAlignedBox(), EXTENT_INFINITE, EXTENT_NULL, Ogre::Vector< dims, T >::makeCeil(), Ogre::Vector< dims, T >::makeFloor(), and setExtents().
Referenced by transform().
|
inline |
Extends the box to encompass the specified point (if needed).
References EXTENT_FINITE, EXTENT_INFINITE, EXTENT_NULL, and setExtents().
|
inline |
Transforms the box according to the 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.
References EXTENT_FINITE, merge(), and setNull().
|
inline |
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.
References Ogre::Math::Abs(), EXTENT_FINITE, getCenter(), getHalfSize(), and setExtents().
|
inline |
|
inline |
Returns true if the box is null i.e.
empty.
References EXTENT_NULL.
Referenced by contains(), contains(), Ogre::Plane::getSide(), intersection(), intersects(), and Ogre::PlaneBoundedVolume::intersects().
|
inline |
|
inline |
Sets the box to 'infinite'.
References EXTENT_INFINITE.
|
inline |
Returns true if the box is infinite.
References EXTENT_INFINITE.
Referenced by contains(), contains(), Ogre::Plane::getSide(), intersection(), intersects(), and Ogre::PlaneBoundedVolume::intersects().
|
inline |
Returns whether or not this box intersects another.
References AxisAlignedBox(), isInfinite(), and isNull().
|
inline |
Calculate the area of intersection of this box and another.
References AxisAlignedBox(), getMaximum(), getMinimum(), isInfinite(), isNull(), Ogre::Vector< dims, T >::makeCeil(), and Ogre::Vector< dims, T >::makeFloor().
|
inline |
Calculate the volume of this box.
References EXTENT_FINITE, EXTENT_INFINITE, EXTENT_NULL, and Ogre::Math::POS_INFINITY.
|
inline |
Scales the AABB by the vector given.
References EXTENT_FINITE, and setExtents().
|
inline |
Tests whether this box intersects a sphere.
References Ogre::Math::intersects().
|
inline |
Tests whether this box intersects a plane.
References Ogre::Math::intersects().
|
inline |
Tests whether the vector point is within this box.
References EXTENT_FINITE, EXTENT_INFINITE, and EXTENT_NULL.
|
inline |
Gets the centre of the box.
References EXTENT_FINITE.
Referenced by Ogre::Plane::getSide(), Ogre::PlaneBoundedVolume::intersects(), and transform().
|
inline |
Gets the size of the box.
References EXTENT_FINITE, EXTENT_INFINITE, EXTENT_NULL, and Ogre::Math::POS_INFINITY.
|
inline |
Gets the half-size of the box.
References EXTENT_FINITE, EXTENT_INFINITE, EXTENT_NULL, and Ogre::Math::POS_INFINITY.
Referenced by Ogre::Plane::getSide(), Ogre::PlaneBoundedVolume::intersects(), and transform().
|
inline |
Tests whether the given point contained by this box.
References isInfinite(), and isNull().
Referenced by squaredDistance().
Returns the squared minimum distance between a given point and any part of the box.
This is faster than distance since avoiding a squareroot, so use if you can.
References contains(), and Ogre::Vector< dims, T >::squaredLength().
Referenced by distance().
Returns the minimum distance between a given point and any part of the box.
References Ogre::Math::Sqrt(), and squaredDistance().
|
inline |
Tests whether another box contained by this box.
References AxisAlignedBox(), isInfinite(), and isNull().
|
inline |
Tests 2 boxes for equality.
References AxisAlignedBox(), and isFinite().
|
inline |
Tests 2 boxes for inequality.
References AxisAlignedBox().
|
static |
Referenced by Ogre::MovablePlane::getBoundingBox().
|
static |