Capsule collision volume. More...
#include <decCollisionCapsule.h>
Public Member Functions | |
Constructors and Destructors | |
| decCollisionCapsule () | |
| Creates a new unoriented capsule. | |
| decCollisionCapsule (const decVector &position, float halfHeight, float topRadius, float bottomRadius) | |
| Creates a new unoriented capsule. | |
| decCollisionCapsule (const decVector &position, float halfHeight, float topRadius, float bottomRadius, const decQuaternion &orientation) | |
| Creates a new oriented capsule. | |
| virtual | ~decCollisionCapsule () |
| Cleans up the collision Capsule. | |
First Stage Dispatch | |
| virtual bool | VolumeHitsVolume (decCollisionVolume *volume) |
| Determines if this volume collides with the given one. | |
| virtual float | VolumeMoveHitsVolume (decCollisionVolume *volume, const decVector &displacement, decVector *normal) |
| Retrieves the distance travelled along a given displacement vector until this volume hits another one. | |
Second Stage Dispatch | |
| virtual bool | SphereHitsVolume (decCollisionSphere *sphere) |
| Determines if the given sphere collides with this volume. | |
| virtual bool | CylinderHitsVolume (decCollisionCylinder *cylinder) |
| Determines if the given cylinder collides with this volume. | |
| virtual bool | CapsuleHitsVolume (decCollisionCapsule *capsule) |
| Determines if the given capsule collides with this volume. | |
| virtual bool | BoxHitsVolume (decCollisionBox *box) |
| Determines if the given box collides with this volume. | |
| virtual bool | TriangleHitsVolume (decCollisionTriangle *triangle) |
| Determines if the given triangle collides with this volume. | |
| virtual bool | FrustumHitsVolume (decCollisionFrustum *frustum) |
| Determines if the given frustum collides with this volume. | |
| virtual float | SphereMoveHitsVolume (decCollisionSphere *sphere, const decVector &displacement, decVector *normal) |
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| 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) |
| Retrieves the distance travelled along a given displacement vector until the given point hits this volume. | |
Enclosing Volumes | |
| virtual void | GetEnclosingSphere (decCollisionSphere *sphere) |
| Retrieves the sphere volume best enclosing this volume. | |
| virtual void | GetEnclosingBox (decCollisionBox *box) |
| Retrieves the box volume best enclosing this volume. | |
Miscelanous Functions | |
| virtual decVector | ClosestPointTo (const decVector &point) |
| 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) |
| Visits the collision volume. | |
Collision Routines | |
| bool | SphereHitsCapsule (decCollisionSphere *sphere) |
| Determines if the given sphere hits this capsule. | |
| bool | CylinderHitsCapsule (decCollisionCylinder *cylinder) |
| Determines if the given cylinder hits this capsule. | |
| bool | CapsuleHitsCapsule (decCollisionCapsule *capsule) |
| Determines if the given capsule hits this capsule. | |
| float | SphereMoveHitsCapsule (decCollisionSphere *sphere, const decVector &displacement, decVector *normal) |
| Determines the distance of the given sphere to move until colliding with this capsule. | |
| float | CylinderMoveHitsCapsule (decCollisionCylinder *cylinder, const decVector &displacement, decVector *normal) |
| Determines the distance of the given cylinder to move until colliding with this capsule. | |
| float | CapsuleMoveHitsCapsule (decCollisionCapsule *capsule, const decVector &displacement, decVector *normal) |
| Determines the distance of the given capsule to move until colliding with this capsule. | |
Management | |
| const decVector & | GetPosition () const |
| Retrieves the capsule center. | |
| void | SetPosition (const decVector &position) |
| Sets the position. | |
| const decQuaternion & | GetOrientation () const |
| Retrieves the orientation. | |
| void | SetOrientation (const decQuaternion &orientation) |
| Sets the orientation. | |
| void | ClearOrientation () |
| Clears the orientation of the capsule setting it to the identity quaternion. | |
| float | GetHalfHeight () const |
| Retrieves the half height. | |
| void | SetHalfHeight (float halfHeight) |
| Sets the half height. | |
| float | GetTopRadius () const |
| Retrieves the top radius. | |
| void | SetTopRadius (float radius) |
| Sets the top radius. | |
| float | GetBottomRadius () const |
| Retrieves the bottom radius. | |
| void | SetBottomRadius (float radius) |
| Sets the bottom radius. | |
| void | SetRadius (float radius) |
| Sets both radi to the same value. | |
| bool | GetOriented () const |
| Determines if this capsule is oriented. | |
| bool | GetAxisAligned () const |
| Determines if this capsule is axis aligned. | |
| bool | GetTapered () const |
| Determines if this capsule is tapered. | |
| const decVector & | GetAxisX () const |
| Retrieves the X-Axis. | |
| const decVector & | GetAxisY () const |
| Retrieves the Y-Axis. | |
| const decVector & | GetAxisZ () const |
| Retrieves the Z-Axis. | |
| decVector | WorldToLocal (const decVector &point) const |
| Transforms a point from world coordinates into local coordinates. | |
| decVector | LocalToWorld (const decVector &point) const |
| Transforms a point from local coordinates into world coordinates. | |
| decVector | NormalWorldToLocal (const decVector &normal) const |
| Transforms a normal from world coordinates into local coordinates. | |
| decVector | NormalLocalToWorld (const decVector &normal) const |
| Transforms a normal from local coordinates into world coordinates. | |
Capsule collision volume.
Defines a collision volume in the shape of a capsule. The capsule is defined by a half height and two radi one for the top sphere and one for the bottom sphere. The capsule is oriented along the Y-Axis. A capsule with different radi is a tapered capsule while a capsule with two identical radi is a common capsule. Common capsules are usually faster.
| decCollisionCapsule::decCollisionCapsule | ( | ) |
Creates a new unoriented capsule.
The half height is set to 0.5, the top and bottom radius are set both to 0.5 too.
| decCollisionCapsule::decCollisionCapsule | ( | const decVector & | position, |
| float | halfHeight, | ||
| float | topRadius, | ||
| float | bottomRadius | ||
| ) |
Creates a new unoriented capsule.
| position | Center of the capsule. |
| halfHeight | Half the height of the capsule. Has to be greater than 0. |
| topRadius | Radius of the top cap. Has to be greater than 0. |
| bottomRadius | Radius of the bottom cap. Has to be greater than 0. |
| decCollisionCapsule::decCollisionCapsule | ( | const decVector & | position, |
| float | halfHeight, | ||
| float | topRadius, | ||
| float | bottomRadius, | ||
| const decQuaternion & | orientation | ||
| ) |
Creates a new oriented capsule.
| position | Center of the capsule. |
| halfHeight | Half the height of the capsule. Has to be greater than 0. |
| topRadius | Radius of the top cap. Has to be greater than 0. |
| bottomRadius | Radius of the bottom cap. Has to be greater than 0. |
| orientation | Orientation of the capsule as normalized quaternion. |
| virtual decCollisionCapsule::~decCollisionCapsule | ( | ) | [virtual] |
Cleans up the collision Capsule.
| virtual bool decCollisionCapsule::BoxHitsVolume | ( | decCollisionBox * | box ) | [virtual] |
Determines if the given box collides with this volume.
The subclass has to dispatch to a collision function here.
Implements decCollisionVolume.
| virtual float decCollisionCapsule::BoxMoveHitsVolume | ( | decCollisionBox * | box, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionVolume.
| bool decCollisionCapsule::CapsuleHitsCapsule | ( | decCollisionCapsule * | capsule ) |
Determines if the given capsule hits this capsule.
| virtual bool decCollisionCapsule::CapsuleHitsVolume | ( | decCollisionCapsule * | capsule ) | [virtual] |
Determines if the given capsule collides with this volume.
The subclass has to dispatch to a collision function here.
Implements decCollisionVolume.
| float decCollisionCapsule::CapsuleMoveHitsCapsule | ( | decCollisionCapsule * | capsule, |
| const decVector & | displacement, | ||
| decVector * | normal | ||
| ) |
Determines the distance of the given capsule to move until colliding with this capsule.
| virtual float decCollisionCapsule::CapsuleMoveHitsVolume | ( | decCollisionCapsule * | capsule, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionVolume.
| void decCollisionCapsule::ClearOrientation | ( | ) |
Clears the orientation of the capsule setting it to the identity quaternion.
Retrieves the closest point on the volume.
Implements decCollisionVolume.
| bool decCollisionCapsule::CylinderHitsCapsule | ( | decCollisionCylinder * | cylinder ) |
Determines if the given cylinder hits this capsule.
| virtual bool decCollisionCapsule::CylinderHitsVolume | ( | decCollisionCylinder * | cylinder ) | [virtual] |
Determines if the given cylinder collides with this volume.
The subclass has to dispatch to a collision function here.
Implements decCollisionVolume.
| float decCollisionCapsule::CylinderMoveHitsCapsule | ( | decCollisionCylinder * | cylinder, |
| const decVector & | displacement, | ||
| decVector * | normal | ||
| ) |
Determines the distance of the given cylinder to move until colliding with this capsule.
| virtual float decCollisionCapsule::CylinderMoveHitsVolume | ( | decCollisionCylinder * | cylinder, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionVolume.
| virtual bool decCollisionCapsule::FrustumHitsVolume | ( | decCollisionFrustum * | frustum ) | [virtual] |
Determines if the given frustum collides with this volume.
The subclass has to dispatch to a collision function here.
Implements decCollisionVolume.
| virtual float decCollisionCapsule::FrustumMoveHitsVolume | ( | decCollisionFrustum * | frustum, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionVolume.
| bool decCollisionCapsule::GetAxisAligned | ( | ) | const [inline] |
Determines if this capsule is axis aligned.
| const decVector& decCollisionCapsule::GetAxisX | ( | ) | const [inline] |
Retrieves the X-Axis.
| const decVector& decCollisionCapsule::GetAxisY | ( | ) | const [inline] |
Retrieves the Y-Axis.
| const decVector& decCollisionCapsule::GetAxisZ | ( | ) | const [inline] |
Retrieves the Z-Axis.
| float decCollisionCapsule::GetBottomRadius | ( | ) | const [inline] |
Retrieves the bottom radius.
| virtual void decCollisionCapsule::GetEnclosingBox | ( | decCollisionBox * | box ) | [virtual] |
Retrieves the box volume best enclosing this volume.
Implements decCollisionVolume.
| virtual void decCollisionCapsule::GetEnclosingSphere | ( | decCollisionSphere * | sphere ) | [virtual] |
Retrieves the sphere volume best enclosing this volume.
Implements decCollisionVolume.
| float decCollisionCapsule::GetHalfHeight | ( | ) | const [inline] |
Retrieves the half height.
| const decQuaternion& decCollisionCapsule::GetOrientation | ( | ) | const [inline] |
Retrieves the orientation.
| bool decCollisionCapsule::GetOriented | ( | ) | const [inline] |
Determines if this capsule is oriented.
| const decVector& decCollisionCapsule::GetPosition | ( | ) | const [inline] |
Retrieves the capsule center.
| bool decCollisionCapsule::GetTapered | ( | ) | const [inline] |
Determines if this capsule is tapered.
| float decCollisionCapsule::GetTopRadius | ( | ) | const [inline] |
Retrieves the top radius.
Transforms a point from local coordinates into world coordinates.
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 from decCollisionVolume.
Transforms a normal from local coordinates into world coordinates.
Transforms a normal from world coordinates into local coordinates.
| virtual float decCollisionCapsule::PointMoveHitsVolume | ( | const decVector & | point, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionVolume.
| virtual bool decCollisionCapsule::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 from decCollisionVolume.
| void decCollisionCapsule::SetBottomRadius | ( | float | radius ) |
Sets the bottom radius.
| radius | Radius of the bottom capsule cap. Has to be greater than 0. |
| void decCollisionCapsule::SetHalfHeight | ( | float | halfHeight ) |
Sets the half height.
| halfHeight | Half the height of the capsule. Has to be greater than 0. |
| void decCollisionCapsule::SetOrientation | ( | const decQuaternion & | orientation ) |
Sets the orientation.
| orientation | Normalized rotation quaternion. |
| void decCollisionCapsule::SetPosition | ( | const decVector & | position ) |
Sets the position.
| position | Center of capsule. |
| void decCollisionCapsule::SetRadius | ( | float | radius ) |
Sets both radi to the same value.
| radius | Radius of both the top and bottom cap. Has to be greater than 0. |
| void decCollisionCapsule::SetTopRadius | ( | float | radius ) |
Sets the top radius.
| radius | Radius of the top capsule cap. Has to be greater than 0. |
| bool decCollisionCapsule::SphereHitsCapsule | ( | decCollisionSphere * | sphere ) |
Determines if the given sphere hits this capsule.
| virtual bool decCollisionCapsule::SphereHitsVolume | ( | decCollisionSphere * | sphere ) | [virtual] |
Determines if the given sphere collides with this volume.
The subclass has to dispatch to a collision function here.
Implements decCollisionVolume.
| float decCollisionCapsule::SphereMoveHitsCapsule | ( | decCollisionSphere * | sphere, |
| const decVector & | displacement, | ||
| decVector * | normal | ||
| ) |
Determines the distance of the given sphere to move until colliding with this capsule.
| virtual float decCollisionCapsule::SphereMoveHitsVolume | ( | decCollisionSphere * | sphere, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionVolume.
| virtual bool decCollisionCapsule::TriangleHitsVolume | ( | decCollisionTriangle * | triangle ) | [virtual] |
Determines if the given triangle collides with this volume.
The subclass has to dispatch to a collision function here.
Implements decCollisionVolume.
| virtual float decCollisionCapsule::TriangleMoveHitsVolume | ( | decCollisionTriangle * | triangle, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionVolume.
| virtual void decCollisionCapsule::Visit | ( | decCollisionVolumeVisitor * | visitor ) | [virtual] |
Visits the collision volume.
Implements decCollisionVolume.
| virtual bool decCollisionCapsule::VolumeHitsVolume | ( | decCollisionVolume * | volume ) | [virtual] |
Determines if this volume collides with the given one.
The subclass has to dispatch to a second stage function here.
Implements decCollisionVolume.
| virtual float decCollisionCapsule::VolumeMoveHitsVolume | ( | decCollisionVolume * | volume, |
| const decVector & | displacement, | ||
| decVector * | 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 decCollisionVolume.
Transforms a point from world coordinates into local coordinates.
1.7.2