Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes

sp::scene::CollisionGraph Class Reference
[Collision System]

#include <spCollisionGraph.hpp>

List of all members.

Public Member Functions

 CollisionGraph ()
virtual ~CollisionGraph ()
virtual CollisionMaterialcreateMaterial ()
 Creates a new collision material and returns a pointer to the new CollisionMaterial object.
virtual void deleteMaterial (CollisionMaterial *Material)
 Deletes the specified collision material.
virtual void addCollisionNode (CollisionNode *Node)
 Adds the specified collision node into the collision graph. This is similiar to the "addSceneNode" function of the SceneGraph class.
virtual void removeCollisionNode (CollisionNode *Node)
 Removes the specified collision node from the collision graph.
virtual CollisionSpherecreateSphere (CollisionMaterial *Material, scene::SceneNode *Node, f32 Radius)
virtual CollisionCapsulecreateCapsule (CollisionMaterial *Material, scene::SceneNode *Node, f32 Radius, f32 Height)
virtual CollisionCylindercreateCylinder (CollisionMaterial *Material, scene::SceneNode *Node, f32 Radius, f32 Height)
virtual CollisionConecreateCone (CollisionMaterial *Material, scene::SceneNode *Node, f32 Radius, f32 Height)
virtual CollisionBoxcreateBox (CollisionMaterial *Material, scene::SceneNode *Node, const dim::aabbox3df &Box)
virtual CollisionPlanecreatePlane (CollisionMaterial *Material, scene::SceneNode *Node, const dim::plane3df &Plane)
virtual CollisionMeshcreateMesh (CollisionMaterial *Material, scene::Mesh *Mesh, u8 MaxTreeLevel=DEF_KDTREE_LEVEL)
virtual CollisionMeshcreateMeshList (CollisionMaterial *Material, const std::list< Mesh * > &MeshList, u8 MaxTreeLevel=DEF_KDTREE_LEVEL)
virtual bool deleteNode (CollisionNode *Node)
 Deletes the given collision node and returns true on succeed.
virtual CharacterControllercreateCharacterController (CollisionMaterial *Material, scene::SceneNode *Node, f32 Radius, f32 Height)
virtual bool deleteCharacterController (CharacterController *Object)
virtual void clearScene (bool isDeleteNodes=true, bool isDeleteMaterials=true, bool isDeleteCharacters=true)
 Clears the whole scene from the specified objects.
virtual bool checkIntersection (const dim::line3df &Line, bool ExcludeCorners=false, const IntersectionCriteriaCallback &CriteriaCallback=0) const
virtual void findIntersections (const dim::line3df &Line, std::list< SIntersectionContact > &ContactList, bool SearchBidirectional=false, const IntersectionCriteriaCallback &CriteriaCallback=0) const
virtual void updateScene ()
 Performs all collision resolving for the whole collision graph.
const std::list< CollisionNode * > & getNodeList () const
const std::list
< CollisionMaterial * > & 
getMaterialList () const
TreeNodegetRootTreeNode () const
 Returns pointer to the root tree node.
std::list< SIntersectionContactfindIntersections (const dim::line3df &Line, bool SearchBidirectional=false, const IntersectionCriteriaCallback &CriteriaCallback=0) const
 Makes intersection tests with the whole collision graph.

Static Public Member Functions

static void sortContactList (const dim::vector3df &LineStart, std::list< SIntersectionContact > &ContactList)

Protected Member Functions

virtual void findIntersectionsUnidirectional (const dim::line3df &Line, std::list< SIntersectionContact > &ContactList, const IntersectionCriteriaCallback &CriteriaCallback) const
template<class T >
T * addCollNode (T *Node)

Protected Attributes

std::list< CollisionNode * > CollNodes_
std::list< CollisionMaterial * > CollMaterials_
std::list< CharacterController * > CharacterControllers_
TreeNodeRootTreeNode_

Detailed Description

This is the new collision scene graph use for real-time intersection tests, collision detection and resolving. Here is a small code example on how to use the new collision system.

// Define the collision contact callback to determine when a collision has been detected.
void CharCollCallback(CollisionMaterial* Material, CollisionNode* Node, CollisionNode* Rival)
{
    // do something with this information ...
}

// ...

// Create a collision material for the world and for the character.
CollisionMaterial* CollMatWorld = spCollGraph->createMaterial();
CollisionMaterial* CollMatChar = spCollGraph->createMaterial();

// Set the world material as rival for the character material.
// Now characters will collide with the world
CollMatChar->addRivalCollisionMaterial(CollMatWorld);

// Set the collision contact callback for the character material.
CollMatChar->setCollisionContactCallback(CharCollCallback);

// Create a world collision node (mesh).
CollisionMesh* WorldCollNode = spCollGraph->createMesh(CollMatWorld, WorldMesh);

// Create a character collision node (capsule).
CollisionCapsule* CharCollNode = spCollGraph->createCapsule(CollMatChar, CharSceneNode, CharRadius, CharHeight);

// ...

// Update the scene for collisions.
spCollGraph->updateScene();

The following models for collision- detection and resolving are supported:


Constructor & Destructor Documentation

sp::scene::CollisionGraph::CollisionGraph (  ) 
sp::scene::CollisionGraph::~CollisionGraph (  )  [virtual]

Member Function Documentation

void sp::scene::CollisionGraph::addCollisionNode ( CollisionNode Node  )  [virtual]

Adds the specified collision node into the collision graph. This is similiar to the "addSceneNode" function of the SceneGraph class.

template<class T >
T* sp::scene::CollisionGraph::addCollNode ( T *  Node  )  [inline, protected]
bool sp::scene::CollisionGraph::checkIntersection ( const dim::line3df Line,
bool  ExcludeCorners = false,
const IntersectionCriteriaCallback CriteriaCallback = 0 
) const [virtual]

Makes an intersection test with the whole collision graph.

Parameters:
[in] Line Specifies the line which is to be tested for intersection.
[in] ExcludeCorners Specifies whether intersections with the corners are to be ignored or not. If true a tolerance value is used for rounding-error avoidance.
[in] CriteriaCallback Specifies the intersection criteria callback. Use this optional parameter to sort individual collision nodes out.
Returns:
True if any intersection has been detected.
Note:
In most cases this is much faster than getting a list of all intersections. So if you only need to know if any intersection has been detected, use this function instead of "findIntersections".
See also:
findIntersections
IntersectionCriteriaCallback
void sp::scene::CollisionGraph::clearScene ( bool  isDeleteNodes = true,
bool  isDeleteMaterials = true,
bool  isDeleteCharacters = true 
) [virtual]

Clears the whole scene from the specified objects.

CollisionBox * sp::scene::CollisionGraph::createBox ( CollisionMaterial Material,
scene::SceneNode Node,
const dim::aabbox3df Box 
) [virtual]

Creates a new collision box.

Parameters:
Box,: Specifies the box size.
Returns:
Pointer to the new CollisionBox object.
See also:
createSphere
CollisionCapsule * sp::scene::CollisionGraph::createCapsule ( CollisionMaterial Material,
scene::SceneNode Node,
f32  Radius,
f32  Height 
) [virtual]

Creates a new collision capsule.

Parameters:
Height,: Specifies the capsule's height. This can not be smaller than 0 and the whole capsule's height is (Height + 2 * Radius).
Returns:
Pointer to the new CollisionCapsule object.
See also:
createSphere
CharacterController * sp::scene::CollisionGraph::createCharacterController ( CollisionMaterial Material,
scene::SceneNode Node,
f32  Radius,
f32  Height 
) [virtual]

Creates a new character controller.

Returns:
Pointer to the new CharacterController object or null if an error occured.
See also:
createCapsule
CollisionCone * sp::scene::CollisionGraph::createCone ( CollisionMaterial Material,
scene::SceneNode Node,
f32  Radius,
f32  Height 
) [virtual]
CollisionCylinder * sp::scene::CollisionGraph::createCylinder ( CollisionMaterial Material,
scene::SceneNode Node,
f32  Radius,
f32  Height 
) [virtual]
CollisionMaterial * sp::scene::CollisionGraph::createMaterial (  )  [virtual]

Creates a new collision material and returns a pointer to the new CollisionMaterial object.

CollisionMesh * sp::scene::CollisionGraph::createMesh ( CollisionMaterial Material,
scene::Mesh Mesh,
u8  MaxTreeLevel = DEF_KDTREE_LEVEL 
) [virtual]

Creates a new collision mesh.

Parameters:
Mesh,: Specifies the mesh which is to be used for the collision.
MaxTreeLevel,: Specifies the maximal tree hierarchy level.
Returns:
Pointer to the new CollisionMesh object.
See also:
createSphere
CollisionMesh * sp::scene::CollisionGraph::createMeshList ( CollisionMaterial Material,
const std::list< Mesh * > &  MeshList,
u8  MaxTreeLevel = DEF_KDTREE_LEVEL 
) [virtual]

Creates a new collision mesh out of several meshes.

See also:
createMesh
CollisionPlane * sp::scene::CollisionGraph::createPlane ( CollisionMaterial Material,
scene::SceneNode Node,
const dim::plane3df Plane 
) [virtual]

Creates a new collision plane.

Parameters:
Plane,: Specifies the plane.
Returns:
Pointer to the new CollisionPlane object.
See also:
createSphere
CollisionSphere * sp::scene::CollisionGraph::createSphere ( CollisionMaterial Material,
scene::SceneNode Node,
f32  Radius 
) [virtual]

Creates a new collision sphere.

Parameters:
Material,: Specifies the collision material. This may also be 0.
Node,: Specifies the scene node object. This must not be 0!
Radius,: Specifies the sphere's radius.
Returns:
Pointer to the new CollisionSphere object.
bool sp::scene::CollisionGraph::deleteCharacterController ( CharacterController Object  )  [virtual]
void sp::scene::CollisionGraph::deleteMaterial ( CollisionMaterial Material  )  [virtual]

Deletes the specified collision material.

bool sp::scene::CollisionGraph::deleteNode ( CollisionNode Node  )  [virtual]

Deletes the given collision node and returns true on succeed.

std::list<SIntersectionContact> sp::scene::CollisionGraph::findIntersections ( const dim::line3df Line,
bool  SearchBidirectional = false,
const IntersectionCriteriaCallback CriteriaCallback = 0 
) const [inline]

Makes intersection tests with the whole collision graph.

void sp::scene::CollisionGraph::findIntersections ( const dim::line3df Line,
std::list< SIntersectionContact > &  ContactList,
bool  SearchBidirectional = false,
const IntersectionCriteriaCallback CriteriaCallback = 0 
) const [virtual]

Makes intersection tests with the whole collision graph.

Parameters:
[in] Line Specifies the line which is to be tested for intersection.
[out] ContactList Specifies the list where the intersection result are to be stored.
[in] SearchBidirectional Specifies whether the search will be performed
[in] CriteriaCallback Specifies the intersection criteria callback. Use this optional bidirectional (two times) or not. By default false.
See also:
IntersectionCriteriaCallback
void sp::scene::CollisionGraph::findIntersectionsUnidirectional ( const dim::line3df Line,
std::list< SIntersectionContact > &  ContactList,
const IntersectionCriteriaCallback CriteriaCallback 
) const [protected, virtual]
const std::list<CollisionMaterial*>& sp::scene::CollisionGraph::getMaterialList (  )  const [inline]
const std::list<CollisionNode*>& sp::scene::CollisionGraph::getNodeList (  )  const [inline]
TreeNode* sp::scene::CollisionGraph::getRootTreeNode (  )  const [inline]

Returns pointer to the root tree node.

void sp::scene::CollisionGraph::removeCollisionNode ( CollisionNode Node  )  [virtual]

Removes the specified collision node from the collision graph.

void sp::scene::CollisionGraph::sortContactList ( const dim::vector3df LineStart,
std::list< SIntersectionContact > &  ContactList 
) [static]
void sp::scene::CollisionGraph::updateScene (  )  [virtual]

Performs all collision resolving for the whole collision graph.

TODO! -> optimize for-loop againts none-resolving objects TODO! -> distinguish between static and dynamic objects


Member Data Documentation


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines