NL3D::CLodCharacterShapeBank Class Reference

#include <lod_character_shape_bank.h>


Detailed Description

A Bank of CLodCharacterShape. Can contains at max 65536 shapes. You must call compile() after changing the shape bank.
Author:
Lionel Berenguier

Nevrax France

Date:
2002

Definition at line 44 of file lod_character_shape_bank.h.

Public Member Functions

 CLodCharacterShapeBank ()
 Constructor.

void serial (NLMISC::IStream &f)
 serial

build process
uint32 addShape ()
 Just add a shape to the bank. Use getShapeFullAcces() to fill it. return id of the shape.

bool compile ()
uint getNumShapes () const
 get number of shape. This is also the MaxID+1.

const CLodCharacterShapegetShape (uint32 shapeId) const
 Get a const ref on a shape. Ptr not valid after addShape(). NULL if not found.

CLodCharacterShapegetShapeFullAcces (uint32 shapeId)
sint32 getShapeIdByName (const std::string &name) const
void reset ()
 reset the shapeBank


Private Types

typedef TStrIdMap::const_iterator CstItStrIdMap
typedef TStrIdMap::iterator ItStrIdMap
typedef std::map< std::string,
uint32
TStrIdMap
 Map name To Id.


Private Attributes

std::vector< CLodCharacterShape_ShapeArray
 Array of shape.

TStrIdMap _ShapeMap
 Map of shape id.


Member Typedef Documentation

typedef TStrIdMap::const_iterator NL3D::CLodCharacterShapeBank::CstItStrIdMap [private]
 

Definition at line 93 of file lod_character_shape_bank.h.

typedef TStrIdMap::iterator NL3D::CLodCharacterShapeBank::ItStrIdMap [private]
 

Definition at line 92 of file lod_character_shape_bank.h.

typedef std::map<std::string, uint32> NL3D::CLodCharacterShapeBank::TStrIdMap [private]
 

Map name To Id.

Definition at line 91 of file lod_character_shape_bank.h.


Constructor & Destructor Documentation

NL3D::CLodCharacterShapeBank::CLodCharacterShapeBank  ) 
 

Constructor.

Definition at line 41 of file lod_character_shape_bank.cpp.

00042 {
00043 }


Member Function Documentation

uint32 NL3D::CLodCharacterShapeBank::addShape  ) 
 

Just add a shape to the bank. Use getShapeFullAcces() to fill it. return id of the shape.

Definition at line 53 of file lod_character_shape_bank.cpp.

References _ShapeArray, and uint32.

00054 {
00055         // Alloc a new shape
00056         _ShapeArray.resize(_ShapeArray.size()+1);
00057 
00058         return _ShapeArray.size()-1;
00059 }

bool NL3D::CLodCharacterShapeBank::compile  ) 
 

re-compile the shape Bank. This must be called after changing a shape, or after adding all your shapes. It return false if same names have been found, but it is still correctly builded.

Definition at line 90 of file lod_character_shape_bank.cpp.

References _ShapeArray, nlwarning, and uint.

00091 {
00092         bool    error= false;
00093 
00094         // clear the map
00095         contReset(_ShapeMap);
00096 
00097         // build the map
00098         for(uint i=0; i<_ShapeArray.size(); i++)
00099         {
00100                 const string &name= _ShapeArray[i].getName();
00101                 ItStrIdMap      it= _ShapeMap.find(name);
00102                 if(it == _ShapeMap.end())
00103                         _ShapeMap.insert(make_pair(name, i));
00104                 else
00105                 {
00106                         error= true;
00107                         nlwarning("Found a CLod with same name in the bank: %s", name.c_str());
00108                 }
00109         }
00110 
00111         return error;
00112 }

uint NL3D::CLodCharacterShapeBank::getNumShapes  )  const
 

get number of shape. This is also the MaxID+1.

Definition at line 115 of file lod_character_shape_bank.cpp.

References _ShapeArray, and uint.

00116 {
00117         return _ShapeArray.size();
00118 }

const CLodCharacterShape * NL3D::CLodCharacterShapeBank::getShape uint32  shapeId  )  const
 

Get a const ref on a shape. Ptr not valid after addShape(). NULL if not found.

Definition at line 72 of file lod_character_shape_bank.cpp.

References _ShapeArray, and uint32.

Referenced by NL3D::CLodCharacterManager::getShape().

00073 {
00074         if(shapeId >= _ShapeArray.size())
00075                 return NULL;
00076         else
00077                 return &_ShapeArray[shapeId];
00078 }

CLodCharacterShape * NL3D::CLodCharacterShapeBank::getShapeFullAcces uint32  shapeId  ) 
 

Get a ptr on a shape. Ptr not valid after addShape(). NULL if not found May be used for example to replace the shape

Definition at line 81 of file lod_character_shape_bank.cpp.

References _ShapeArray, and uint32.

00082 {
00083         if(shapeId >= _ShapeArray.size())
00084                 return NULL;
00085         else
00086                 return &_ShapeArray[shapeId];
00087 }

sint32 NL3D::CLodCharacterShapeBank::getShapeIdByName const std::string &  name  )  const
 

Get a shapeId by its name. -1 if not found. Possible Values are in 0-65535 Call valid only if compile() has been correctly called

Definition at line 62 of file lod_character_shape_bank.cpp.

References sint32.

00063 {
00064         CstItStrIdMap   it= _ShapeMap.find(name);
00065         if(it==_ShapeMap.end())
00066                 return -1;
00067         else
00068                 return it->second;
00069 }

void NL3D::CLodCharacterShapeBank::reset  ) 
 

reset the shapeBank

Definition at line 46 of file lod_character_shape_bank.cpp.

References _ShapeArray.

00047 {
00048         contReset(_ShapeArray);
00049         contReset(_ShapeMap);
00050 }

void NL3D::CLodCharacterShapeBank::serial NLMISC::IStream f  ) 
 

serial

Definition at line 121 of file lod_character_shape_bank.cpp.

References _ShapeArray, NLMISC::IStream::serialCont(), and NLMISC::IStream::serialVersion().

00122 {
00123         (void)f.serialVersion(0);
00124 
00125         f.serialCont(_ShapeArray);
00126         f.serialCont(_ShapeMap);
00127 }


Field Documentation

std::vector<CLodCharacterShape> NL3D::CLodCharacterShapeBank::_ShapeArray [private]
 

Array of shape.

Definition at line 99 of file lod_character_shape_bank.h.

Referenced by addShape(), compile(), getNumShapes(), getShape(), getShapeFullAcces(), reset(), and serial().

TStrIdMap NL3D::CLodCharacterShapeBank::_ShapeMap [private]
 

Map of shape id.

Definition at line 102 of file lod_character_shape_bank.h.


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 06:50:01 2004 for NeL by doxygen 1.3.6