Public Types

decCollisionFrustum Class Reference

Frustum collision volume. More...

#include <decCollisionFrustum.h>

Inheritance diagram for decCollisionFrustum:
decCollisionVolume

List of all members.

Public Types

enum  eIntersectType { eitOutside = -1, eitIntersect = 0, eitInside = 1 }
 

Enumerator for collision type.

More...

Public Member Functions

Constructors and Destructors
 decCollisionFrustum ()
 Creastes a new collision frustum with default parameters.
virtual ~decCollisionFrustum ()
 Cleans up the collision frustum.
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.
Visiting
virtual void Visit (decCollisionVolumeVisitor *visitor)
 Visits the collision volume.
Collision Routines
bool SphereHitsFrustum (decCollisionSphere *sphere)
 Determines if the given sphere hits this frustum.
bool CylinderHitsFrustum (decCollisionCylinder *cylinder)
 Determines if the given cylinder hits this frustum.
bool CapsuleHitsFrustum (decCollisionCapsule *capsule)
 Determines if the given capsule hits this frustum.
bool BoxHitsFrustum (decCollisionBox *box)
 Determines if the given box hits this frustum.
bool TriangleHitsFrustum (decCollisionTriangle *triangle)
 Determines if the given triangle hits this frustum.
bool FrustumHitsFrustum (decCollisionFrustum *frustum)
 Determines if the given frustum hits this frustum.
float SphereMoveHitsFrustum (decCollisionSphere *sphere, const decVector &displacement, decVector *normal)
 Determines the distance of the given sphere to move until colliding with this frustum.
float CylinderMoveHitsFrustum (decCollisionCylinder *cylinder, const decVector &displacement, decVector *normal)
 Determines the distance of the given cylinder to move until colliding with this frustum.
float CapsuleMoveHitsFrustum (decCollisionCapsule *capsule, const decVector &displacement, decVector *normal)
 Determines the distance of the given capsule to move until colliding with this frustum.
float BoxMoveHitsFrustum (decCollisionBox *box, const decVector &displacement, decVector *normal)
 Determines the distance of the given box to move until colliding with this frustum.
float TriangleMoveHitsFrustum (decCollisionTriangle *triangle, const decVector &displacement, decVector *normal)
 Determines the distance of the given triangle to move until colliding with this frustum.
float FrustumMoveHitsFrustum (decCollisionFrustum *frustum, const decVector &displacement, decVector *normal)
 Determines the distance of the given frustum to move until colliding with this frustum.
decVector GetLeftNormal () const
decVector GetRightNormal () const
decVector GetTopNormal () const
decVector GetBottomNormal () const
decVector GetNearNormal () const
decVector GetFarNormal () const
float GetLeftDistance () const
float GetRightDistance () const
float GetTopDistance () const
float GetBottomDistance () const
float GetNearDistance () const
float GetFarDistance () const
void SetLeftPlane (const decVector &normal, float dist)
void SetRightPlane (const decVector &normal, float dist)
void SetTopPlane (const decVector &normal, float dist)
void SetBottomPlane (const decVector &normal, float dist)
void SetNearPlane (const decVector &normal, float dist)
void SetFarPlane (const decVector &normal, float dist)
void SetFrustum (const decDMatrix &mat)
 Sets the frustm from the given projection matrix.
void SetFrustum (const decVector &origin, const decVector &r1, const decVector &r2, const decVector &r3, const decVector &r4, float nearDist)
 Sets the frustum from the given parameters.
void SetFrustumBox (const decVector &r1, const decVector &r2, const decVector &r3, const decVector &r4, float nearDist)
 Sets the frustum from the given parameters.
Intersection Tests
int IntersectSphere (decCollisionSphere *sphere)
 Determines if the given sphere intersects this frustum.

Detailed Description

Frustum collision volume.

Defines a collision volume in the shape of a view frustum. A view frustum is a pyramid with capped top. Such frustums are used mainly for culling objects inside a camera view. The frustum is defined by the six planes forming the sides of the pyramid. The planes are defined by a normal and the distance to the origin. A frustum is best set from a projection matrix. The normals of the planes are considered to point inside the frustum.

The planes in this frustum are labeled like the pyramid is laying on the ground. Hence left, right, top and bottom refer to the sides of the frustum surrounding it. Near and far refer to the capped pinacle and the base of the frustum.

Author:
Plüss Roland
Version:
1.0
Date:
2008
Warning:
This class is partially implemented. See collision functions for more informations.
Todo:
  • Implementing CylinderHitsFrustum
  • Implementing CapsuleHitsFrustum
  • Implementing TriangleHitsFrustum
  • Implementing FrustumHitsFrustum

Member Enumeration Documentation

Enumerator for collision type.

Enumerator:
eitOutside 

Does not intersect frustum.

eitIntersect 

Intersects frustum.

eitInside 

Is fully inside frustum.


Constructor & Destructor Documentation

decCollisionFrustum::decCollisionFrustum (  )

Creastes a new collision frustum with default parameters.

virtual decCollisionFrustum::~decCollisionFrustum (  ) [virtual]

Cleans up the collision frustum.


Member Function Documentation

bool decCollisionFrustum::BoxHitsFrustum ( decCollisionBox box )

Determines if the given box hits this frustum.

virtual bool decCollisionFrustum::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 decCollisionFrustum::BoxMoveHitsFrustum ( decCollisionBox box,
const decVector displacement,
decVector normal 
)

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

Warning:
Function is not implemented yet and always returns 1.
virtual float decCollisionFrustum::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 decCollisionFrustum::CapsuleHitsFrustum ( decCollisionCapsule capsule )

Determines if the given capsule hits this frustum.

Warning:
Not implemented yet and always returns false.
virtual bool decCollisionFrustum::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 decCollisionFrustum::CapsuleMoveHitsFrustum ( decCollisionCapsule capsule,
const decVector displacement,
decVector normal 
)

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

Warning:
Function is not implemented yet and always returns 1.
virtual float decCollisionFrustum::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 decCollisionFrustum::ClosestPointTo ( const decVector point ) [virtual]

Retrieves the closest point on the volume.

Implements decCollisionVolume.

bool decCollisionFrustum::CylinderHitsFrustum ( decCollisionCylinder cylinder )

Determines if the given cylinder hits this frustum.

Warning:
Not implemented yet and always returns false.
virtual bool decCollisionFrustum::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 decCollisionFrustum::CylinderMoveHitsFrustum ( decCollisionCylinder cylinder,
const decVector displacement,
decVector normal 
)

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

Warning:
Function is not implemented yet and always returns 1.
virtual float decCollisionFrustum::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.

bool decCollisionFrustum::FrustumHitsFrustum ( decCollisionFrustum frustum )

Determines if the given frustum hits this frustum.

Warning:
Not implemented yet and always returns false.
virtual bool decCollisionFrustum::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.

float decCollisionFrustum::FrustumMoveHitsFrustum ( decCollisionFrustum frustum,
const decVector displacement,
decVector normal 
)

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

Warning:
Function is not implemented yet and always returns 1.
virtual float decCollisionFrustum::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.

float decCollisionFrustum::GetBottomDistance (  ) const [inline]
decVector decCollisionFrustum::GetBottomNormal (  ) const [inline]
virtual void decCollisionFrustum::GetEnclosingBox ( decCollisionBox box ) [virtual]

Retrieves the box volume best enclosing this volume.

Implements decCollisionVolume.

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

Retrieves the sphere volume best enclosing this volume.

Implements decCollisionVolume.

float decCollisionFrustum::GetFarDistance (  ) const [inline]
decVector decCollisionFrustum::GetFarNormal (  ) const [inline]
float decCollisionFrustum::GetLeftDistance (  ) const [inline]
decVector decCollisionFrustum::GetLeftNormal (  ) const [inline]
float decCollisionFrustum::GetNearDistance (  ) const [inline]
decVector decCollisionFrustum::GetNearNormal (  ) const [inline]
float decCollisionFrustum::GetRightDistance (  ) const [inline]
decVector decCollisionFrustum::GetRightNormal (  ) const [inline]
float decCollisionFrustum::GetTopDistance (  ) const [inline]
decVector decCollisionFrustum::GetTopNormal (  ) const [inline]
int decCollisionFrustum::IntersectSphere ( decCollisionSphere sphere )

Determines if the given sphere intersects this frustum.

Returns:
eIntersectType indicating the intersection type
virtual float decCollisionFrustum::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.

void decCollisionFrustum::SetBottomPlane ( const decVector normal,
float  dist 
)
void decCollisionFrustum::SetFarPlane ( const decVector normal,
float  dist 
)
void decCollisionFrustum::SetFrustum ( const decDMatrix mat )

Sets the frustm from the given projection matrix.

void decCollisionFrustum::SetFrustum ( const decVector origin,
const decVector r1,
const decVector r2,
const decVector r3,
const decVector r4,
float  nearDist 
)

Sets the frustum from the given parameters.

Parameters:
originPinacle of the uncapped frustum.
r1Top-Left corner part of the left/top/far planes
r2Top-Right corner part of the right/top/far planes
r3Bottom-Right corner part of the right/bottom/far planes
r4Bottom-Left corner part of the left/bottom/far planes
nearDistDistance from uncapped frustum pinacle to the near plane
void decCollisionFrustum::SetFrustumBox ( const decVector r1,
const decVector r2,
const decVector r3,
const decVector r4,
float  nearDist 
)

Sets the frustum from the given parameters.

The origin of the frustum is set to the 0 vector.

Parameters:
r1Top-Left corner part of the left/top/far planes
r2Top-Right corner part of the right/top/far planes
r3Bottom-Right corner part of the right/bottom/far planes
r4Bottom-Left corner part of the left/bottom/far planes
nearDistDistance from uncapped frustum pinacle to the near plane
void decCollisionFrustum::SetLeftPlane ( const decVector normal,
float  dist 
)
void decCollisionFrustum::SetNearPlane ( const decVector normal,
float  dist 
)
void decCollisionFrustum::SetRightPlane ( const decVector normal,
float  dist 
)
void decCollisionFrustum::SetTopPlane ( const decVector normal,
float  dist 
)
bool decCollisionFrustum::SphereHitsFrustum ( decCollisionSphere sphere )

Determines if the given sphere hits this frustum.

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

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

Warning:
Function is not implemented yet and always returns 1.
virtual float decCollisionFrustum::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.

bool decCollisionFrustum::TriangleHitsFrustum ( decCollisionTriangle triangle )

Determines if the given triangle hits this frustum.

Warning:
Not implemented yet and always returns false.
virtual bool decCollisionFrustum::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.

float decCollisionFrustum::TriangleMoveHitsFrustum ( decCollisionTriangle triangle,
const decVector displacement,
decVector normal 
)

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

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

Visits the collision volume.

Implements decCollisionVolume.

virtual bool decCollisionFrustum::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 decCollisionFrustum::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: