Public Types

decDCollisionFrustum Class Reference

Frustum collision volume. More...

#include <decDCollisionFrustum.h>

Inheritance diagram for decDCollisionFrustum:
decDCollisionVolume

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
 decDCollisionFrustum ()
 Creastes a new collision frustum with default parameters.
virtual ~decDCollisionFrustum ()
 Cleans up the collision frustum.
First Stage Dispatch
virtual bool VolumeHitsVolume (decDCollisionVolume *volume)
 Determines if this volume collides with the given one.
virtual double VolumeMoveHitsVolume (decDCollisionVolume *volume, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits another one.
Second Stage Dispatch
virtual bool SphereHitsVolume (decDCollisionSphere *sphere)
 Determines if the given sphere collides with this volume.
virtual bool CylinderHitsVolume (decDCollisionCylinder *cylinder)
 Determines if the given cylinder collides with this volume.
virtual bool CapsuleHitsVolume (decDCollisionCapsule *capsule)
 Determines if the given capsule collides with this volume.
virtual bool BoxHitsVolume (decDCollisionBox *box)
 Determines if the given box collides with this volume.
virtual bool TriangleHitsVolume (decDCollisionTriangle *triangle)
 Determines if the given triangle collides with this volume.
virtual bool FrustumHitsVolume (decDCollisionFrustum *frustum)
 Determines if the given frustum collides with this volume.
virtual double SphereMoveHitsVolume (decDCollisionSphere *sphere, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a sphere.
virtual double CylinderMoveHitsVolume (decDCollisionCylinder *cylinder, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a cylinder.
virtual double CapsuleMoveHitsVolume (decDCollisionCapsule *capsule, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a capsule.
virtual double BoxMoveHitsVolume (decDCollisionBox *box, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a box.
virtual double TriangleMoveHitsVolume (decDCollisionTriangle *triangle, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a triangle.
virtual double FrustumMoveHitsVolume (decDCollisionFrustum *frustum, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until this volume hits a frustum.
virtual double PointMoveHitsVolume (const decDVector &point, const decDVector &displacement, decDVector *normal)
 Retrieves the distance travelled along a given displacement vector until the given point hits this volume.
Enclosing Volumes
virtual void GetEnclosingSphere (decDCollisionSphere *sphere)
 Retrieves the sphere volume best enclosing this volume.
virtual void GetEnclosingBox (decDCollisionBox *box)
 Retrieves the box volume best enclosing this volume.
Miscelanous Functions
virtual decDVector ClosestPointTo (const decDVector &point)
 Retrieves the closest point on the volume.
Visiting
virtual void Visit (decDCollisionVolumeVisitor *visitor)
 Visits the collision volume.
Collision Routines
bool SphereHitsFrustum (decDCollisionSphere *sphere)
 Determines if the given sphere hits this frustum.
bool CylinderHitsFrustum (decDCollisionCylinder *cylinder)
 Determines if the given cylinder hits this frustum.
bool CapsuleHitsFrustum (decDCollisionCapsule *capsule)
 Determines if the given capsule hits this frustum.
bool BoxHitsFrustum (decDCollisionBox *box)
 Determines if the given box hits this frustum.
bool TriangleHitsFrustum (decDCollisionTriangle *triangle)
 Determines if the given triangle hits this frustum.
bool FrustumHitsFrustum (decDCollisionFrustum *frustum)
 Determines if the given frustum hits this frustum.
double SphereMoveHitsFrustum (decDCollisionSphere *sphere, const decDVector &displacement, decDVector *normal)
 Determines the distance of the given sphere to move until colliding with this frustum.
double CylinderMoveHitsFrustum (decDCollisionCylinder *cylinder, const decDVector &displacement, decDVector *normal)
 Determines the distance of the given cylinder to move until colliding with this frustum.
double CapsuleMoveHitsFrustum (decDCollisionCapsule *capsule, const decDVector &displacement, decDVector *normal)
 Determines the distance of the given capsule to move until colliding with this frustum.
double BoxMoveHitsFrustum (decDCollisionBox *box, const decDVector &displacement, decDVector *normal)
 Determines the distance of the given box to move until colliding with this frustum.
double TriangleMoveHitsFrustum (decDCollisionTriangle *triangle, const decDVector &displacement, decDVector *normal)
 Determines the distance of the given triangle to move until colliding with this frustum.
double FrustumMoveHitsFrustum (decDCollisionFrustum *frustum, const decDVector &displacement, decDVector *normal)
 Determines the distance of the given frustum to move until colliding with this frustum.
decDVector GetLeftNormal () const
decDVector GetRightNormal () const
decDVector GetTopNormal () const
decDVector GetBottomNormal () const
decDVector GetNearNormal () const
decDVector GetFarNormal () const
double GetLeftDistance () const
double GetRightDistance () const
double GetTopDistance () const
double GetBottomDistance () const
double GetNearDistance () const
double GetFarDistance () const
void SetLeftPlane (const decDVector &normal, double dist)
void SetRightPlane (const decDVector &normal, double dist)
void SetTopPlane (const decDVector &normal, double dist)
void SetBottomPlane (const decDVector &normal, double dist)
void SetNearPlane (const decDVector &normal, double dist)
void SetFarPlane (const decDVector &normal, double dist)
void SetFrustum (const decDMatrix &mat)
 Sets the frustm from the given projection matrix.
void SetFrustum (const decDVector &origin, const decDVector &r1, const decDVector &r2, const decDVector &r3, const decDVector &r4, double nearDist)
 Sets the frustum from the given parameters.
void SetFrustumBox (const decDVector &r1, const decDVector &r2, const decDVector &r3, const decDVector &r4, double nearDist)
 Sets the frustum from the given parameters.
Intersection Tests
int IntersectSphere (decDCollisionSphere *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

decDCollisionFrustum::decDCollisionFrustum (  )

Creastes a new collision frustum with default parameters.

virtual decDCollisionFrustum::~decDCollisionFrustum (  ) [virtual]

Cleans up the collision frustum.


Member Function Documentation

bool decDCollisionFrustum::BoxHitsFrustum ( decDCollisionBox box )

Determines if the given box hits this frustum.

virtual bool decDCollisionFrustum::BoxHitsVolume ( decDCollisionBox box ) [virtual]

Determines if the given box collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

double decDCollisionFrustum::BoxMoveHitsFrustum ( decDCollisionBox box,
const decDVector displacement,
decDVector 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 double decDCollisionFrustum::BoxMoveHitsVolume ( decDCollisionBox box,
const decDVector displacement,
decDVector 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 decDCollisionVolume.

bool decDCollisionFrustum::CapsuleHitsFrustum ( decDCollisionCapsule capsule )

Determines if the given capsule hits this frustum.

Warning:
Not implemented yet and always returns false.
virtual bool decDCollisionFrustum::CapsuleHitsVolume ( decDCollisionCapsule capsule ) [virtual]

Determines if the given capsule collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

double decDCollisionFrustum::CapsuleMoveHitsFrustum ( decDCollisionCapsule capsule,
const decDVector displacement,
decDVector 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 double decDCollisionFrustum::CapsuleMoveHitsVolume ( decDCollisionCapsule capsule,
const decDVector displacement,
decDVector 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 decDCollisionVolume.

virtual decDVector decDCollisionFrustum::ClosestPointTo ( const decDVector point ) [virtual]

Retrieves the closest point on the volume.

Implements decDCollisionVolume.

bool decDCollisionFrustum::CylinderHitsFrustum ( decDCollisionCylinder cylinder )

Determines if the given cylinder hits this frustum.

Warning:
Not implemented yet and always returns false.
virtual bool decDCollisionFrustum::CylinderHitsVolume ( decDCollisionCylinder cylinder ) [virtual]

Determines if the given cylinder collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

double decDCollisionFrustum::CylinderMoveHitsFrustum ( decDCollisionCylinder cylinder,
const decDVector displacement,
decDVector 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 double decDCollisionFrustum::CylinderMoveHitsVolume ( decDCollisionCylinder cylinder,
const decDVector displacement,
decDVector 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 decDCollisionVolume.

bool decDCollisionFrustum::FrustumHitsFrustum ( decDCollisionFrustum frustum )

Determines if the given frustum hits this frustum.

Warning:
Not implemented yet and always returns false.
virtual bool decDCollisionFrustum::FrustumHitsVolume ( decDCollisionFrustum frustum ) [virtual]

Determines if the given frustum collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

double decDCollisionFrustum::FrustumMoveHitsFrustum ( decDCollisionFrustum frustum,
const decDVector displacement,
decDVector 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 double decDCollisionFrustum::FrustumMoveHitsVolume ( decDCollisionFrustum frustum,
const decDVector displacement,
decDVector 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 decDCollisionVolume.

double decDCollisionFrustum::GetBottomDistance (  ) const [inline]
decDVector decDCollisionFrustum::GetBottomNormal (  ) const [inline]
virtual void decDCollisionFrustum::GetEnclosingBox ( decDCollisionBox box ) [virtual]

Retrieves the box volume best enclosing this volume.

Implements decDCollisionVolume.

virtual void decDCollisionFrustum::GetEnclosingSphere ( decDCollisionSphere sphere ) [virtual]

Retrieves the sphere volume best enclosing this volume.

Implements decDCollisionVolume.

double decDCollisionFrustum::GetFarDistance (  ) const [inline]
decDVector decDCollisionFrustum::GetFarNormal (  ) const [inline]
double decDCollisionFrustum::GetLeftDistance (  ) const [inline]
decDVector decDCollisionFrustum::GetLeftNormal (  ) const [inline]
double decDCollisionFrustum::GetNearDistance (  ) const [inline]
decDVector decDCollisionFrustum::GetNearNormal (  ) const [inline]
double decDCollisionFrustum::GetRightDistance (  ) const [inline]
decDVector decDCollisionFrustum::GetRightNormal (  ) const [inline]
double decDCollisionFrustum::GetTopDistance (  ) const [inline]
decDVector decDCollisionFrustum::GetTopNormal (  ) const [inline]
int decDCollisionFrustum::IntersectSphere ( decDCollisionSphere sphere )

Determines if the given sphere intersects this frustum.

Returns:
eIntersectType indicating the intersection type
virtual double decDCollisionFrustum::PointMoveHitsVolume ( const decDVector point,
const decDVector displacement,
decDVector 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 decDCollisionVolume.

void decDCollisionFrustum::SetBottomPlane ( const decDVector normal,
double  dist 
)
void decDCollisionFrustum::SetFarPlane ( const decDVector normal,
double  dist 
)
void decDCollisionFrustum::SetFrustum ( const decDMatrix mat )

Sets the frustm from the given projection matrix.

void decDCollisionFrustum::SetFrustum ( const decDVector origin,
const decDVector r1,
const decDVector r2,
const decDVector r3,
const decDVector r4,
double  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 decDCollisionFrustum::SetFrustumBox ( const decDVector r1,
const decDVector r2,
const decDVector r3,
const decDVector r4,
double  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 decDCollisionFrustum::SetLeftPlane ( const decDVector normal,
double  dist 
)
void decDCollisionFrustum::SetNearPlane ( const decDVector normal,
double  dist 
)
void decDCollisionFrustum::SetRightPlane ( const decDVector normal,
double  dist 
)
void decDCollisionFrustum::SetTopPlane ( const decDVector normal,
double  dist 
)
bool decDCollisionFrustum::SphereHitsFrustum ( decDCollisionSphere sphere )

Determines if the given sphere hits this frustum.

virtual bool decDCollisionFrustum::SphereHitsVolume ( decDCollisionSphere sphere ) [virtual]

Determines if the given sphere collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

double decDCollisionFrustum::SphereMoveHitsFrustum ( decDCollisionSphere sphere,
const decDVector displacement,
decDVector 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 double decDCollisionFrustum::SphereMoveHitsVolume ( decDCollisionSphere sphere,
const decDVector displacement,
decDVector 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 decDCollisionVolume.

bool decDCollisionFrustum::TriangleHitsFrustum ( decDCollisionTriangle triangle )

Determines if the given triangle hits this frustum.

Warning:
Not implemented yet and always returns false.
virtual bool decDCollisionFrustum::TriangleHitsVolume ( decDCollisionTriangle triangle ) [virtual]

Determines if the given triangle collides with this volume.

The subclass has to dispatch to a collision function here.

Implements decDCollisionVolume.

double decDCollisionFrustum::TriangleMoveHitsFrustum ( decDCollisionTriangle triangle,
const decDVector displacement,
decDVector 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 double decDCollisionFrustum::TriangleMoveHitsVolume ( decDCollisionTriangle triangle,
const decDVector displacement,
decDVector 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 decDCollisionVolume.

virtual void decDCollisionFrustum::Visit ( decDCollisionVolumeVisitor visitor ) [virtual]

Visits the collision volume.

Implements decDCollisionVolume.

virtual bool decDCollisionFrustum::VolumeHitsVolume ( decDCollisionVolume volume ) [virtual]

Determines if this volume collides with the given one.

The subclass has to dispatch to a second stage function here.

Implements decDCollisionVolume.

virtual double decDCollisionFrustum::VolumeMoveHitsVolume ( decDCollisionVolume volume,
const decDVector displacement,
decDVector 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 decDCollisionVolume.


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