Base class for collision volumes. More...
#include <decCollisionVolume.h>
Public Member Functions | |
Constructors and Destructors | |
| decCollisionVolume () | |
| Creates a new collision volume. | |
| virtual | ~decCollisionVolume () |
| Cleans up the collision volume. | |
First Stage Dispatch | |
| virtual bool | VolumeHitsVolume (decCollisionVolume *volume)=0 |
| Determines if this volume collides with the given one. | |
| virtual float | VolumeMoveHitsVolume (decCollisionVolume *volume, const decVector &displacement, decVector *normal)=0 |
| Retrieves the distance travelled along a given displacement vector until this volume hits another one. | |
Second Stage Dispatch | |
| virtual bool | SphereHitsVolume (decCollisionSphere *sphere)=0 |
| Determines if the given sphere collides with this volume. | |
| virtual bool | CylinderHitsVolume (decCollisionCylinder *cylinder)=0 |
| Determines if the given cylinder collides with this volume. | |
| virtual bool | CapsuleHitsVolume (decCollisionCapsule *capsule)=0 |
| Determines if the given capsule collides with this volume. | |
| virtual bool | BoxHitsVolume (decCollisionBox *box)=0 |
| Determines if the given box collides with this volume. | |
| virtual bool | TriangleHitsVolume (decCollisionTriangle *triangle)=0 |
| Determines if the given triangle collides with this volume. | |
| virtual bool | FrustumHitsVolume (decCollisionFrustum *frustum)=0 |
| Determines if the given frustum collides with this volume. | |
| virtual float | SphereMoveHitsVolume (decCollisionSphere *sphere, const decVector &displacement, decVector *normal)=0 |
| Retrieves the distance travelled along a given displacement vector until this volume hits a sphere. | |
| virtual float | CylinderMoveHitsVolume (decCollisionCylinder *cylinder, const decVector &displacement, decVector *normal)=0 |
| Retrieves the distance travelled along a given displacement vector until this volume hits a cylinder. | |
| virtual float | CapsuleMoveHitsVolume (decCollisionCapsule *capsule, const decVector &displacement, decVector *normal)=0 |
| Retrieves the distance travelled along a given displacement vector until this volume hits a capsule. | |
| virtual float | BoxMoveHitsVolume (decCollisionBox *box, const decVector &displacement, decVector *normal)=0 |
| Retrieves the distance travelled along a given displacement vector until this volume hits a box. | |
| virtual float | TriangleMoveHitsVolume (decCollisionTriangle *triangle, const decVector &displacement, decVector *normal)=0 |
| Retrieves the distance travelled along a given displacement vector until this volume hits a triangle. | |
| virtual float | FrustumMoveHitsVolume (decCollisionFrustum *frustum, const decVector &displacement, decVector *normal)=0 |
| Retrieves the distance travelled along a given displacement vector until this volume hits a frustum. | |
| virtual float | PointMoveHitsVolume (const decVector &point, const decVector &displacement, decVector *normal)=0 |
| Retrieves the distance travelled along a given displacement vector until the given point hits this volume. | |
Enclosing Volumes | |
| virtual void | GetEnclosingSphere (decCollisionSphere *sphere)=0 |
| Retrieves the sphere volume best enclosing this volume. | |
| virtual void | GetEnclosingBox (decCollisionBox *box)=0 |
| Retrieves the box volume best enclosing this volume. | |
Miscelanous Functions | |
| virtual decVector | ClosestPointTo (const decVector &point)=0 |
| Retrieves the closest point on the volume. | |
| virtual decVector | NormalAtPoint (const decVector &point) |
| Retrieves the surface normal through the given point. | |
| virtual bool | RayHitsVolume (const decVector &rayOrigin, const decVector &rayDirection, float &hitDistance) |
| Determines if a ray hits the volume. | |
Visiting | |
| virtual void | Visit (decCollisionVolumeVisitor *visitor)=0 |
| Visits the collision volume. | |
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.
| decCollisionVolume::decCollisionVolume | ( | ) |
Creates a new collision volume.
| virtual decCollisionVolume::~decCollisionVolume | ( | ) | [virtual] |
Cleans up the collision volume.
| virtual bool decCollisionVolume::BoxHitsVolume | ( | decCollisionBox * | box ) | [pure virtual] |
Determines if the given box collides with this volume.
The subclass has to dispatch to a collision function here.
Implemented in decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual float decCollisionVolume::BoxMoveHitsVolume | ( | decCollisionBox * | box, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual bool decCollisionVolume::CapsuleHitsVolume | ( | decCollisionCapsule * | capsule ) | [pure virtual] |
Determines if the given capsule collides with this volume.
The subclass has to dispatch to a collision function here.
Implemented in decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual float decCollisionVolume::CapsuleMoveHitsVolume | ( | decCollisionCapsule * | capsule, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
Retrieves the closest point on the volume.
Implemented in decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual bool decCollisionVolume::CylinderHitsVolume | ( | decCollisionCylinder * | cylinder ) | [pure virtual] |
Determines if the given cylinder collides with this volume.
The subclass has to dispatch to a collision function here.
Implemented in decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual float decCollisionVolume::CylinderMoveHitsVolume | ( | decCollisionCylinder * | cylinder, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual bool decCollisionVolume::FrustumHitsVolume | ( | decCollisionFrustum * | frustum ) | [pure virtual] |
Determines if the given frustum collides with this volume.
The subclass has to dispatch to a collision function here.
Implemented in decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual float decCollisionVolume::FrustumMoveHitsVolume | ( | decCollisionFrustum * | frustum, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual void decCollisionVolume::GetEnclosingBox | ( | decCollisionBox * | box ) | [pure virtual] |
Retrieves the box volume best enclosing this volume.
Implemented in decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual void decCollisionVolume::GetEnclosingSphere | ( | decCollisionSphere * | sphere ) | [pure virtual] |
Retrieves the sphere volume best enclosing this volume.
Implemented in decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
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.
| point | Point to determine the normal for. |
Reimplemented in decCollisionBox, decCollisionCapsule, decCollisionCylinder, and decCollisionSphere.
| virtual float decCollisionVolume::PointMoveHitsVolume | ( | const decVector & | point, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual bool decCollisionVolume::RayHitsVolume | ( | const decVector & | rayOrigin, |
| const decVector & | rayDirection, | ||
| float & | hitDistance | ||
| ) | [virtual] |
Determines if a ray hits the volume.
| rayOrigin | Origin of the ray. |
| rayDirection | Normalized direction of the ray. |
| hitDistance | If the ray hits this will be set to the distance from the ray origin to the collision point. |
Reimplemented in decCollisionBox, decCollisionCapsule, decCollisionCylinder, and decCollisionSphere.
| virtual bool decCollisionVolume::SphereHitsVolume | ( | decCollisionSphere * | sphere ) | [pure virtual] |
Determines if the given sphere collides with this volume.
The subclass has to dispatch to a collision function here.
Implemented in decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual float decCollisionVolume::SphereMoveHitsVolume | ( | decCollisionSphere * | sphere, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual bool decCollisionVolume::TriangleHitsVolume | ( | decCollisionTriangle * | triangle ) | [pure virtual] |
Determines if the given triangle collides with this volume.
The subclass has to dispatch to a collision function here.
Implemented in decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual float decCollisionVolume::TriangleMoveHitsVolume | ( | decCollisionTriangle * | triangle, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual void decCollisionVolume::Visit | ( | decCollisionVolumeVisitor * | visitor ) | [pure virtual] |
Visits the collision volume.
Implemented in decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual bool decCollisionVolume::VolumeHitsVolume | ( | decCollisionVolume * | 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 decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
| virtual float decCollisionVolume::VolumeMoveHitsVolume | ( | decCollisionVolume * | volume, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionBox, decCollisionCapsule, decCollisionCylinder, decCollisionFrustum, decCollisionSphere, and decCollisionTriangle.
1.7.2