decDCollisionVolume Class Reference

Base class for collision volumes. More...

#include <decDCollisionVolume.h>

Inheritance diagram for decDCollisionVolume:
decDCollisionBox decDCollisionCapsule decDCollisionCylinder decDCollisionFrustum decDCollisionSphere decDCollisionTriangle

List of all members.

Public Member Functions

Constructors and Destructors
 decDCollisionVolume ()
 Creates a new collision volume.
virtual ~decDCollisionVolume ()
 Cleans up the collision volume.
First Stage Dispatch
virtual bool VolumeHitsVolume (decDCollisionVolume *volume)=0
 Determines if this volume collides with the given one.
virtual double VolumeMoveHitsVolume (decDCollisionVolume *volume, const decDVector &displacement, decDVector *normal)=0
 Retrieves the distance travelled along a given displacement vector until this volume hits another one.
Second Stage Dispatch
virtual bool SphereHitsVolume (decDCollisionSphere *sphere)=0
 Determines if the given sphere collides with this volume.
virtual bool CylinderHitsVolume (decDCollisionCylinder *cylinder)=0
 Determines if the given cylinder collides with this volume.
virtual bool CapsuleHitsVolume (decDCollisionCapsule *capsule)=0
 Determines if the given capsule collides with this volume.
virtual bool BoxHitsVolume (decDCollisionBox *box)=0
 Determines if the given box collides with this volume.
virtual bool TriangleHitsVolume (decDCollisionTriangle *triangle)=0
 Determines if the given triangle collides with this volume.
virtual bool FrustumHitsVolume (decDCollisionFrustum *frustum)=0
 Determines if the given frustum collides with this volume.
virtual double SphereMoveHitsVolume (decDCollisionSphere *sphere, const decDVector &displacement, decDVector *normal)=0
 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)=0
 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)=0
 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)=0
 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)=0
 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)=0
 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)=0
 Retrieves the distance travelled along a given displacement vector until the given point hits this volume.
Enclosing Volumes
virtual void GetEnclosingSphere (decDCollisionSphere *sphere)=0
 Retrieves the sphere volume best enclosing this volume.
virtual void GetEnclosingBox (decDCollisionBox *box)=0
 Retrieves the box volume best enclosing this volume.
Miscelanous Functions
virtual decDVector ClosestPointTo (const decDVector &point)=0
 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)=0
 Visits the collision volume.

Detailed Description

Base class for collision volumes.

The collision detection system uses a double dispatch system to determine collisions between various volumes. The first dispatch call is VolumeHitsVolume. Each subclass has to call a left side specialized function on either the caller or itself to trigger the second dispatch. Left side functions are those of the shape *HitsVolume. Such a left side function then has to call the approriate right side function which is a function of the shape *Hits*. Collision detection is then carried out by such a right side function. A collision check requires though at most 2 dispatch calls in addition to the execution time of the real collision routine.

Although the name collision volumes suggests only volumes to be used in collision detection this is not fully true. This collision system also allows a ray as beeing a volume. Also a triangle is strictly not a volume as it is infitesimal small in one direction but is considered a collision volume.

Author:
Plüss Roland
Version:
1.0
Date:
2008
Note:
The Ray as a collision class doesn't really fit in the big picture. A ray is an infinite object and not even a volume. A solution would be to take out the ray class and simply add a collision test call to the collision volume class. This way the important functionality is conserved but the troublesome ray class vanishes.

Constructor & Destructor Documentation

decDCollisionVolume::decDCollisionVolume (  )

Creates a new collision volume.

virtual decDCollisionVolume::~decDCollisionVolume (  ) [virtual]

Cleans up the collision volume.


Member Function Documentation

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

Determines if the given box collides with this volume.

The subclass has to dispatch to a collision function here.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

virtual double decDCollisionVolume::BoxMoveHitsVolume ( decDCollisionBox box,
const decDVector displacement,
decDVector normal 
) [pure 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.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

virtual bool decDCollisionVolume::CapsuleHitsVolume ( decDCollisionCapsule capsule ) [pure virtual]

Determines if the given capsule collides with this volume.

The subclass has to dispatch to a collision function here.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

virtual double decDCollisionVolume::CapsuleMoveHitsVolume ( decDCollisionCapsule capsule,
const decDVector displacement,
decDVector normal 
) [pure 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.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

virtual decDVector decDCollisionVolume::ClosestPointTo ( const decDVector point ) [pure virtual]
virtual bool decDCollisionVolume::CylinderHitsVolume ( decDCollisionCylinder cylinder ) [pure virtual]

Determines if the given cylinder collides with this volume.

The subclass has to dispatch to a collision function here.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

virtual double decDCollisionVolume::CylinderMoveHitsVolume ( decDCollisionCylinder cylinder,
const decDVector displacement,
decDVector normal 
) [pure 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.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

virtual bool decDCollisionVolume::FrustumHitsVolume ( decDCollisionFrustum frustum ) [pure virtual]

Determines if the given frustum collides with this volume.

The subclass has to dispatch to a collision function here.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

virtual double decDCollisionVolume::FrustumMoveHitsVolume ( decDCollisionFrustum frustum,
const decDVector displacement,
decDVector normal 
) [pure 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.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

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

Retrieves the box volume best enclosing this volume.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

virtual void decDCollisionVolume::GetEnclosingSphere ( decDCollisionSphere sphere ) [pure virtual]

Retrieves the sphere volume best enclosing this volume.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

virtual decDVector decDCollisionVolume::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 in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, and decDCollisionSphere.

virtual double decDCollisionVolume::PointMoveHitsVolume ( const decDVector point,
const decDVector displacement,
decDVector normal 
) [pure 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.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

virtual bool decDCollisionVolume::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 in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, and decDCollisionSphere.

virtual bool decDCollisionVolume::SphereHitsVolume ( decDCollisionSphere sphere ) [pure virtual]

Determines if the given sphere collides with this volume.

The subclass has to dispatch to a collision function here.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

virtual double decDCollisionVolume::SphereMoveHitsVolume ( decDCollisionSphere sphere,
const decDVector displacement,
decDVector normal 
) [pure 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.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

virtual bool decDCollisionVolume::TriangleHitsVolume ( decDCollisionTriangle triangle ) [pure virtual]

Determines if the given triangle collides with this volume.

The subclass has to dispatch to a collision function here.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

virtual double decDCollisionVolume::TriangleMoveHitsVolume ( decDCollisionTriangle triangle,
const decDVector displacement,
decDVector normal 
) [pure 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.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

virtual void decDCollisionVolume::Visit ( decDCollisionVolumeVisitor visitor ) [pure virtual]
virtual bool decDCollisionVolume::VolumeHitsVolume ( decDCollisionVolume volume ) [pure virtual]

Determines if this volume collides with the given one.

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

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.

virtual double decDCollisionVolume::VolumeMoveHitsVolume ( decDCollisionVolume volume,
const decDVector displacement,
decDVector normal 
) [pure 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.

Implemented in decDCollisionBox, decDCollisionCapsule, decDCollisionCylinder, decDCollisionFrustum, decDCollisionSphere, and decDCollisionTriangle.


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