MezzanineEngine 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | 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_AudioManager = 1, MT_AnimationManager, MT_CollisionShapeManager, MT_CompositorManager,
  MT_GraphicsManager, MT_EventManager, MT_InputManager, MT_LogManager,
  MT_MaterialManager, MT_MeshManager, MT_NetworkManager, MT_ResourceManager,
  MT_ScriptingManager, MT_UIManager, MT_ActorManager = 100, MT_AreaEffectManager,
  MT_CameraManager, MT_DebrisManager, MT_PagingManager, MT_PhysicsManager,
  MT_SceneManager, MT_SoundScapeManager, MT_TerrainManager, MT_VehicleManager,
  MT_UserCreated = 512
}
 

Public Member Functions

 CollisionShapeManager ()
 Class constructor.
 
 CollisionShapeManager (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, bool UseAllSubmeshes=false)
 Generates a Convex Hull from a provided mesh. More...
 
virtual ConvexHullCollisionShapeGenerateConvexHull (const String &Name, const String &MeshName, const String &Group, bool UseAllSubmeshes=false)
 Generates a Convex Hull from a provided mesh. More...
 
virtual DynamicMeshCollisionShapeGenerateDynamicTriMesh (const String &Name, Graphics::Mesh *ObjectMesh, bool UseAllSubmeshes=false)
 Generates a mesh shape for dynamic objects. More...
 
virtual DynamicMeshCollisionShapeGenerateDynamicTriMesh (const String &Name, const String &MeshName, const String &Group, bool UseAllSubmeshes=false)
 Generates a mesh shape for dynamic objects. More...
 
virtual StaticMeshCollisionShapeGenerateStaticTriMesh (const String &Name, Graphics::Mesh *ObjectMesh, bool UseAllSubmeshes=false)
 Generates a mesh shape for static objects. More...
 
virtual StaticMeshCollisionShapeGenerateStaticTriMesh (const String &Name, const String &MeshName, const String &Group, bool 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 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, bool 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, bool 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::ManagerBase
 ManagerBase ()
 Class constructor.
 
virtual ~ManagerBase ()
 Class destructor.
 
virtual String GetInterfaceTypeAsString () const
 Gets a string of the interface type of this manager. More...
 
bool IsInitialized () const
 Gets whether or not this manager has been initialized. More...
 
- Public Member Functions inherited from Mezzanine::Singleton< CollisionShapeManager >
 Singleton ()
 Class constructor.
 
 ~Singleton ()
 Class destructor.
 

Protected Member Functions

btTriangleMesh * CreateBulletTrimesh (Graphics::Mesh *ObjectMesh, bool 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 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
bool Initialized
 Simple bool 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 bool SingletonValid ()
 Checks to see if the singleton pointer is valid. More...
 
- Static Protected Attributes inherited from Mezzanine::Singleton< CollisionShapeManager >
static CollisionShapeManager * SingletonPtr
 

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 80 of file collisionshapemanager.h.

Constructor & Destructor Documentation

Mezzanine::Physics::CollisionShapeManager::CollisionShapeManager ( 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 90 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 379 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 385 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 750 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 355 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 360 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 382 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 388 of file collisionshapemanager.cpp.

ConvexHullCollisionShape * Mezzanine::Physics::CollisionShapeManager::GenerateConvexHull ( const String Name,
Graphics::Mesh ObjectMesh,
bool  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 394 of file collisionshapemanager.cpp.

ConvexHullCollisionShape * Mezzanine::Physics::CollisionShapeManager::GenerateConvexHull ( const String Name,
const String MeshName,
const String Group,
bool  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 411 of file collisionshapemanager.cpp.

DynamicMeshCollisionShape * Mezzanine::Physics::CollisionShapeManager::GenerateDynamicTriMesh ( const String Name,
Graphics::Mesh ObjectMesh,
bool  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 417 of file collisionshapemanager.cpp.

DynamicMeshCollisionShape * Mezzanine::Physics::CollisionShapeManager::GenerateDynamicTriMesh ( const String Name,
const String MeshName,
const String Group,
bool  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 423 of file collisionshapemanager.cpp.

StaticMeshCollisionShape * Mezzanine::Physics::CollisionShapeManager::GenerateStaticTriMesh ( const String Name,
Graphics::Mesh ObjectMesh,
bool  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 429 of file collisionshapemanager.cpp.

StaticMeshCollisionShape * Mezzanine::Physics::CollisionShapeManager::GenerateStaticTriMesh ( const String Name,
const String MeshName,
const String Group,
bool  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 435 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 759 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 756 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 332 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 325 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 720 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 747 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 645 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 582 of file collisionshapemanager.cpp.

CompoundCollisionShape * Mezzanine::Physics::CollisionShapeManager::PerformConvexDecomposition ( const String Name,
Graphics::Mesh ObjectMesh,
Whole  Depth,
Real  CPercent,
Real  PPercent,
bool  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 441 of file collisionshapemanager.cpp.

CompoundCollisionShape * Mezzanine::Physics::CollisionShapeManager::PerformConvexDecomposition ( const String Name,
const String MeshName,
const String Group,
Whole  Depth,
Real  CPercent,
Real  PPercent,
bool  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 573 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 337 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 342 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 679 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 603 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 698 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 624 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 725 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 311 of file collisionshapemanager.cpp.

Member Data Documentation

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

This stores the names and collision Shapes.

Definition at line 98 of file collisionshapemanager.h.

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

Stores shapes that have not been given a name.

Definition at line 101 of file collisionshapemanager.h.


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