TalanSoft Toolkits  201707
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
Public Member Functions | Static Public Member Functions | Protected Attributes | List of all members
cAABB< T > Class Template Reference
Inheritance diagram for cAABB< T >:
cBoundingVolumeAABB

Detailed Description

template<class T>
class ni::cAABB< T >

Axis aligned bounding box template class interface.

vertex[x]
    \                                    Y+    Z+
     7 <===  size  ===> 6 (max)          |    /
      *===============*                  |   /
     /|              /|                  |  /
    / |             / |                  | /
 4 /  |          5 /  |                  |/
  *===+===========*   |        ==========+========== X+
  |   |           |   |                 /|
  |   |           |   |                / |
  | 3 *===========+===* 2             /  |
  |  /            |  /               /   |
  | /             | /               /    |
  |/              |/
  *===============*
 0 (min)        1
  Vertices :
  0 = bottom left front (min)
  1 = bottom right front
  2 = bottom right back
  3 = bottom left back
  4 = top left front
  5 = top right front
  6 = top right back
  7 = top left back
  Faces (CW, facing outside) - so that texcoo(0,0 - 1,1) are mapped directly (for a cube) :
  PositiveX = 5,6,2,1
  NegativeX = 7,3,0,4
  PositiveY = 7,6,5,4
  NegativeY = 0,1,2,3
  PositiveZ = 6,7,3,2
  NegativeZ = 4,5,1,0
  Faces (CCW, facing inside) - so that texcoo(0,0 - 1,1) are mapped directly (for a cubemap) :
  PositiveX = 6,5,1,2
  NegativeX = 4,7,3,0
  PositiveY = 4,5,6,7
  NegativeY = 3,2,1,0
  PositiveZ = 7,6,2,3
  NegativeZ = 5,4,0,1
  

Public Member Functions

 cAABB ()
 
 cAABB (const sVec3< T > &min, const sVec3< T > &max)
 
 cAABB (const sVec3< T > &center, T afRadius)
 
 ~cAABB ()
 
void ZeroMembers ()
 
const sVec3< T > & GetMin () const
 
const sVec3< T > & GetMax () const
 
const T GetXSize () const
 
const T GetYSize () const
 
const T GetZSize () const
 
const T GetMaxSize () const
 
const T GetRadius () const
 
sVec3< T > GetSize () const
 
sVec3< T > GetExtents () const
 
sVec3< T > GetCenter () const
 
GetAverageExtent () const
 
void Set (const sVec3< T > &min, const sVec3< T > &max)
 
void SetMin (const sVec3< T > &min)
 
void SetMax (const sVec3< T > &max)
 
void SetCenterSize (const sVec3< T > &center, T size)
 
void SetCenterSize (const sVec3< T > &center, const sVec3< T > &size)
 
void SetCenterExtents (const sVec3< T > &center, T size)
 
void SetCenterExtents (const sVec3< T > &center, const sVec3< T > &size)
 
tBool Intersect (const sVec3< T > &p, T epsilon=niEpsilon5) const
 
tBool Intersect (const cAABB< T > &aabb, T epsilon=niEpsilon5) const
 
tBool Intersect (const sVec3< T > &min, const sVec3< T > &max, T epsilon=niEpsilon5) const
 
tBool IntersectRay (const sVec3< T > &avRayPos, const sVec3< T > &avRayDir, sVec3< T > *pOut=NULL, T epsilon=niEpsilon5) const
 
void Reset ()
 Bounding box computing helper. More...
 
void SetPoint (const sVec3< T > &p)
 
void Inflate (T percent)
 Inflate the bounding box of the given percent (1.0 == 100%). More...
 
void Extend (const sVec3< T > &v)
 Extend the bounding box of the given vector. More...
 
void Translate (const sVec3< T > &vVec)
 Translate the AABB. More...
 
void Rotate (const sMatrix< T > &aMtx)
 Rotate/Scale the AABB. More...
 
void Transform (const sMatrix< T > &aMtx)
 Transform the AABB. More...
 
void GetVertices (tPtr pVerts, tU32 aulPosOffset, tU32 aulStride) const
 Get the AABB vertices. More...
 
void GetFacesPlanes (sVec4< T > *pPlanes, bool bOutward) const
 Get the AABB faces planes. More...
 

Static Public Member Functions

static tBool Intersect (const sVec3< T > &mina, const sVec3< T > &maxa, const sVec3< T > &minb, const sVec3< T > &maxb, T epsilon=niEpsilon5)
 
static void GetTrianglesIndices (tU32 *pIndices, bool bCW)
 Get triangles indices. More...
 
static void GetLinesIndices (tU32 *pIndices)
 Get lines indices. To draw the AABB borders by example. More...
 

Protected Attributes

sVec3< T > mvMin
 
sVec3< T > mvMax
 

Constructor & Destructor Documentation

cAABB ( )
cAABB ( const sVec3< T > &  min,
const sVec3< T > &  max 
)
cAABB ( const sVec3< T > &  center,
afRadius 
)
~cAABB ( )

Member Function Documentation

void ZeroMembers ( )
const sVec3<T>& GetMin ( ) const
const sVec3<T>& GetMax ( ) const
const T GetXSize ( ) const
const T GetYSize ( ) const
const T GetZSize ( ) const
const T GetMaxSize ( ) const
const T GetRadius ( ) const
sVec3<T> GetSize ( ) const
sVec3<T> GetExtents ( ) const
sVec3<T> GetCenter ( ) const
T GetAverageExtent ( ) const
void Set ( const sVec3< T > &  min,
const sVec3< T > &  max 
)
void SetMin ( const sVec3< T > &  min)
void SetMax ( const sVec3< T > &  max)
void SetCenterSize ( const sVec3< T > &  center,
size 
)
void SetCenterSize ( const sVec3< T > &  center,
const sVec3< T > &  size 
)
void SetCenterExtents ( const sVec3< T > &  center,
size 
)
void SetCenterExtents ( const sVec3< T > &  center,
const sVec3< T > &  size 
)
tBool Intersect ( const sVec3< T > &  p,
epsilon = niEpsilon5 
) const
tBool Intersect ( const cAABB< T > &  aabb,
epsilon = niEpsilon5 
) const
tBool Intersect ( const sVec3< T > &  min,
const sVec3< T > &  max,
epsilon = niEpsilon5 
) const
static tBool Intersect ( const sVec3< T > &  mina,
const sVec3< T > &  maxa,
const sVec3< T > &  minb,
const sVec3< T > &  maxb,
epsilon = niEpsilon5 
)
static
tBool IntersectRay ( const sVec3< T > &  avRayPos,
const sVec3< T > &  avRayDir,
sVec3< T > *  pOut = NULL,
epsilon = niEpsilon5 
) const
void Reset ( )

Bounding box computing helper.

void SetPoint ( const sVec3< T > &  p)
void Inflate ( percent)

Inflate the bounding box of the given percent (1.0 == 100%).

void Extend ( const sVec3< T > &  v)

Extend the bounding box of the given vector.

void Translate ( const sVec3< T > &  vVec)

Translate the AABB.

void Rotate ( const sMatrix< T > &  aMtx)

Rotate/Scale the AABB.

void Transform ( const sMatrix< T > &  aMtx)

Transform the AABB.

void GetVertices ( tPtr  pVerts,
tU32  aulPosOffset,
tU32  aulStride 
) const

Get the AABB vertices.

Remarks
The array needs to have room for 8 elements.
static void GetTrianglesIndices ( tU32 pIndices,
bool  bCW 
)
static

Get triangles indices.

Remarks
The array needs to have room for 36 elements.
static void GetLinesIndices ( tU32 pIndices)
static

Get lines indices. To draw the AABB borders by example.

Remarks
The array needs to have room for 24 elements.
void GetFacesPlanes ( sVec4< T > *  pPlanes,
bool  bOutward 
) const

Get the AABB faces planes.

Remarks
The array needs to have room for 6 elements.

Member Data Documentation

sVec3<T> mvMin
protected
sVec3<T> mvMax
protected