Public Member Functions

decDCollisionBox Class Reference

Box Collision Volume. More...

#include <decDCollisionBox.h>

Inheritance diagram for decDCollisionBox:
decDCollisionVolume

List of all members.

Public Member Functions

decDVector LocalToWorld (const decDVector &point) const
decDVector NormalLocalToWorld (const decDVector &normal) const
decDVector NormalWorldToLocal (const decDVector &normal) const
decDVector WorldToLocal (const decDVector &point) const
Constructors and Destructors
 decDCollisionBox ()
 Creates a new collision box of 0 size.
 decDCollisionBox (const decDVector &center, const decDVector &halfSize)
 Creates a new collision box with the given parameters.
 decDCollisionBox (const decDVector &center, const decDVector &halfSize, const decQuaternion &orientation)
 Creates a new collision box with the given parameters.
virtual ~decDCollisionBox ()
 Cleans up the collision box.
First Stage Dispatch
virtual bool VolumeHitsVolume (decDCollisionVolume *volume)
 Determines if this volume collides with the given one.
virtual double VolumeMoveHitsVolume (decDCollisionVolume *volume, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits another one.
Second Stage Dispatch
virtual bool SphereHitsVolume (decDCollisionSphere *sphere)
 Determines if the given sphere collides with this volume.
virtual bool CylinderHitsVolume (decDCollisionCylinder *cylinder)
 Determines if the given cylinder collides with this volume.
virtual bool CapsuleHitsVolume (decDCollisionCapsule *capsule)
 Determines if the given capsule collides with this volume.
virtual bool BoxHitsVolume (decDCollisionBox *box)
 Determines if the given box collides with this volume.
virtual bool TriangleHitsVolume (decDCollisionTriangle *triangle)
 Determines if the given triangle collides with this volume.
virtual bool FrustumHitsVolume (decDCollisionFrustum *frustum)
 Determines if the given frustum collides with this volume.
virtual double SphereMoveHitsVolume (decDCollisionSphere *sphere, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a sphere.
virtual double CylinderMoveHitsVolume (decDCollisionCylinder *cylinder, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a cylinder.
virtual double CapsuleMoveHitsVolume (decDCollisionCapsule *capsule, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a capsule.
virtual double BoxMoveHitsVolume (decDCollisionBox *box, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a box.
virtual double TriangleMoveHitsVolume (decDCollisionTriangle *triangle, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a triangle.
virtual double FrustumMoveHitsVolume (decDCollisionFrustum *frustum, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a frustum.
virtual double PointMoveHitsVolume (const decDVector &point, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until the given point hits this volume.
Enclosing Volumes
virtual void GetEnclosingSphere (decDCollisionSphere *sphere)
 Retrieves the sphere volume best enclosing this volume.
virtual void GetEnclosingBox (decDCollisionBox *box)
 Retrieves the box volume best enclosing this volume.
Miscelanous Functions
virtual decDVector ClosestPointTo (const decDVector &point)
 Retrieves the closest point on the volume.
virtual decDVector NormalAtPoint (const decDVector &point)
 Retrieves the surface normal through the given point.
virtual bool RayHitsVolume (const decDVector &rayOrigin, const decDVector &rayDirection, double &hitDistance)
 Determines if a ray hits the volume.
Visiting
virtual void Visit (decDCollisionVolumeVisitor *visitor)
 Visits the collision volume.
Collision Routines
bool SphereHitsBox (decDCollisionSphere *sphere)
 Determines if the given sphere hits this box.
bool CylinderHitsBox (decDCollisionCylinder *cylinder)
 Determines if the given cylinder hits this box.
bool CapsuleHitsBox (decDCollisionCapsule *capsule)
 Determines if the given capsule hits this box.
bool BoxHitsBox (decDCollisionBox *box)
 Determines if the given box hits this box.
double SphereMoveHitsBox (decDCollisionSphere *sphere, const decDVector &displacement, decDVector *normal)
 Determines the distance of the given sphere to move until colliding with this box.
double CylinderMoveHitsBox (decDCollisionCylinder *cylinder, const decDVector &displacement, decDVector *normal)
 Determines the distance of the given cylinder to move until colliding with this box.
double CapsuleMoveHitsBox (decDCollisionCapsule *capsule, const decDVector &displacement, decDVector *normal)
 Determines the distance of the given capsule to move until colliding with this box.
double BoxMoveHitsBox (decDCollisionBox *box, const decDVector &displacement, decDVector *normal)
 Determines the distance of the given box to move until colliding with this box.
Parameters
const decDVectorGetCenter () const
 Retrieves the center.
const decDVectorGetHalfSize () const
 Retrieves the half sizes.
const decQuaternionGetOrientation () const
 Retrieves the orientation.
bool GetAxisAligned () const
 Determines if this box is axis aligned.
bool GetOriented () const
 Determines if this box is oriented.
const decDVectorGetAxisX () const
 Retrieves the x axis.
const decDVectorGetAxisY () const
 Retrieves the y axis.
const decDVectorGetAxisZ () const
 Retrieves the z axis.
void SetCenter (const decDVector &center)
 Sets the center.
void SetHalfSize (const decDVector &halfSize)
 Sets the half sizes.
void SetOrientation (const decQuaternion &orientation)
 Sets the orientation.
void ClearOrientation ()
 Clears the rotation and turns the box into an axis aligned box.
void SetFromExtends (const decDVector &minExtend, const decDVector &maxExtend)
 Sets the box parameters from the given extends.
void MoveBy (const decDVector &offset)
 Moves the center of the box by the given offset.
double ProjectExtends (const decDVector &axis) const
 Projects the extends of the box to the given axis.

Detailed Description

Box Collision Volume.

Defines a collision volume in the shape of a box. The box is defined by a position, the length of the extends in each direction ( half-size ) and an optional orientation. A box without a rotation is called axis aligned box whereas a box with a rotation is called an oriented box.

Author:
Plüss Roland
Version:
1.0
Date:
2008
Warning:
This class is partially implemented. See the collision functions for more informations.
Todo:
  • Implementing CylinderHitsBox

Constructor & Destructor Documentation

decDCollisionBox::decDCollisionBox (  )

Creates a new collision box of 0 size.

decDCollisionBox::decDCollisionBox ( const decDVector center,
const decDVector halfSize 
)

Creates a new collision box with the given parameters.

decDCollisionBox::decDCollisionBox ( const decDVector center,
const decDVector halfSize,
const decQuaternion orientation 
)

Creates a new collision box with the given parameters.

virtual decDCollisionBox::~decDCollisionBox (  ) [virtual]

Cleans up the collision box.


Member Function Documentation

bool decDCollisionBox::BoxHitsBox ( decDCollisionBox box )

Determines if the given box hits this box.

virtual bool decDCollisionBox::BoxHitsVolume ( decDCollisionBox box ) [virtual]

Determines if the given box collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

double decDCollisionBox::BoxMoveHitsBox ( decDCollisionBox box,
const decDVector displacement,
decDVector normal 
)

Determines the distance of the given box to move until colliding with this box.

Warning:
Function is not implemented yet and always returns 1.
virtual double decDCollisionBox::BoxMoveHitsVolume ( decDCollisionBox box,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until this volume hits a box.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

bool decDCollisionBox::CapsuleHitsBox ( decDCollisionCapsule capsule )

Determines if the given capsule hits this box.

virtual bool decDCollisionBox::CapsuleHitsVolume ( decDCollisionCapsule capsule ) [virtual]

Determines if the given capsule collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

double decDCollisionBox::CapsuleMoveHitsBox ( decDCollisionCapsule capsule,
const decDVector displacement,
decDVector normal 
)

Determines the distance of the given capsule to move until colliding with this box.

Warning:
Function is not implemented yet and always returns 1.
virtual double decDCollisionBox::CapsuleMoveHitsVolume ( decDCollisionCapsule capsule,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until this volume hits a capsule.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

void decDCollisionBox::ClearOrientation (  )

Clears the rotation and turns the box into an axis aligned box.

virtual decDVector decDCollisionBox::ClosestPointTo ( const decDVector point ) [virtual]

Retrieves the closest point on the volume.

Implements decDCollisionVolume.

bool decDCollisionBox::CylinderHitsBox ( decDCollisionCylinder cylinder )

Determines if the given cylinder hits this box.

Warning:
Not implemented yet and returns always false.
virtual bool decDCollisionBox::CylinderHitsVolume ( decDCollisionCylinder cylinder ) [virtual]

Determines if the given cylinder collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

double decDCollisionBox::CylinderMoveHitsBox ( decDCollisionCylinder cylinder,
const decDVector displacement,
decDVector normal 
)

Determines the distance of the given cylinder to move until colliding with this box.

Warning:
Function is not implemented yet and always returns 1.
virtual double decDCollisionBox::CylinderMoveHitsVolume ( decDCollisionCylinder cylinder,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until this volume hits a cylinder.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

virtual bool decDCollisionBox::FrustumHitsVolume ( decDCollisionFrustum frustum ) [virtual]

Determines if the given frustum collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

virtual double decDCollisionBox::FrustumMoveHitsVolume ( decDCollisionFrustum frustum,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until this volume hits a frustum.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

bool decDCollisionBox::GetAxisAligned (  ) const [inline]

Determines if this box is axis aligned.

const decDVector& decDCollisionBox::GetAxisX (  ) const [inline]

Retrieves the x axis.

const decDVector& decDCollisionBox::GetAxisY (  ) const [inline]

Retrieves the y axis.

const decDVector& decDCollisionBox::GetAxisZ (  ) const [inline]

Retrieves the z axis.

const decDVector& decDCollisionBox::GetCenter (  ) const [inline]

Retrieves the center.

virtual void decDCollisionBox::GetEnclosingBox ( decDCollisionBox box ) [virtual]

Retrieves the box volume best enclosing this volume.

Implements decDCollisionVolume.

virtual void decDCollisionBox::GetEnclosingSphere ( decDCollisionSphere sphere ) [virtual]

Retrieves the sphere volume best enclosing this volume.

Implements decDCollisionVolume.

const decDVector& decDCollisionBox::GetHalfSize (  ) const [inline]

Retrieves the half sizes.

const decQuaternion& decDCollisionBox::GetOrientation (  ) const [inline]

Retrieves the orientation.

bool decDCollisionBox::GetOriented (  ) const [inline]

Determines if this box is oriented.

decDVector decDCollisionBox::LocalToWorld ( const decDVector point ) const
void decDCollisionBox::MoveBy ( const decDVector offset )

Moves the center of the box by the given offset.

virtual decDVector decDCollisionBox::NormalAtPoint ( const decDVector point ) [virtual]

Retrieves the surface normal through the given point.

The point is either right on the surface or near to it. This function is relaxing in this case and tries to calculate the best normal pointing from the volume at the point. For certain points a normal is impossible to determine. The normal in this case is undefined.

Parameters:
pointPoint to determine the normal for.
Returns:
Surface normal at given point.

Reimplemented from decDCollisionVolume.

decDVector decDCollisionBox::NormalLocalToWorld ( const decDVector normal ) const
decDVector decDCollisionBox::NormalWorldToLocal ( const decDVector normal ) const
virtual double decDCollisionBox::PointMoveHitsVolume ( const decDVector point,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until the given point hits this volume.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

double decDCollisionBox::ProjectExtends ( const decDVector axis ) const [inline]

Projects the extends of the box to the given axis.

virtual bool decDCollisionBox::RayHitsVolume ( const decDVector rayOrigin,
const decDVector rayDirection,
double &  hitDistance 
) [virtual]

Determines if a ray hits the volume.

Parameters:
rayOriginOrigin of the ray.
rayDirectionNormalized direction of the ray.
hitDistanceIf the ray hits this will be set to the distance from the ray origin to the collision point.
Returns:
True if the ray hits the volume.

Reimplemented from decDCollisionVolume.

void decDCollisionBox::SetCenter ( const decDVector center )

Sets the center.

void decDCollisionBox::SetFromExtends ( const decDVector minExtend,
const decDVector maxExtend 
)

Sets the box parameters from the given extends.

The extends define the minimal and maximal values on the approriate axis the box has to spawn. The resulting box is axis aligned.

void decDCollisionBox::SetHalfSize ( const decDVector halfSize )

Sets the half sizes.

All components have to be at least 0.

void decDCollisionBox::SetOrientation ( const decQuaternion orientation )

Sets the orientation.

bool decDCollisionBox::SphereHitsBox ( decDCollisionSphere sphere )

Determines if the given sphere hits this box.

virtual bool decDCollisionBox::SphereHitsVolume ( decDCollisionSphere sphere ) [virtual]

Determines if the given sphere collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

double decDCollisionBox::SphereMoveHitsBox ( decDCollisionSphere sphere,
const decDVector displacement,
decDVector normal 
)

Determines the distance of the given sphere to move until colliding with this box.

Warning:
Function is not implemented yet and always returns 1.
virtual double decDCollisionBox::SphereMoveHitsVolume ( decDCollisionSphere sphere,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until this volume hits a sphere.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

virtual bool decDCollisionBox::TriangleHitsVolume ( decDCollisionTriangle triangle ) [virtual]

Determines if the given triangle collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

virtual double decDCollisionBox::TriangleMoveHitsVolume ( decDCollisionTriangle triangle,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until this volume hits a triangle.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

virtual void decDCollisionBox::Visit ( decDCollisionVolumeVisitor visitor ) [virtual]

Visits the collision volume.

Implements decDCollisionVolume.

virtual bool decDCollisionBox::VolumeHitsVolume ( decDCollisionVolume volume ) [virtual]

Determines if this volume collides with the given one.

The subclass has to dispatch to a second stage function here.

Implements decDCollisionVolume.

virtual double decDCollisionBox::VolumeMoveHitsVolume ( decDCollisionVolume volume,
const decDVector displacement,
decDVector normal 
) [virtual]

Retrieves the distance travelled along a given displacement vector until this volume hits another one.

The returned value is in the range of 0 to 1. If no collision happens 1 is returned. In case of collision 'normal' has to be filled in with a normalized vector designating the plane along which this volume can be moved without colliding the given volume. Set 'normal' to NULL if you are not interested in this information. The subclass has to dispatch to a second stage function here.

Implements decDCollisionVolume.

decDVector decDCollisionBox::WorldToLocal ( const decDVector point ) const

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