CDBox Class Reference
[Game Data]

Representation of box. More...

#include <colmodel.h>

List of all members.

Public Member Functions

 CDBox ()
virtual ~CDBox ()
void zeroize ()
 Zeroize the vertices of the box.
void translate (const GLVector3d translation)
 Adds translation vector to all vertices.
void rotate (GLQuaterniond rotation)
 Rotates all vertices by rotation represented by quaternion.
double getMin (int cordinate) const
 Get minimal value in a coorinate.
double getMax (int cordinate) const
 Get maximal value in coorinate.
bool quickCheckCollision (const CDBox &box) const
 Quick check colision with another box.
void project (const GLVector3d &normal, double &min, double &max) const
 Return min and max for the projection.
double trySepparatingAxis (const CDBox &box, int a1, int a2, int b1, int b2, GLVector3d &normal) const
 Try separation with plane contructed from axis taken from both boxes.
double trySepparatingAxisSelf (const CDBox &box, int a1, int a2, int b1, int b2, GLVector3d &normal) const
 Try separation with plane contructed from axis taken from this box.

Static Public Member Functions

static double projectAndCompare (const CDBox &box1, const CDBox &box2, const GLVector3d &normal)
 Project boxes to normal and try to decide collision.

Public Attributes

GLVector3d mVertex [8]
 Eight vertices representing the box.


Detailed Description

Representation of box.

Definition at line 31 of file colmodel.h.


Constructor & Destructor Documentation

CDBox::CDBox  )  [inline]
 

Definition at line 34 of file colmodel.h.

virtual CDBox::~CDBox  )  [inline, virtual]
 

Definition at line 35 of file colmodel.h.


Member Function Documentation

double CDBox::getMax int  cordinate  )  const [inline]
 

Get maximal value in coorinate.

Parameters:
cordinate id of coodrinate. 0 = x, 1 = y, 2 = z
Returns:
maximal value in specified coordinate

Definition at line 91 of file colmodel.h.

References mVertex.

Referenced by quickCheckCollision().

double CDBox::getMin int  cordinate  )  const [inline]
 

Get minimal value in a coorinate.

Parameters:
cordinate id of coodrinate. 0 = x, 1 = y, 2 = z
Returns:
minimal value in specified coordinate

Definition at line 78 of file colmodel.h.

References mVertex.

Referenced by quickCheckCollision().

void CDBox::project const GLVector3d &  normal,
double &  min,
double &  max
const [inline]
 

Return min and max for the projection.

Compute min and max value of dot product of every vertex of the box and vector normal.

Parameters:
normal the vector to compute dot products with
min minimal computed dot product
max maximal computed dot product

Definition at line 125 of file colmodel.h.

References mVertex.

Referenced by projectAndCompare(), and projectAndCompareMax().

static double CDBox::projectAndCompare const CDBox box1,
const CDBox box2,
const GLVector3d &  normal
[inline, static]
 

Project boxes to normal and try to decide collision.

Parameters:
box1 First box to test.
box1 Second box to test.
normal Vector for projection.
Returns:
Depth of penetration. If you multiply normal with returned value, you get avoid vector for this direction.

Definition at line 212 of file colmodel.h.

References project().

Referenced by trySepparatingAxis(), and trySepparatingAxisSelf().

Here is the call graph for this function:

bool CDBox::quickCheckCollision const CDBox box  )  const [inline]
 

Quick check colision with another box.

Does only check based on min/max coordinates.

Parameters:
box other box to test with
Returns:
false if there is no colision, true if not sure

Definition at line 105 of file colmodel.h.

References getMax(), and getMin().

Referenced by CollisionModel::computeMinimalAvoidDistance(), and CollisionModel::computeMinimalAvoidVector().

Here is the call graph for this function:

void CDBox::rotate GLQuaterniond  rotation  )  [inline]
 

Rotates all vertices by rotation represented by quaternion.

Definition at line 66 of file colmodel.h.

References mVertex.

void CDBox::translate const GLVector3d  translation  )  [inline]
 

Adds translation vector to all vertices.

Parameters:
translation the vector to add

Definition at line 58 of file colmodel.h.

References mVertex.

double CDBox::trySepparatingAxis const CDBox box,
int  a1,
int  a2,
int  b1,
int  b2,
GLVector3d &  normal
const [inline]
 

Try separation with plane contructed from axis taken from both boxes.

Parameters:
box The second box to check separate from this box.
a1 index of first vertex that determine axis from this box
a2 index of second vertex that determine axis from this box
b1 index of first vertex that determine axis from second box
b2 index of second vertex that determine axis from second box
normal Computed normal vector for tested plane. The normal is normalized.
Returns:
Depth of penetration. You may mutiply normal by this number and get avoid vector. Value 0 means no collision. Return some big number if the axis don't define a plane. (means are paralel)

Definition at line 149 of file colmodel.h.

References mVertex, and projectAndCompare().

Here is the call graph for this function:

double CDBox::trySepparatingAxisSelf const CDBox box,
int  a1,
int  a2,
int  b1,
int  b2,
GLVector3d &  normal
const [inline]
 

Try separation with plane contructed from axis taken from this box.

Parameters:
box The second box to check separate from this box.
a1 index of first vertex that determine first axis from this box
a2 index of second vertex that determine first axis from this box
b1 index of first vertex that determine second axis from this box
b2 index of second vertex that determine second axis from this box
normal Computed normal vector for tested plane. The normal is normalized.
Returns:
Depth of penetration. You may mutiply normal by this number and get avoid vector. Value 0 means no collision. Return some big number if the axis don't define a plane. (means are paralel)

Definition at line 183 of file colmodel.h.

References mVertex, and projectAndCompare().

Here is the call graph for this function:

void CDBox::zeroize  )  [inline]
 

Zeroize the vertices of the box.

Definition at line 48 of file colmodel.h.

References mVertex.

Referenced by CollisionModel::CollisionModel().


Member Data Documentation

GLVector3d CDBox::mVertex[8]
 

Eight vertices representing the box.

Eight vertices representing the box, the indices represents them in the following order: BOTTOM_FRONT_LEFT, BOTTOM_FRONT_RIGHT, BOTTOM_BACK_RIGHT, BOTTOM_BACK_LEFT, TOP_FRONT_LEFT, TOP_FRONT_RIGHT, TOP_BACK_RIGHT, TOP_BACK_LEFT.

Definition at line 35 of file colmodel.h.

Referenced by TaskSimulationServer::checkTerrainHeights(), getMax(), getMin(), project(), Tank::render(), rotate(), translate(), trySepparatingAxis(), trySepparatingAxisMax(), trySepparatingAxisSelf(), trySepparatingAxisSelfMax(), and zeroize().


The documentation for this class was generated from the following file:
Generated on Wed Apr 12 14:12:25 2006 for bjs by  doxygen 1.4.5