Spinning Topp Logo BlackTopp Studios
inc
Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Protected Attributes | List of all members
Mezzanine::Physics::CollisionShapeManager Class Reference

This manager is for the storage of all shapes and creation of mesh shapes. More...

#include <collisionshapemanager.h>

+ Inheritance diagram for Mezzanine::Physics::CollisionShapeManager:
+ Collaboration diagram for Mezzanine::Physics::CollisionShapeManager:

Public Types

typedef ShapeMap::const_iterator ConstShapeMapIterator
 Const Map Iterator type for CollisionShape instances stored by this class.
 
typedef ShapeVector::const_iterator ConstShapeVectorIterator
 Const Vector Iterator type for CollisionShape instances stored by this class.
 
typedef std::map< String, CollisionShape * > ShapeMap
 Map container type for CollisionShape storage by this class.
 
typedef ShapeMap::iterator ShapeMapIterator
 Map Iterator type for CollisionShape instances stored by this class.
 
typedef std::vector< CollisionShape * > ShapeVector
 Vector container type for CollisionShape storage by this class.
 
typedef ShapeVector::iterator ShapeVectorIterator
 Vector Iterator type for CollisionShape instances stored by this class.
 
- Public Types inherited from Mezzanine::ManagerBase
enum  ManagerType {
  MT_Undefined = 0, MT_AudioManager = 1, MT_AnimationManager = 2, MT_CollisionShapeManager = 3,
  MT_CompositorManager = 4, MT_GraphicsManager = 5, MT_EventManager = 6, MT_InputManager = 7,
  MT_LogManager = 8, MT_MaterialManager = 9, MT_MeshManager = 10, MT_NetworkManager = 11,
  MT_ResourceManager = 12, MT_ScriptingManager = 13, MT_TextureManager = 14, MT_UIManager = 15,
  MT_ActorManager = 101, MT_AreaEffectManager = 102, MT_DebrisManager = 103, MT_PagingManager = 104,
  MT_PhysicsManager = 105, MT_SceneManager = 106, MT_SoundScapeManager = 107, MT_TerrainManager = 108,
  MT_VehicleManager = 109, MT_UserCreated = 512
}
 A listing of Manager Types. More...
 

Public Member Functions

 CollisionShapeManager ()
 Class constructor.
 
 CollisionShapeManager (const XML::Node &XMLNode)
 XML constructor. More...
 
virtual ~CollisionShapeManager ()
 Class destructor.
 
ShapeMapIterator BeginCollisionShape ()
 Gets an Iterator to the first CollisionShape in this manager. More...
 
ConstShapeMapIterator BeginCollisionShape () const
 Gets a Const Iterator to the first CollisionShape in this manager. More...
 
virtual void Deinitialize ()
 Removes this manager from any necessary configuration so it can be safely disposed of. More...
 
virtual void DestroyAllShapes ()
 Removes all shapes from the manager and then deletes them.
 
virtual void DestroyShape (CollisionShape *Shape)
 Removes a shape from this manager and deletes it. More...
 
virtual void DestroyShape (const String &Name)
 Removes a shape from this manager and deletes it. More...
 
ShapeMapIterator EndCollisionShape ()
 Gets an Iterator to one passed the last CollisionShape in this manager. More...
 
ConstShapeMapIterator EndCollisionShape () const
 Gets a Const Iterator to one passed the last CollisionShape in this manager. More...
 
virtual ConvexHullCollisionShapeGenerateConvexHull (const String &Name, Graphics::Mesh *ObjectMesh, Boole UseAllSubmeshes=false)
 Generates a Convex Hull from a provided mesh. More...
 
virtual ConvexHullCollisionShapeGenerateConvexHull (const String &Name, const String &MeshName, const String &Group, Boole UseAllSubmeshes=false)
 Generates a Convex Hull from a provided mesh. More...
 
virtual DynamicMeshCollisionShapeGenerateDynamicTriMesh (const String &Name, Graphics::Mesh *ObjectMesh, Boole UseAllSubmeshes=false)
 Generates a mesh shape for dynamic objects. More...
 
virtual DynamicMeshCollisionShapeGenerateDynamicTriMesh (const String &Name, const String &MeshName, const String &Group, Boole UseAllSubmeshes=false)
 Generates a mesh shape for dynamic objects. More...
 
virtual StaticMeshCollisionShapeGenerateStaticTriMesh (const String &Name, Graphics::Mesh *ObjectMesh, Boole UseAllSubmeshes=false)
 Generates a mesh shape for static objects. More...
 
virtual StaticMeshCollisionShapeGenerateStaticTriMesh (const String &Name, const String &MeshName, const String &Group, Boole UseAllSubmeshes=false)
 Generates a mesh shape for static objects. More...
 
virtual String GetImplementationTypeName () const
 This Allows any manager name to be sent to a stream. Primarily used for logging. More...
 
virtual ManagerBase::ManagerType GetInterfaceType () const
 This returns the type of this manager. More...
 
virtual Whole GetNumStoredShapes ()
 Gets the number of stored shapes in this manager. More...
 
virtual CollisionShapeGetShape (const String &Name)
 Gets a shape already stored in this manager. More...
 
ShapeVectorGetUnnamedShapes ()
 Returns a vector of unnamed shapes stored in this manager. More...
 
virtual void Initialize ()
 Configures this manager for use prior to entering the main loop. More...
 
virtual void LoadAllShapesFromBinaryFile (const String &FileName, const String &Group)
 Loads all shapes saved in an existing binary file, and stores them in this manager. More...
 
virtual void LoadAllShapesFromXMLFile (const String &FileName, const String &Group)
 Loads all shapes saved in an existing XML file, and stores them in this manager. More...
 
virtual CompoundCollisionShapePerformConvexDecomposition (const String &Name, Graphics::Mesh *ObjectMesh, Whole Depth, Real CPercent, Real PPercent, Boole UseAllSubmeshes=false)
 Generates a compound shape of Convex Hulls from a provided mesh. More...
 
virtual CompoundCollisionShapePerformConvexDecomposition (const String &Name, const String &MeshName, const String &Group, Whole Depth, Real CPercent, Real PPercent, Boole UseAllSubmeshes=false)
 Generates a compound shape of Convex Hulls from a provided mesh. More...
 
virtual void RemoveAllShapes ()
 Removes all shapes from the manager without deleting them.
 
virtual void RemoveShape (CollisionShape *Shape)
 Removes a shape from this manager without deleting it. More...
 
virtual void RemoveShape (const String &Name)
 Removes a shape from this manager without deleting it. More...
 
virtual void SaveAllStoredShapesToBinaryFile (const String &FileName)
 Takes all the shapes currently stored this manager and saves them to a binary file. More...
 
virtual void SaveAllStoredShapesToXMLFile (const String &FileName)
 Takes all the shapes currently stored this manager and saves them to a XML file. More...
 
virtual void SaveShapesToBinaryFile (const String &FileName, ShapeVector &ShapesToSave)
 Saves all shapes contained in a vector and saves them to a binary file. More...
 
virtual void SaveShapesToXMLFile (const String &FileName, ShapeVector &ShapesToSave)
 Saves all shapes contained in a vector and saves them to a XML file. More...
 
void SetNameForUnnamedShape (const String &NewName, CollisionShape *Shape)
 Assigns a name to an unnamed shape. More...
 
virtual void StoreShape (CollisionShape *Shape)
 Stores a pre-made shape in this manager. More...
 
- Public Member Functions inherited from Mezzanine::EntresolManager
 EntresolManager ()
 Class constructor.
 
virtual ~EntresolManager ()
 Class destructor.
 
- Public Member Functions inherited from Mezzanine::ManagerBase
 ManagerBase ()
 Class constructor.
 
virtual ~ManagerBase ()
 Class destructor.
 
virtual String GetInterfaceTypeAsString () const
 Gets a string of the interface type of this manager. More...
 
Boole IsInitialized () const
 Gets whether or not this manager has been initialized. More...
 
- Public Member Functions inherited from Mezzanine::Singleton< CollisionShapeManager >
 ~Singleton ()
 Class destructor.
 

Static Public Attributes

static const String ImplementationName = "DefaultCollisionShapeManager"
 A String containing the name of this manager implementation.
 
static const ManagerBase::ManagerType InterfaceType = ManagerBase::MT_CollisionShapeManager
 A ManagerType enum value used to describe the type of interface/functionality this manager provides.
 

Protected Member Functions

btTriangleMesh * CreateBulletTrimesh (Graphics::Mesh *ObjectMesh, Boole UseAllSubmeshes)
 Creates a TriMesh to be used in TriMesh based collision shapes.
 
CollisionShapeWrapShape (const String &Name, btCollisionShape *InternalShape)
 Creates a wrapper for an internal bullet shape.
 
- Protected Member Functions inherited from Mezzanine::Singleton< CollisionShapeManager >
 Singleton ()
 Class constructor.
 

Protected Attributes

ShapeMap CollisionShapes
 This stores the names and collision Shapes. More...
 
ShapeVector UnnamedShapes
 Stores shapes that have not been given a name. More...
 
- Protected Attributes inherited from Mezzanine::ManagerBase
Boole Initialized
 Simple Boole indicating whether or not this manager has been initialized. More...
 
EntresolTheEntresol
 The actual pointer to the Entresol core class. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from Mezzanine::ManagerBase
static String GetTypeAsString (const ManagerType &ManagerType)
 Gets the string form of the type of manager. More...
 
static ManagerType GetTypeFromString (const String &ManagerName)
 Gets the type of manager requested from a string. More...
 
- Static Public Member Functions inherited from Mezzanine::Singleton< CollisionShapeManager >
static CollisionShapeManager * GetSingletonPtr ()
 Fetches a pointer to the singleton. More...
 
static Boole SingletonValid ()
 Checks to see if the singleton pointer is valid. More...
 
- Static Protected Attributes inherited from Mezzanine::Singleton< CollisionShapeManager >
static CollisionShapeManager * SingletonPtr
 The one and only pointer to the single object. More...
 

Detailed Description

This manager is for the storage of all shapes and creation of mesh shapes.

Collision shapes do not need to be stored in this manager, but can be re-used across multiple World objects with physics representations. For performance reasons, it is recommended to store and re-use a collision shape anytime you need it in multiple objects, rather then re-creating the same shape again and again.

Definition at line 82 of file collisionshapemanager.h.

Constructor & Destructor Documentation

Mezzanine::Physics::CollisionShapeManager::CollisionShapeManager ( const XML::Node XMLNode)

XML constructor.

Parameters
XMLNodeThe node of the xml document to construct from.
Todo:
This class currently doesn't initialize anything from XML, if that changes this constructor needs to be expanded.

Definition at line 93 of file collisionshapemanager.cpp.

Member Function Documentation

CollisionShapeManager::ShapeMapIterator Mezzanine::Physics::CollisionShapeManager::BeginCollisionShape ( )

Gets an Iterator to the first CollisionShape in this manager.

Returns
Returns an Iterator to the first CollisionShape.

Definition at line 380 of file collisionshapemanager.cpp.

CollisionShapeManager::ConstShapeMapIterator Mezzanine::Physics::CollisionShapeManager::BeginCollisionShape ( ) const

Gets a Const Iterator to the first CollisionShape in this manager.

Returns
Returns a Const Iterator to the first CollisionShape.

Definition at line 386 of file collisionshapemanager.cpp.

void Mezzanine::Physics::CollisionShapeManager::Deinitialize ( )
virtual

Removes this manager from any necessary configuration so it can be safely disposed of.

Implements Mezzanine::ManagerBase.

Definition at line 751 of file collisionshapemanager.cpp.

void Mezzanine::Physics::CollisionShapeManager::DestroyShape ( CollisionShape Shape)
virtual

Removes a shape from this manager and deletes it.

Parameters
ShapePointer to the shape to be destroyed.

Definition at line 356 of file collisionshapemanager.cpp.

void Mezzanine::Physics::CollisionShapeManager::DestroyShape ( const String Name)
virtual

Removes a shape from this manager and deletes it.

Parameters
NameThe name of the shape to be destroyed.

Definition at line 361 of file collisionshapemanager.cpp.

CollisionShapeManager::ShapeMapIterator Mezzanine::Physics::CollisionShapeManager::EndCollisionShape ( )

Gets an Iterator to one passed the last CollisionShape in this manager.

Returns
Returns an Iterator to one passed the last CollisionShape.

Definition at line 383 of file collisionshapemanager.cpp.

CollisionShapeManager::ConstShapeMapIterator Mezzanine::Physics::CollisionShapeManager::EndCollisionShape ( ) const

Gets a Const Iterator to one passed the last CollisionShape in this manager.

Returns
Returns a Const Iterator to one passed the last CollisionShape.

Definition at line 389 of file collisionshapemanager.cpp.

ConvexHullCollisionShape * Mezzanine::Physics::CollisionShapeManager::GenerateConvexHull ( const String Name,
Graphics::Mesh ObjectMesh,
Boole  UseAllSubmeshes = false 
)
virtual

Generates a Convex Hull from a provided mesh.

Returns
Returns a pointer to the created shape.
Parameters
NameThe name to give the created shape.
ObjectMeshThe mesh to base this shape off of.
UseAllSubmeshesWhether or not you want to use all submesh information when generating this shape.

Definition at line 395 of file collisionshapemanager.cpp.

ConvexHullCollisionShape * Mezzanine::Physics::CollisionShapeManager::GenerateConvexHull ( const String Name,
const String MeshName,
const String Group,
Boole  UseAllSubmeshes = false 
)
virtual

Generates a Convex Hull from a provided mesh.

Returns
Returns a pointer to the created shape.
Parameters
NameThe name to give the created shape.
MeshNameThe name of the mesh to base this shape off of.
GroupThe resource group where the mesh can be found.
UseAllSubmeshesWhether or not you want to use all submesh information when generating this shape.

Definition at line 412 of file collisionshapemanager.cpp.

DynamicMeshCollisionShape * Mezzanine::Physics::CollisionShapeManager::GenerateDynamicTriMesh ( const String Name,
Graphics::Mesh ObjectMesh,
Boole  UseAllSubmeshes = false 
)
virtual

Generates a mesh shape for dynamic objects.

Note
Dynamic Mesh shapes cannot be scaled per object, only globally. If you are generating this shape and intend to scale it, you will need to make a separate copy of the shape for each object you intend to set to a different scaling.
Returns
Returns a pointer to the created shape.
Parameters
NameThe name to give the created shape.
ObjectMeshThe mesh to base this shape off of.
UseAllSubmeshesWhether or not you want to use all submesh information when generating this shape.

Definition at line 418 of file collisionshapemanager.cpp.

DynamicMeshCollisionShape * Mezzanine::Physics::CollisionShapeManager::GenerateDynamicTriMesh ( const String Name,
const String MeshName,
const String Group,
Boole  UseAllSubmeshes = false 
)
virtual

Generates a mesh shape for dynamic objects.

Note
Dynamic Mesh shapes cannot be scaled per object, only globally. If you are generating this shape and intend to scale it, you will need to make a separate copy of the shape for each object you intend to set to a different scaling.
Returns
Returns a pointer to the created shape.
Parameters
NameThe name to give the created shape.
MeshNameThe name of the mesh to base this shape off of.
GroupThe resource group where the mesh can be found.
UseAllSubmeshesWhether or not you want to use all submesh information when generating this shape.

Definition at line 424 of file collisionshapemanager.cpp.

StaticMeshCollisionShape * Mezzanine::Physics::CollisionShapeManager::GenerateStaticTriMesh ( const String Name,
Graphics::Mesh ObjectMesh,
Boole  UseAllSubmeshes = false 
)
virtual

Generates a mesh shape for static objects.

Returns
Returns a pointer to the created shape.
Parameters
NameThe name to give the created shape.
ObjectMeshThe mesh to base this shape off of.
UseAllSubmeshesWhether or not you want to use all submesh information when generating this shape.

Definition at line 430 of file collisionshapemanager.cpp.

StaticMeshCollisionShape * Mezzanine::Physics::CollisionShapeManager::GenerateStaticTriMesh ( const String Name,
const String MeshName,
const String Group,
Boole  UseAllSubmeshes = false 
)
virtual

Generates a mesh shape for static objects.

Returns
Returns a pointer to the created shape.
Parameters
NameThe name to give the created shape.
MeshNameThe name of the mesh to base this shape off of.
GroupThe resource group where the mesh can be found.
UseAllSubmeshesWhether or not you want to use all submesh information when generating this shape.

Definition at line 436 of file collisionshapemanager.cpp.

String Mezzanine::Physics::CollisionShapeManager::GetImplementationTypeName ( ) const
virtual

This Allows any manager name to be sent to a stream. Primarily used for logging.

Returns
This returns a String that contains the name.

Implements Mezzanine::ManagerBase.

Definition at line 760 of file collisionshapemanager.cpp.

ManagerBase::ManagerType Mezzanine::Physics::CollisionShapeManager::GetInterfaceType ( ) const
virtual

This returns the type of this manager.

This is intended to make using and casting from Manager base easier. With this is is possible to cast from ManagerBase to the correct Manager Type.

Returns
This returns a ManagerTypeName to identify what this can be safely cast to.

Implements Mezzanine::ManagerBase.

Definition at line 757 of file collisionshapemanager.cpp.

Whole Mezzanine::Physics::CollisionShapeManager::GetNumStoredShapes ( )
virtual

Gets the number of stored shapes in this manager.

Returns
Returns a whole representing how many shapes this manager is storing.

Definition at line 333 of file collisionshapemanager.cpp.

CollisionShape * Mezzanine::Physics::CollisionShapeManager::GetShape ( const String Name)
virtual

Gets a shape already stored in this manager.

Parameters
Namethe name of the desired shape.
Returns
Returns a pointer to the desired shape, or NULL if no such shape exists.

Definition at line 326 of file collisionshapemanager.cpp.

CollisionShapeManager::ShapeVector & Mezzanine::Physics::CollisionShapeManager::GetUnnamedShapes ( )

Returns a vector of unnamed shapes stored in this manager.

Returns
Returns a reference to a vector storing all the unnamed shapes loaded from files.

Shapes created in code require a name to be constructed. However, sometimes when loading a file a shape may not have a name, since one isn't required by the .bullet file format in order for a shape to be serialized. When that happens those shapes go here, and from there can be handled by the game programmer however they see fit.

Definition at line 721 of file collisionshapemanager.cpp.

void Mezzanine::Physics::CollisionShapeManager::Initialize ( )
virtual

Configures this manager for use prior to entering the main loop.

Implements Mezzanine::ManagerBase.

Definition at line 748 of file collisionshapemanager.cpp.

void Mezzanine::Physics::CollisionShapeManager::LoadAllShapesFromBinaryFile ( const String FileName,
const String Group 
)
virtual

Loads all shapes saved in an existing binary file, and stores them in this manager.

Parameters
FileNameThe name of the binary file to load shapes from.
GroupThe resource group the .bullet file is located in.

Definition at line 646 of file collisionshapemanager.cpp.

void Mezzanine::Physics::CollisionShapeManager::LoadAllShapesFromXMLFile ( const String FileName,
const String Group 
)
virtual

Loads all shapes saved in an existing XML file, and stores them in this manager.

Parameters
FileNameThe name of the XML file to load shapes from.
GroupThe resource group the .bullet file is located in.
Todo:
Replace this stack allocated stream for one initialized from the Resource Manager, after the system is ready.

Definition at line 583 of file collisionshapemanager.cpp.

CompoundCollisionShape * Mezzanine::Physics::CollisionShapeManager::PerformConvexDecomposition ( const String Name,
Graphics::Mesh ObjectMesh,
Whole  Depth,
Real  CPercent,
Real  PPercent,
Boole  UseAllSubmeshes = false 
)
virtual

Generates a compound shape of Convex Hulls from a provided mesh.

Note
Compound shapes cannot be scaled per object, only globally. If you are generating this shape and intend to scale it, you will need to make a separate copy of the shape for each object you intend to set to a different scaling.
Returns
Returns a pointer to the created shape.
Parameters
NameThe name to give the created shape.
ObjectMeshThe mesh to base this shape off of.
UseAllSubmeshesWhether or not you want to use all submesh information when generating this shape.

Definition at line 442 of file collisionshapemanager.cpp.

CompoundCollisionShape * Mezzanine::Physics::CollisionShapeManager::PerformConvexDecomposition ( const String Name,
const String MeshName,
const String Group,
Whole  Depth,
Real  CPercent,
Real  PPercent,
Boole  UseAllSubmeshes = false 
)
virtual

Generates a compound shape of Convex Hulls from a provided mesh.

Note
Compound shapes cannot be scaled per object, only globally. If you are generating this shape and intend to scale it, you will need to make a separate copy of the shape for each object you intend to set to a different scaling.
Returns
Returns a pointer to the created shape.
Parameters
NameThe name to give the created shape.
MeshNameThe name of the mesh to base this shape off of.
GroupThe resource group where the mesh can be found.
UseAllSubmeshesWhether or not you want to use all submesh information when generating this shape.

Definition at line 574 of file collisionshapemanager.cpp.

void Mezzanine::Physics::CollisionShapeManager::RemoveShape ( CollisionShape Shape)
virtual

Removes a shape from this manager without deleting it.

Parameters
ShapePointer to the shape to be removed.

Definition at line 338 of file collisionshapemanager.cpp.

void Mezzanine::Physics::CollisionShapeManager::RemoveShape ( const String Name)
virtual

Removes a shape from this manager without deleting it.

Parameters
NameThe name of the shape to be removed.

Definition at line 343 of file collisionshapemanager.cpp.

void Mezzanine::Physics::CollisionShapeManager::SaveAllStoredShapesToBinaryFile ( const String FileName)
virtual

Takes all the shapes currently stored this manager and saves them to a binary file.

Remarks
The binary file the shapes will be saved to is a file generated by the Bullet Physics library, typically with a .bullet extension.
Parameters
FileNameThe name of the file to save the shapes to.

Definition at line 680 of file collisionshapemanager.cpp.

void Mezzanine::Physics::CollisionShapeManager::SaveAllStoredShapesToXMLFile ( const String FileName)
virtual

Takes all the shapes currently stored this manager and saves them to a XML file.

Parameters
FileNameThe name of the file to save the shapes to.
Todo:
Replace this stack allocated stream for one initialized from the Resource Manager, after the system is ready.

Definition at line 604 of file collisionshapemanager.cpp.

void Mezzanine::Physics::CollisionShapeManager::SaveShapesToBinaryFile ( const String FileName,
ShapeVector ShapesToSave 
)
virtual

Saves all shapes contained in a vector and saves them to a binary file.

Remarks
The binary file the shapes will be saved to is a file generated by the Bullet Physics library, typically with a .bullet extension.
Parameters
FileNameThe name of the file to save the shapes to.
ShapesToSaveA vector of collisions shapes that will be saved.

Definition at line 699 of file collisionshapemanager.cpp.

void Mezzanine::Physics::CollisionShapeManager::SaveShapesToXMLFile ( const String FileName,
ShapeVector ShapesToSave 
)
virtual

Saves all shapes contained in a vector and saves them to a XML file.

Parameters
FileNameThe name of the file to save the shapes to.
ShapesToSaveA vector of collisions shapes that will be saved.
Todo:
Replace this stack allocated stream for one initialized from the Resource Manager, after the system is ready.

Definition at line 625 of file collisionshapemanager.cpp.

void Mezzanine::Physics::CollisionShapeManager::SetNameForUnnamedShape ( const String NewName,
CollisionShape Shape 
)

Assigns a name to an unnamed shape.

Parameters
NewNameThe new name to be assigned to a shape.
ShapeThe shape to be given the new name. This shape must be a valid shape currently stored in the set of unnamed shapes. Calling this fucntion will not remove it from that set, but will move it into the named collision shape map. If you want the shape removed from the Unnamed set, you must do it yourself.

Definition at line 726 of file collisionshapemanager.cpp.

void Mezzanine::Physics::CollisionShapeManager::StoreShape ( CollisionShape Shape)
virtual

Stores a pre-made shape in this manager.

Parameters
ShapeThe shape to be stored.

Definition at line 314 of file collisionshapemanager.cpp.

Member Data Documentation

ShapeMap Mezzanine::Physics::CollisionShapeManager::CollisionShapes
protected

This stores the names and collision Shapes.

Definition at line 105 of file collisionshapemanager.h.

ShapeVector Mezzanine::Physics::CollisionShapeManager::UnnamedShapes
protected

Stores shapes that have not been given a name.

Definition at line 108 of file collisionshapemanager.h.


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