Vegastrike 0.5.1 rc1  1.0
Original sources for Vegastrike Evolved
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
OBB Class Reference

#include <IceOBB.h>

Public Member Functions

inline_ OBB ()
 Constructor. More...
 
inline_ OBB (const Point &center, const Point &extents, const Matrix3x3 &rot)
 Constructor. More...
 
inline_ ~OBB ()
 Destructor. More...
 
void SetEmpty ()
 
bool ContainsPoint (const Point &p) const
 
void Create (const AABB &aabb, const Matrix4x4 &mat)
 
inline_ void Rotate (const Matrix4x4 &mtx, OBB &obb) const
 
inline_ BOOL IsValid () const
 
bool ComputePlanes (Plane *planes) const
 
bool ComputePoints (Point *pts) const
 
bool ComputeVertexNormals (Point *pts) const
 
const udwordGetEdges () const
 
const PointGetLocalEdgeNormals () const
 
void ComputeWorldEdgeNormal (udword edge_index, Point &world_normal) const
 
void ComputeLSS (LSS &lss) const
 
bool IsInside (const OBB &box) const
 
inline_ const PointGetCenter () const
 
inline_ const PointGetExtents () const
 
inline_ const Matrix3x3GetRot () const
 
inline_ void GetRotatedExtents (Matrix3x3 &extents) const
 

Public Attributes

Point mCenter
 B for Box. More...
 
Point mExtents
 B for Bounding. More...
 
Matrix3x3 mRot
 O for Oriented. More...
 

Detailed Description

An Oriented Bounding Box (OBB).

Author
Pierre Terdiman
Version
1.0

Definition at line 18 of file IceOBB.h.

Constructor & Destructor Documentation

inline_ OBB::OBB ( )
inline

Constructor.

Definition at line 22 of file IceOBB.h.

22 {}
inline_ OBB::OBB ( const Point center,
const Point extents,
const Matrix3x3 rot 
)
inline

Constructor.

Definition at line 24 of file IceOBB.h.

24 : mCenter(center), mExtents(extents), mRot(rot) {}
inline_ OBB::~OBB ( )
inline

Destructor.

Definition at line 26 of file IceOBB.h.

26 {}

Member Function Documentation

void OBB::ComputeLSS ( LSS lss) const

Computes an LSS surrounding the OBB.

Parameters
lss[out] the LSS
bool OBB::ComputePlanes ( Plane planes) const

Computes the obb planes.

Parameters
planes[out] 6 box planes
Returns
true if success

Referenced by PlanesCollider::Collide().

bool OBB::ComputePoints ( Point pts) const

Computes the obb points.

Parameters
pts[out] 8 box points
Returns
true if success
bool OBB::ComputeVertexNormals ( Point pts) const

Computes vertex normals.

Parameters
pts[out] 8 box points
Returns
true if success
void OBB::ComputeWorldEdgeNormal ( udword  edge_index,
Point world_normal 
) const

Returns world edge normal

Parameters
edge_index[in] 0 <= edge index < 12
world_normal[out] edge normal in world space
bool OBB::ContainsPoint ( const Point p) const

Tests if a point is contained within the OBB.

Parameters
p[in] the world point to test
Returns
true if inside the OBB
void OBB::Create ( const AABB aabb,
const Matrix4x4 mat 
)

Builds an OBB from an AABB and a world transform.

Parameters
aabb[in] the aabb
mat[in] the world transform
inline_ const Point& OBB::GetCenter ( ) const
inline

Definition at line 159 of file IceOBB.h.

159 { return mCenter; }
const udword* OBB::GetEdges ( ) const

Returns edges.

Returns
24 indices (12 edges) indexing the list returned by ComputePoints()
inline_ const Point& OBB::GetExtents ( ) const
inline

Definition at line 160 of file IceOBB.h.

160 { return mExtents; }
const Point* OBB::GetLocalEdgeNormals ( ) const

Returns local edge normals.

Returns
edge normals in local space
inline_ const Matrix3x3& OBB::GetRot ( ) const
inline

Definition at line 161 of file IceOBB.h.

161 { return mRot; }
inline_ void OBB::GetRotatedExtents ( Matrix3x3 extents) const
inline

Definition at line 163 of file IceOBB.h.

References Matrix3x3::Scale().

164  {
165  extents = mRot;
166  extents.Scale(mExtents);
167  }
bool OBB::IsInside ( const OBB box) const

Checks the OBB is inside another OBB.

Parameters
box[in] the other OBB
Returns
TRUE if we're inside the other box
inline_ BOOL OBB::IsValid ( ) const
inline

Checks the OBB is valid.

Returns
true if the box is valid

Definition at line 81 of file IceOBB.h.

82  {
83  // Consistency condition for (Center, Extents) boxes: Extents >= 0.0f
84  if(mExtents.x < 0.0f) return FALSE;
85  if(mExtents.y < 0.0f) return FALSE;
86  if(mExtents.z < 0.0f) return FALSE;
87  return TRUE;
88  }
inline_ void OBB::Rotate ( const Matrix4x4 mtx,
OBB obb 
) const
inline

Recomputes the OBB after an arbitrary transform by a 4x4 matrix.

Parameters
mtx[in] the transform matrix
obb[out] the transformed OBB

Definition at line 65 of file IceOBB.h.

Referenced by PlanesCollider::Collide().

66  {
67  // The extents remain constant
68  obb.mExtents = mExtents;
69  // The center gets x-formed
70  obb.mCenter = mCenter * mtx;
71  // Combine rotations
72  obb.mRot = mRot * Matrix3x3(mtx);
73  }
void OBB::SetEmpty ( )
inline

Setups an empty OBB.

Definition at line 33 of file IceOBB.h.

34  {
35  mCenter.Zero();
37  mRot.Identity();
38  }

Member Data Documentation

Point OBB::mCenter

B for Box.

Definition at line 169 of file IceOBB.h.

Point OBB::mExtents

B for Bounding.

Definition at line 170 of file IceOBB.h.

Matrix3x3 OBB::mRot

O for Oriented.

Definition at line 171 of file IceOBB.h.


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