Box Collision Volume. More...
#include <decCollisionBox.h>
Public Member Functions | |
| decVector | LocalToWorld (const decVector &point) const |
| decVector | NormalLocalToWorld (const decVector &normal) const |
| decVector | NormalWorldToLocal (const decVector &normal) const |
| decVector | WorldToLocal (const decVector &point) const |
Constructors and Destructors | |
| decCollisionBox () | |
| Creates a new collision box of 0 size. | |
| decCollisionBox (const decVector ¢er, const decVector &halfSize) | |
| Creates a new collision box with the given parameters. | |
| decCollisionBox (const decVector ¢er, const decVector &halfSize, const decQuaternion &orientation) | |
| Creates a new collision box with the given parameters. | |
| virtual | ~decCollisionBox () |
| Cleans up the collision box. | |
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 | SphereHitsBox (decCollisionSphere *sphere) |
| Determines if the given sphere hits this box. | |
| bool | CylinderHitsBox (decCollisionCylinder *cylinder) |
| Determines if the given cylinder hits this box. | |
| bool | CapsuleHitsBox (decCollisionCapsule *capsule) |
| Determines if the given capsule hits this box. | |
| bool | BoxHitsBox (decCollisionBox *box) |
| Determines if the given box hits this box. | |
| float | SphereMoveHitsBox (decCollisionSphere *sphere, const decVector &displacement, decVector *normal) |
| Determines the distance of the given sphere to move until colliding with this box. | |
| float | CylinderMoveHitsBox (decCollisionCylinder *cylinder, const decVector &displacement, decVector *normal) |
| Determines the distance of the given cylinder to move until colliding with this box. | |
| float | CapsuleMoveHitsBox (decCollisionCapsule *capsule, const decVector &displacement, decVector *normal) |
| Determines the distance of the given capsule to move until colliding with this box. | |
| float | BoxMoveHitsBox (decCollisionBox *box, const decVector &displacement, decVector *normal) |
| Determines the distance of the given box to move until colliding with this box. | |
Parameters | |
| const decVector & | GetCenter () const |
| Retrieves the center. | |
| const decVector & | GetHalfSize () const |
| Retrieves the half sizes. | |
| const decQuaternion & | GetOrientation () const |
| Retrieves the orientation. | |
| bool | GetAxisAligned () const |
| Determines if this box is axis aligned. | |
| bool | GetOriented () const |
| Determines if this box is oriented. | |
| const decVector & | GetAxisX () const |
| Retrieves the x axis. | |
| const decVector & | GetAxisY () const |
| Retrieves the y axis. | |
| const decVector & | GetAxisZ () const |
| Retrieves the z axis. | |
| void | SetCenter (const decVector ¢er) |
| Sets the center. | |
| void | SetHalfSize (const decVector &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 decVector &minExtend, const decVector &maxExtend) |
| Sets the box parameters from the given extends. | |
| void | MoveBy (const decVector &offset) |
| Moves the center of the box by the given offset. | |
| float | ProjectExtends (const decVector &axis) const |
| Projects the extends of the box to the given axis. | |
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.
| decCollisionBox::decCollisionBox | ( | ) |
Creates a new collision box of 0 size.
Creates a new collision box with the given parameters.
| decCollisionBox::decCollisionBox | ( | const decVector & | center, |
| const decVector & | halfSize, | ||
| const decQuaternion & | orientation | ||
| ) |
Creates a new collision box with the given parameters.
| virtual decCollisionBox::~decCollisionBox | ( | ) | [virtual] |
Cleans up the collision box.
| bool decCollisionBox::BoxHitsBox | ( | decCollisionBox * | box ) |
Determines if the given box hits this box.
| virtual bool decCollisionBox::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.
| float decCollisionBox::BoxMoveHitsBox | ( | decCollisionBox * | box, |
| const decVector & | displacement, | ||
| decVector * | normal | ||
| ) |
Determines the distance of the given box to move until colliding with this box.
| virtual float decCollisionBox::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 decCollisionBox::CapsuleHitsBox | ( | decCollisionCapsule * | capsule ) |
Determines if the given capsule hits this box.
| virtual bool decCollisionBox::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 decCollisionBox::CapsuleMoveHitsBox | ( | decCollisionCapsule * | capsule, |
| const decVector & | displacement, | ||
| decVector * | normal | ||
| ) |
Determines the distance of the given capsule to move until colliding with this box.
| virtual float decCollisionBox::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 decCollisionBox::ClearOrientation | ( | ) |
Clears the rotation and turns the box into an axis aligned box.
Retrieves the closest point on the volume.
Implements decCollisionVolume.
| bool decCollisionBox::CylinderHitsBox | ( | decCollisionCylinder * | cylinder ) |
Determines if the given cylinder hits this box.
| virtual bool decCollisionBox::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 decCollisionBox::CylinderMoveHitsBox | ( | decCollisionCylinder * | cylinder, |
| const decVector & | displacement, | ||
| decVector * | normal | ||
| ) |
Determines the distance of the given cylinder to move until colliding with this box.
| virtual float decCollisionBox::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 decCollisionBox::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 decCollisionBox::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 decCollisionBox::GetAxisAligned | ( | ) | const [inline] |
Determines if this box is axis aligned.
| const decVector& decCollisionBox::GetAxisX | ( | ) | const [inline] |
Retrieves the x axis.
| const decVector& decCollisionBox::GetAxisY | ( | ) | const [inline] |
Retrieves the y axis.
| const decVector& decCollisionBox::GetAxisZ | ( | ) | const [inline] |
Retrieves the z axis.
| const decVector& decCollisionBox::GetCenter | ( | ) | const [inline] |
Retrieves the center.
| virtual void decCollisionBox::GetEnclosingBox | ( | decCollisionBox * | box ) | [virtual] |
Retrieves the box volume best enclosing this volume.
Implements decCollisionVolume.
| virtual void decCollisionBox::GetEnclosingSphere | ( | decCollisionSphere * | sphere ) | [virtual] |
Retrieves the sphere volume best enclosing this volume.
Implements decCollisionVolume.
| const decVector& decCollisionBox::GetHalfSize | ( | ) | const [inline] |
Retrieves the half sizes.
| const decQuaternion& decCollisionBox::GetOrientation | ( | ) | const [inline] |
Retrieves the orientation.
| bool decCollisionBox::GetOriented | ( | ) | const [inline] |
Determines if this box is oriented.
| void decCollisionBox::MoveBy | ( | const decVector & | offset ) |
Moves the center of the box by the given offset.
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.
| virtual float decCollisionBox::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.
| float decCollisionBox::ProjectExtends | ( | const decVector & | axis ) | const [inline] |
Projects the extends of the box to the given axis.
| virtual bool decCollisionBox::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 decCollisionBox::SetCenter | ( | const decVector & | center ) |
Sets the center.
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 decCollisionBox::SetHalfSize | ( | const decVector & | halfSize ) |
Sets the half sizes.
All components have to be at least 0.
| void decCollisionBox::SetOrientation | ( | const decQuaternion & | orientation ) |
Sets the orientation.
| bool decCollisionBox::SphereHitsBox | ( | decCollisionSphere * | sphere ) |
Determines if the given sphere hits this box.
| virtual bool decCollisionBox::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 decCollisionBox::SphereMoveHitsBox | ( | decCollisionSphere * | sphere, |
| const decVector & | displacement, | ||
| decVector * | normal | ||
| ) |
Determines the distance of the given sphere to move until colliding with this box.
| virtual float decCollisionBox::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 decCollisionBox::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 decCollisionBox::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 decCollisionBox::Visit | ( | decCollisionVolumeVisitor * | visitor ) | [virtual] |
Visits the collision volume.
Implements decCollisionVolume.
| virtual bool decCollisionBox::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 decCollisionBox::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.
1.7.2