decCollisionSphere Class Reference

Sphere collision volume. More...

#include <decCollisionSphere.h>

Inheritance diagram for decCollisionSphere:
decCollisionVolume

List of all members.

Public Member Functions

Constructors and Destructors
 decCollisionSphere ()
 Creates a new collision sphere with no radius located at the origin.
 decCollisionSphere (const decVector &center, float radius)
 Creates a new collision sphere with the given parameters.
 ~decCollisionSphere ()
 Cleans up the collision sphere.
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 SphereHitsSphere (decCollisionSphere *sphere)
 Determines if the given sphere collides with this sphere.
float SphereMoveHitsSphere (decCollisionSphere *sphere, const decVector &displacement, decVector *normal)
 Determines the distance of the given sphere to move until colliding with this sphere.
Parameters
const decVectorGetCenter () const
 Retrieves the center point of the sphere.
float GetRadius () const
 Retrieves the radius of the sphere.
float GetSquareRadius () const
 Retrieves the sqaured radius of the sphere.
void SetCenter (const decVector &center)
 Sets the center point of the sphere.
void SetRadius (float radius)
 Sets the radius of the sphere.
void SetAll (const decVector &center, float radius)
 Sets all sphere parameters at once.

Detailed Description

Sphere collision volume.

Defines a collision volume in the shape of a sphere. The sphere is defined by a center point and a radius. The surface of the sphere is considered to be part of the volume.

Author:
Plüss Roland
Version:
1.0
Date:
2008

Constructor & Destructor Documentation

decCollisionSphere::decCollisionSphere (  )

Creates a new collision sphere with no radius located at the origin.

decCollisionSphere::decCollisionSphere ( const decVector center,
float  radius 
)

Creates a new collision sphere with the given parameters.

Parameters:
centerCenter point of sphere
radiusRadius of sphere beeing at least 0
decCollisionSphere::~decCollisionSphere (  )

Cleans up the collision sphere.


Member Function Documentation

virtual bool decCollisionSphere::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 decCollisionSphere::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.

virtual bool decCollisionSphere::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.

virtual float decCollisionSphere::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.

virtual decVector decCollisionSphere::ClosestPointTo ( const decVector point ) [virtual]

Retrieves the closest point on the volume.

Implements decCollisionVolume.

virtual bool decCollisionSphere::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.

virtual float decCollisionSphere::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 decCollisionSphere::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 decCollisionSphere::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.

const decVector& decCollisionSphere::GetCenter (  ) const [inline]

Retrieves the center point of the sphere.

virtual void decCollisionSphere::GetEnclosingBox ( decCollisionBox box ) [virtual]

Retrieves the box volume best enclosing this volume.

Implements decCollisionVolume.

virtual void decCollisionSphere::GetEnclosingSphere ( decCollisionSphere sphere ) [virtual]

Retrieves the sphere volume best enclosing this volume.

Implements decCollisionVolume.

float decCollisionSphere::GetRadius (  ) const [inline]

Retrieves the radius of the sphere.

float decCollisionSphere::GetSquareRadius (  ) const [inline]

Retrieves the sqaured radius of the sphere.

virtual decVector decCollisionSphere::NormalAtPoint ( const decVector 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 decCollisionVolume.

virtual float decCollisionSphere::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 decCollisionSphere::RayHitsVolume ( const decVector rayOrigin,
const decVector rayDirection,
float &  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 decCollisionVolume.

void decCollisionSphere::SetAll ( const decVector center,
float  radius 
)

Sets all sphere parameters at once.

Parameters:
centerCenter point of sphere
radiusRadius of sphere beeing at least 0
void decCollisionSphere::SetCenter ( const decVector center )

Sets the center point of the sphere.

void decCollisionSphere::SetRadius ( float  radius )

Sets the radius of the sphere.

Parameters:
radiusRadius of sphere beeing at least 0
bool decCollisionSphere::SphereHitsSphere ( decCollisionSphere sphere )

Determines if the given sphere collides with this sphere.

virtual bool decCollisionSphere::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 decCollisionSphere::SphereMoveHitsSphere ( decCollisionSphere sphere,
const decVector displacement,
decVector normal 
)

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

Warning:
Function is not implemented yet and always returns 1.
virtual float decCollisionSphere::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 decCollisionSphere::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 decCollisionSphere::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 decCollisionSphere::Visit ( decCollisionVolumeVisitor visitor ) [virtual]

Visits the collision volume.

Implements decCollisionVolume.

virtual bool decCollisionSphere::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 decCollisionSphere::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.


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