Public Member Functions | Static Public Member Functions | Public Attributes

Box Class Reference

Defines an AABB (Axis Aligned Bounding Box). More...

Inheritance diagram for Box:
OBB

List of all members.

Public Member Functions

ozinline Box ()
 Constructs an uninitalized box.
ozinline Box (const Vec3f &_center, const Vec3f &_extent)
 Constructs an initalized box.
 ~Box ()
 Destructs this box instance.
ozinline void setFromPoints (const Vec3f &_pt0, const Vec3f &_pt1)
 Build an AABB from two points.
ozinline Vec3f getMin () const
 Gets the minimum corner of this box.
ozinline Vec3f getMax () const
 Gets the maximum corner of this box.
ozinline void getMinMax (Vec3f &_min, Vec3f &_max) const
 Gets the minimal and maximal point of this box.
ozinline bool isOverlap (const Box &_box) const
 Tests if that box overlaps with one another.
ozinline bool isOverlapOnX (const Box &_box) const
 Same than is isOverlap() method but only occurs on X axis.
ozinline bool isOverlapOnY (const Box &_box) const
 Same than is isOverlap() method but only occurs on Y axis.
ozinline bool isOverlapOnZ (const Box &_box) const
 Same than is isOverlap() method but only occurs on Z axis.
ozinline bool isInside (const Box &_box) const
 Tests if one box is fully inside one another.
ozinline bool isInside (const Vec3f &_pt) const
 Tests if point is inside this box.
ozinline float getMinExtent () const
 Gets the smallest extension of that box.
ozinline float getMaxExtent () const
 Gets the highest extension of that box.
ozinline float ext (int i) const
 Returns the extension of the box on X, Y or Z axis.
ozinline Vec3f getPoint (int _index) const
 Returns a point of the cube.
ozinline Plane getPlane (PLANE _which) const
 Gets the plane of one face of the cube.
ozinline BoxEdge getEdge (int _index) const
 Returns an edge of the cube given its index.

Static Public Member Functions

static ozinline Vec3f getVertexNormal (int _index)
 Gets the normal of the cube given its point index.
static ozinline Vec3f getFaceNormal (PLANE _which)
 Returns a face normal of the cube.

Public Attributes

Vec3f center
 The center of the box.
Vec3f extent
 The extent of the box.

Detailed Description

Defines an AABB (Axis Aligned Bounding Box).

An AABB is an Axis Aligned Bounding Box, in the opposite of an OBB that is oriented (Oriented Bounding Box). Typicaly you just have one size for each axis.


Constructor & Destructor Documentation

ozinline Box::Box (  )  [inline]

Constructs an uninitalized box.

ozinline Box::Box ( const Vec3f _center,
const Vec3f _extent 
) [inline]

Constructs an initalized box.

Parameters:
_center The center of the box.
_extent The extent of the box for each axis.
Box::~Box (  )  [inline]

Destructs this box instance.


Member Function Documentation

ozinline float Box::ext ( int  i  )  const [inline]

Returns the extension of the box on X, Y or Z axis.

Parameters:
i The index of the axis. 0 for X, 1 for Y, 2 for Z. If index are not in the valid range [0, 2], Z extension is returned by default.
Returns:
The extension of the asked axis.
ozinline BoxEdge Box::getEdge ( int  _index  )  const [inline]

Returns an edge of the cube given its index.

A box is made of many edges (12 in total). This method allows you to get an edge of the box.

Parameters:
_index The index of the edge (from 0 to 11). If the index is not in the valid range, a 0 BoxEdge is returned.
Returns:
An instance of BoxEdge.
static ozinline Vec3f Box::getFaceNormal ( PLANE  _which  )  [inline, static]

Returns a face normal of the cube.

A box is made of 6 faces. This method allows you to get the normal of each of these faces.

Parameters:
_which The index of the vertex to get the normal from (from 0 to 5). If the index is not in the valid range, 0 is returned.
Returns:
The normal of the face. The normal is normalized.
ozinline Vec3f Box::getMax (  )  const [inline]

Gets the maximum corner of this box.

Returns:
The maximum corner box.
ozinline float Box::getMaxExtent (  )  const [inline]

Gets the highest extension of that box.

It means the axis that has the highest amplitude on X, Y, or Z.

Returns:
The highest extension, it can be the X, Y, or Z axis.
ozinline Vec3f Box::getMin (  )  const [inline]

Gets the minimum corner of this box.

Returns:
The minimum corner box.
ozinline float Box::getMinExtent (  )  const [inline]

Gets the smallest extension of that box.

It means the axis that has the smallest amplitude on X, Y, or Z.

Returns:
The smallest extension, it can be the X, Y, or Z axis.
ozinline void Box::getMinMax ( Vec3f _min,
Vec3f _max 
) const [inline]

Gets the minimal and maximal point of this box.

Parameters:
_min Will contain th minimal point of this box.
_max Will contain th maximal point of this box.
ozinline Plane Box::getPlane ( PLANE  _which  )  const [inline]

Gets the plane of one face of the cube.

A box is made of 6 faces. This method allows you to get a Plane instance of each of these faces.

Parameters:
_which The index of the face to get the plane from (from 0 to 5). If the index is not in the valid range, a 0 plane is returned.
Returns:
The plane of the face. The plane is normalized.
ozinline Vec3f Box::getPoint ( int  _index  )  const [inline]

Returns a point of the cube.

A cube is made of 8 points. This method allow you to return the required point.

Parameters:
_index The index of the point from 0 to 7. If _index is not in the valid range, 0 is returned.
Returns:
The point.
static ozinline Vec3f Box::getVertexNormal ( int  _index  )  [inline, static]

Gets the normal of the cube given its point index.

A box is made of 8 points. This method allows you to get the normal of each of these points.

Parameters:
_index The index of the vertex to get the normal from (from 0 to 7). If the index is not in the valid range, 0 vector is returned.
Returns:
The normal of the vertex. The normal is normalized.
ozinline bool Box::isInside ( const Box _box  )  const [inline]

Tests if one box is fully inside one another.

Parameters:
_box The box to test with.
Returns:
true if _box is fully inside this box, false otherwhise.
ozinline bool Box::isInside ( const Vec3f _pt  )  const [inline]

Tests if point is inside this box.

Parameters:
_pt The point to test.
Returns:
true if the point is inside this this box, false otherwhise.
ozinline bool Box::isOverlap ( const Box _box  )  const [inline]

Tests if that box overlaps with one another.

Parameters:
_box The other box to test with.
Returns:
true if this box overlaps with _box, false otherwhise.
ozinline bool Box::isOverlapOnX ( const Box _box  )  const [inline]

Same than is isOverlap() method but only occurs on X axis.

Parameters:
_box The other box to test with.
Returns:
true if this box overlaps with _box, false otherwhise.
ozinline bool Box::isOverlapOnY ( const Box _box  )  const [inline]

Same than is isOverlap() method but only occurs on Y axis.

Parameters:
_box The other box to test with.
Returns:
true if this box overlaps with _box, false otherwhise.
ozinline bool Box::isOverlapOnZ ( const Box _box  )  const [inline]

Same than is isOverlap() method but only occurs on Z axis.

Parameters:
_box The other box to test with.
Returns:
true if this box overlaps with _box, false otherwhise.
ozinline void Box::setFromPoints ( const Vec3f _pt0,
const Vec3f _pt1 
) [inline]

Build an AABB from two points.

Parameters:
_pt0 The first point.
_pt1 The second point.

Member Data Documentation

The center of the box.

The extent of the box.


The documentation for this class was generated from the following file:
 All Classes Files Functions Variables Enumerations Enumerator