A virtual derived class of GameObject that allows the GameObject to test for collison. More...

#include <Collidable.h>

Inheritance diagram for Collidable:

Detailed Description

A virtual derived class of GameObject that allows the GameObject to test for collison.

A class that inherits from Collidable gains access to the Collision() function. This allows the user to execute code every time a collision is registered. This class also contains functions and entities for storing/getting information about the collision model.

Public Member Functions

virtual void CollisionTerrain ()
 Function that is called when collision with Terrain is triggered. More...
 
const CollisionVolumeGetCollisionVolume () const
 Function to return a reference to the Collision Volume. More...
 
const CollisionVolumeBSphereGetDefualtBSphere () const
 Function to return a reference to the defualt Collision Volume. More...
 
- Public Member Functions inherited from GameObject
void SubmitEntry ()
 Public Function to register a call for the GameObject's SceneEntry() function. More...
 
void SubmitExit ()
 Public Function to register a call for the GameObject's SceneEntry() function. More...
 

Protected Member Functions

virtual void Collision (Collidable *ptrCol)
 Function that is called when collision with another Collidable GameObject is triggered. More...
 
void SetColliderModel (Model *mod, VolumeType volume=VolumeType::BSPHERE)
 Function to set the Collider Model and Collision Volume of this Collidable GameObject. More...
 
void UpdateCollisionData (Matrix &mat)
 Function to update the current Collidable placement. More...
 
template<typename C >
void CollisionRegister (C *ptrCollision)
 Function to register this Collidable GameObject for collision. More...
 
template<typename C >
void CollisionDeregister (C *ptrCollision)
 Function to deregister this Collidable GameObject from collision. More...
 
- Protected Member Functions inherited from GameObject
virtual void SceneEntry ()=0
 Function which is called upon a registered scene entry. More...
 
virtual void SceneExit ()=0
 Function which is called upon a registered scene exit. More...
 

Protected Attributes

Model * pColModel
 
CollisionVolumeColVolume
 

Member Function Documentation

virtual void Collidable::Collision ( Collidable ptrCol)
protectedvirtual

Function that is called when collision with another Collidable GameObject is triggered.

This is a virtual function to be overriden by the user for each Collidable GameObject that is paired for Collision.

The Collision function is called every frame that the registered and paired Collidable GameObjects are colliding. To register the current Collidable GameObject for collision, see CollisionRegister() and CollisionDeregister(). To pair Collidable GameObjects for testing, see the Scene::SetCollisionPair() and Scene::SetCollisionSelf() functions.

Parameters
ptrColPointer to the Collidable GameObject that is colliding with the current Collidable GameObject.
template<typename C >
void Collidable::CollisionDeregister ( C *  ptrCollision)
inlineprotected

Function to deregister this Collidable GameObject from collision.

Deregistering the current Collidable GameObject removes this object from the list of Collidable's to be checked for collision each frame.

An example use of this function would go as follows:

Class::SceneExit(){
...
CollisionDeregister<Class>(*this);
}
template<typename C >
void Collidable::CollisionRegister ( C *  ptrCollision)
inlineprotected

Function to register this Collidable GameObject for collision.

Registering the current Collidable GameObject adds this object to the list of Collidable's to be checked for collision each frame.

An example use of this function would go as follows:

Class::SceneEntry(){
...
CollisionRegister<Class>(*this);
}
virtual void Collidable::CollisionTerrain ( )
virtual

Function that is called when collision with Terrain is triggered.

This is a virtual function to be overriden by the user for the Collidable GameObject that is paired for Collision with Terrain.

The CollisionTerrain function is called every frame that the registered Collidable is colliding with Terrain. To register the current Collidable GameObject for Terrain Collision, see the Scene::SetCollisionTerrain()

const CollisionVolume& Collidable::GetCollisionVolume ( ) const

Function to return a reference to the Collision Volume.

This function returns a reference to this Collidable GameObject's CollisionVolume.

Returns
const reference to the class's Collision volume
const CollisionVolumeBSphere& Collidable::GetDefualtBSphere ( ) const

Function to return a reference to the defualt Collision Volume.

This function returns a reference to this Collidable GameObject's defualt BSphere CollisionVolume.

Returns
const reference to the class's BSphere Collision volume
void Collidable::SetColliderModel ( Model *  mod,
VolumeType  volume = VolumeType::BSPHERE 
)
protected

Function to set the Collider Model and Collision Volume of this Collidable GameObject.

This function assigns a model to the pointer pColModel and initialized the Collision Volume based on a VolumeType enum.

Parameters
modPointer to model that this class will reference.
volumeVolumeType enum for the type of collision volume to use (defualts to BSHPERE)
void Collidable::UpdateCollisionData ( Matrix &  mat)
protected

Function to update the current Collidable placement.

This function updates the current placement of the collision data based on the world matrix passed in as parameter mat.

Parameters
matWorld Matrix reference.

Member Data Documentation

CollisionVolume* Collidable::ColVolume
protected

Collision Volume of the model stored as a CollisionVolume

Model* Collidable::pColModel
protected

Pointer to the model that will be tested for collision