#include <spCollisionGraph.hpp>
Public Member Functions | |
| CollisionGraph () | |
| virtual | ~CollisionGraph () |
| virtual CollisionMaterial * | createMaterial () |
| 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 CollisionSphere * | createSphere (CollisionMaterial *Material, scene::SceneNode *Node, f32 Radius) |
| virtual CollisionCapsule * | createCapsule (CollisionMaterial *Material, scene::SceneNode *Node, f32 Radius, f32 Height) |
| virtual CollisionCylinder * | createCylinder (CollisionMaterial *Material, scene::SceneNode *Node, f32 Radius, f32 Height) |
| virtual CollisionCone * | createCone (CollisionMaterial *Material, scene::SceneNode *Node, f32 Radius, f32 Height) |
| virtual CollisionBox * | createBox (CollisionMaterial *Material, scene::SceneNode *Node, const dim::aabbox3df &Box) |
| virtual CollisionPlane * | createPlane (CollisionMaterial *Material, scene::SceneNode *Node, const dim::plane3df &Plane) |
| virtual CollisionMesh * | createMesh (CollisionMaterial *Material, scene::Mesh *Mesh, u8 MaxTreeLevel=DEF_KDTREE_LEVEL) |
| virtual CollisionMesh * | createMeshList (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 CharacterController * | createCharacterController (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 |
| TreeNode * | getRootTreeNode () const |
| Returns pointer to the root tree node. | |
| std::list< SIntersectionContact > | findIntersections (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_ |
| TreeNode * | RootTreeNode_ |
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:
Sphere-to-Sphere Sphere-to-Capsule Sphere-to-Cone [incomplete] Sphere-to-Cylinder [incomplete] Sphere-to-Box Sphere-to-Plane Sphere-to-Mesh Capsule-to-Sphere Capsule-to-Capsule Capsule-to-Box Capsule-to-Plane Capsule-to-Mesh Box-to-Plane | sp::scene::CollisionGraph::CollisionGraph | ( | ) |
| sp::scene::CollisionGraph::~CollisionGraph | ( | ) | [virtual] |
| 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.
| 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.
| [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. |
| 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.
| Box,: | Specifies the box size. |
| CollisionCapsule * sp::scene::CollisionGraph::createCapsule | ( | CollisionMaterial * | Material, | |
| scene::SceneNode * | Node, | |||
| f32 | Radius, | |||
| f32 | Height | |||
| ) | [virtual] |
Creates a new collision capsule.
| Height,: | Specifies the capsule's height. This can not be smaller than 0 and the whole capsule's height is (Height + 2 * Radius). |
| CharacterController * sp::scene::CollisionGraph::createCharacterController | ( | CollisionMaterial * | Material, | |
| scene::SceneNode * | Node, | |||
| f32 | Radius, | |||
| f32 | Height | |||
| ) | [virtual] |
Creates a new character controller.
| 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.
| Mesh,: | Specifies the mesh which is to be used for the collision. | |
| MaxTreeLevel,: | Specifies the maximal tree hierarchy level. |
| 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.
| CollisionPlane * sp::scene::CollisionGraph::createPlane | ( | CollisionMaterial * | Material, | |
| scene::SceneNode * | Node, | |||
| const dim::plane3df & | Plane | |||
| ) | [virtual] |
Creates a new collision plane.
| Plane,: | Specifies the plane. |
| CollisionSphere * sp::scene::CollisionGraph::createSphere | ( | CollisionMaterial * | Material, | |
| scene::SceneNode * | Node, | |||
| f32 | Radius | |||
| ) | [virtual] |
Creates a new collision sphere.
| 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. |
| 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.
| [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. |
| 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
std::list<CharacterController*> sp::scene::CollisionGraph::CharacterControllers_ [protected] |
std::list<CollisionMaterial*> sp::scene::CollisionGraph::CollMaterials_ [protected] |
std::list<CollisionNode*> sp::scene::CollisionGraph::CollNodes_ [protected] |
TreeNode* sp::scene::CollisionGraph::RootTreeNode_ [protected] |
1.7.1