Cafu Engine
cf::ClipSys::CollModelManI Class Referenceabstract

This class provides (an interface to) the creation, management and destruction of collision models. More...

#include "CollisionModelMan.hpp"

Inheritance diagram for cf::ClipSys::CollModelManI:

Public Member Functions

virtual ~CollModelManI ()
 The virtual destructor. More...
 
virtual const CollisionModelTGetCM (const std::string &FileName)=0
 Loads a collision model from the file specified by FileName. More...
 
virtual const CollisionModelTGetCM (unsigned long Width, unsigned long Height, const ArrayT< Vector3dT > &Mesh, MaterialT *Material, const double MIN_NODE_SIZE)=0
 Creates a collision model from the given explicit mesh. More...
 
virtual const CollisionModelTGetCM (const BoundingBox3T< double > &BB, MaterialT *Material)=0
 Creates a collision model from the given (axis-aligned) bounding-box. More...
 
virtual const CollisionModelTGetCM (const CollisionModelT *CollisionModel)=0
 Creates another collision model from a given collision model. More...
 
virtual const std::string & GetFileName (const CollisionModelT *CollisionModel) const =0
 Returns the file name the given collision model has been loaded from (using the GetCM(const std::string& FileName) method). More...
 
virtual void FreeCM (const CollisionModelT *CollisionModel)=0
 Frees the given collision model (taking reference counting into account if necessary). More...
 
virtual unsigned long GetUniqueCMCount () const =0
 Returns the number of unique, physical collision model instances managed by this class. More...
 

Detailed Description

This class provides (an interface to) the creation, management and destruction of collision models.

It employs reference counting for collision models that are loaded from file. The interface is specified as an ABC in order to be able to share it across exe/dll boundaries.

The important feature is that it allows the flexible, care-free handling of collision models: no matter where a model "comes from" (loaded file, file stream, bounding box, ...), it is created and deleted in a uniform manner, which in turn is an important feature for the game (entity) code. The const-ness of the returned pointers is obviously a consequence of the instance-sharing implied by the reference counting: You can inspect, but not mutate/modify shared objects.

Constructor & Destructor Documentation

virtual cf::ClipSys::CollModelManI::~CollModelManI ( )
inlinevirtual

The virtual destructor.

Member Function Documentation

virtual void cf::ClipSys::CollModelManI::FreeCM ( const CollisionModelT CollisionModel)
pure virtual

Frees the given collision model (taking reference counting into account if necessary).

Parameters
CollisionModelThe collision model to be freed.

Implemented in cf::ClipSys::CollModelManImplT.

virtual const CollisionModelT* cf::ClipSys::CollModelManI::GetCM ( const std::string &  FileName)
pure virtual

Loads a collision model from the file specified by FileName.

If the collision model has been loaded before, reference counting is employed.

Parameters
FileNameThe name of the file to load the collision model from.
Returns
(a pointer to) the collision model instance that has been loaded from the given file, or NULL on failure.

Implemented in cf::ClipSys::CollModelManImplT.

virtual const CollisionModelT* cf::ClipSys::CollModelManI::GetCM ( unsigned long  Width,
unsigned long  Height,
const ArrayT< Vector3dT > &  Mesh,
MaterialT Material,
const double  MIN_NODE_SIZE 
)
pure virtual

Creates a collision model from the given explicit mesh.

Parameters
WidthThe width of the mesh.
HeightThe height of the mesh.
MeshThe vertices of the mesh.
MaterialThe material reported in collision results when a trace hit.
MIN_NODE_SIZEThe minimum size (side length) that a node should not fall below.
Returns
the matching collision model instance.

Implemented in cf::ClipSys::CollModelManImplT.

virtual const CollisionModelT* cf::ClipSys::CollModelManI::GetCM ( const BoundingBox3T< double > &  BB,
MaterialT Material 
)
pure virtual

Creates a collision model from the given (axis-aligned) bounding-box.

Parameters
BBThe bounding box to create a collision model for.
MaterialThe material to use for the collision model.
Returns
the desired collision model.

Implemented in cf::ClipSys::CollModelManImplT.

virtual const CollisionModelT* cf::ClipSys::CollModelManI::GetCM ( const CollisionModelT CollisionModel)
pure virtual

Creates another collision model from a given collision model.

a) If the given collision model has been created with other methods of this CollModelManI earlier, the implementation will simply increase the related reference counter and return the same pointer. b) If the given collision model has been created "externally" with some other means (e.g. direct instantiation of a concrete collision model class), the CollModelManI will create a record about it with a reference count of 1, assume that the original instance is not freed/deleted by the caller as long as it has a non-zero reference count, and will not attempt to delete the instance when the count finally drops to 0.

Parameters
CollisionModelThe collision model to create another collision model from.
Returns
a matching collision model instance.

Implemented in cf::ClipSys::CollModelManImplT.

virtual const std::string& cf::ClipSys::CollModelManI::GetFileName ( const CollisionModelT CollisionModel) const
pure virtual

Returns the file name the given collision model has been loaded from (using the GetCM(const std::string& FileName) method).

Parameters
CollisionModelThe collision model for which return the associated file name.
Returns
the file name of the collision model, or "" (the empty string) if the model was created by another method.

Implemented in cf::ClipSys::CollModelManImplT.

virtual unsigned long cf::ClipSys::CollModelManI::GetUniqueCMCount ( ) const
pure virtual

Returns the number of unique, physical collision model instances managed by this class.

Implemented in cf::ClipSys::CollModelManImplT.


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