NL3D::CLodCharacterManager Class Reference

A Manager used to display CLodCharacter instances. More...

#include <lod_character_manager.h>

List of all members.

Public Member Functions

 CLodCharacterManager ()
 Constructor.
 ~CLodCharacterManager ()
build process



void reset ()
 reset the manager.
uint32 createShapeBank ()
 create a Shape Bank.
const CLodCharacterShapeBankgetShapeBank (uint32 bankId) const
 get a shape Bank. Useful for serialisation for example. return NULL if not found
CLodCharacterShapeBankgetShapeBank (uint32 bankId)
 get a shape Bank. Useful for serialisation for example. return NULL if not found
void deleteShapeBank (uint32 bankId)
 delete a Shape Bank. No-op if bad id.
sint32 getShapeIdByName (const std::string &name) const
 Get a shapeId by its name.
const CLodCharacterShapegetShape (uint32 shapeId) const
 Get a const ref on a shape. Ptr not valid if shape Banks are modfied. NULL if not found.
bool compile ()
 re-compile the shape map.
Misc



bool fastIntersect (const CLodCharacterInstance &instance, const NLMISC::CMatrix &toRaySpace, float &dist2D, float &distZ, bool computeDist2D)
 test if the CLod intersect the ray (0, K) (after mul vertices by toRaySpace)

Private Types

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

Private Attributes

std::vector
< CLodCharacterShapeBank * > 
_ShapeBankArray
 Array of shapeBank.
TStrIdMap _ShapeMap
 Map of shape id.

render process



CVector _ManagerMatrixPos
CMaterial _Material
uint _CurrentVertexId
uint _MaxNumVertices
uint _NumVBHard
CVertexStreamManager _VertexStream
uint8_VertexData
uint _VertexSize
bool _Rendering
bool _LockDone
uint _CurrentTriId
CIndexBuffer _Triangles
CMatrix _LightCorrectionMatrix
void setMaxVertex (uint32 maxVertex)
 set the max number of vertices the manager can render in one time.
uint32 getMaxVertex () const
 see setMaxVertex()
void setVertexStreamNumVBHard (uint32 numVBHard)
 set the number of vbhard to allocate for the vertexStream.
uint32 getVertexStreamNumVBHard () const
 see setVertexStreamNumVBHard
void beginRender (IDriver *driver, const CVector &managerPos)
 Start the rendering process, freeing VBuffer.
bool addRenderCharacterKey (CLodCharacterInstance &instance, const CMatrix &worldMatrix, CRGBA ambient, CRGBA diffuse, const CVector &lightDir)
 Add an instance to the render list.
void endRender ()
 compile the rendering process, effectively rendering into driver the lods.
bool isRendering () const
 tells if we are beetween a beginRender() and a endRender()
void setupNormalCorrectionMatrix (const CMatrix &normalMatrix)
 Setup a correction matrix for Lighting.

Instance texturing.



CSmartPtr< CTextureBlank_BigTexture
std::vector< uint_FreeIds
CLodCharacterTmpBitmap _TmpBitmaps [256]
void initInstance (CLodCharacterInstance &instance)
 Init the instance texturing with this manager. A texture space is reserved (if possible), and UVs are generated.
void releaseInstance (CLodCharacterInstance &instance)
 Release a lod instance. Free texture space.
bool startTextureCompute (CLodCharacterInstance &instance)
 reset the textureSpace. Instance must have been inited (nlassert). return false if no more texture space available
CLodCharacterTmpBitmapgetTmpBitmap (uint8 id)
 get a tmp bitmap for a special slot. caller can fill RGBA texture for the associated material Id in it.
void addTextureCompute (CLodCharacterInstance &instance, const CLodCharacterTexture &lodTexture)
 add a texture from an instance. Texture Lookup are made in _TmpBitmaps
void endTextureCompute (CLodCharacterInstance &instance, uint numBmpToReset)
 end and compile. reset/free memory of _TmpBitmaps up to numBmpToReset.
CRGBAgetTextureInstance (CLodCharacterInstance &instance)

Detailed Description

A Manager used to display CLodCharacter instances.

Author:
Lionel Berenguier
Nevrax France
Date:
2002

Definition at line 104 of file lod_character_manager.h.


Member Typedef Documentation

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

Definition at line 255 of file lod_character_manager.h.

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

Definition at line 254 of file lod_character_manager.h.

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

Map name To Id.

Definition at line 253 of file lod_character_manager.h.


Constructor & Destructor Documentation

NL3D::CLodCharacterManager::CLodCharacterManager (  ) 
NL3D::CLodCharacterManager::~CLodCharacterManager (  ) 

Definition at line 108 of file lod_character_manager.cpp.

References reset().


Member Function Documentation

bool NL3D::CLodCharacterManager::addRenderCharacterKey ( CLodCharacterInstance instance,
const CMatrix worldMatrix,
CRGBA  ambient,
CRGBA  diffuse,
const CVector lightDir 
)

Add an instance to the render list.

nlassert if not isRendering() initInstance() must have been called before (nlassert)

Parameters:
instance the lod instance information (with precomputed color/Uvs)
worldMatrix is the world matrix, used to display the mesh
ambient is the ambient used to simulate the lighting on the lod.
diffuse is the diffuse used to simulate the lighting on the lod.
lightDir is the diffuse used to simulate the lighting on the lod (should be the bigger light influence) Don't need to be normalized (must do it internally)
Returns:
false if the key can't be added to this pass BECAUSE OF TOO MANY VERTICES reason. If the shapeId or animId are bad id, it return true!! You may call endRender(), then restart a block. Or you may just stop the process if you want.

Definition at line 362 of file lod_character_manager.cpp.

References _CurrentTriId, _CurrentVertexId, _LightCorrectionMatrix, _LockDone, _ManagerMatrixPos, _MaxNumVertices, _Triangles, _VertexData, _VertexSize, _VertexStream, NLMISC::CRGBA::A, a00, a01, a02, a10, a11, a12, a20, a21, a22, NL3D::add(), NL3D::CLodCharacterInstance::AnimId, NL3D::CLodCharacterInstance::AnimTime, NL3D::computeLodLighting(), NLMISC::CMatrix::get(), NL3D::CLodCharacterShape::getAnimKey(), NL3D::CVertexStreamManager::getDriver(), NL3D::CIndexBuffer::getIndexNumBytes(), NL3D::CLodCharacterShape::getNormals(), NL3D::CIndexBuffer::getNumIndexes(), NL3D::CLodCharacterShape::getNumTriangles(), NL3D::CLodCharacterShape::getNumVertices(), NLMISC::CMatrix::getPos(), NL3D::CIndexBufferReadWrite::getPtr(), getShape(), NL3D::CLodCharacterShape::getTriangleArray(), NL3D::CLodCharacterInstance::getUVs(), H_AUTO, NLMISC::CSystemInfo::hasMMX(), NL3D::CVertexStreamManager::isBRGA(), isRendering(), NL3D::CIndexBuffer::lock(), NL3D::CVertexStreamManager::lock(), NLMISC::CMatrix::mulVector(), NL3D_CLOD_COLOR_OFF, NL3D_CLOD_UV_OFF, NL3D_CLOD_VERTEX_SIZE, NL_LOD_CHARACTER_INDEX_FORMAT, nlassert, NLMISC::CVector::normalize(), NL3D::CIndexBuffer::setFormat(), NL3D::CIndexBuffer::setNumIndexes(), NL3D::CLodCharacterInstance::ShapeId, NLMISC::CRGBA::swapBR(), NL3D::CLodCharacterInstance::VertexAlphas, NL3D::CLodCharacterInstance::WrapMode, NL3D::CLodCharacterShape::CVector3s::x, NLMISC::CVector::x, NL3D::CLodCharacterShape::CVector3s::y, NLMISC::CVector::y, NL3D::CLodCharacterShape::CVector3s::z, and NLMISC::CVector::z.

Referenced by NL3D::CSkeletonModel::renderCLod().

void NL3D::CLodCharacterManager::addTextureCompute ( CLodCharacterInstance instance,
const CLodCharacterTexture lodTexture 
)
void NL3D::CLodCharacterManager::beginRender ( IDriver driver,
const CVector managerPos 
)

Start the rendering process, freeing VBuffer.

nlassert if isRendering() NB: VBhard is locked here, so you must call endRender to unlock him (even if 0 meshes are rendered)

Parameters:
managerPos is to help ZBuffer Precision (see IDriver::setupViewMatrixEx). This vector is removed from all instance worldMatrixes, and a IDriver::setupModelMatrix() will be done with this position. Hence, whatever value you give, the result will be the same. But if you give a value near the camera position, ZBuffer precision will be enhanced.

Definition at line 276 of file lod_character_manager.cpp.

References _CurrentTriId, _CurrentVertexId, _LockDone, _ManagerMatrixPos, _MaxNumVertices, _NumVBHard, _Rendering, _Triangles, _VertexSize, _VertexStream, NL3D::CVertexBuffer::getColorOff(), NL3D::CVertexStreamManager::getDriver(), NL3D::CVertexStreamManager::getMaxVertices(), NL3D::CIndexBuffer::getNumIndexes(), NL3D::CVertexStreamManager::getNumVB(), NL3D::CVertexBuffer::getTexCoordOff(), NL3D::CVertexStreamManager::getVertexSize(), H_AUTO, NL3D::CVertexStreamManager::init(), isRendering(), NL3D_CLOD_COLOR_OFF, NL3D_CLOD_UV_OFF, NL3D_CLOD_VERTEX_FORMAT, NL3D_CLOD_VERTEX_SIZE, NL_LOD_CHARACTER_INDEX_FORMAT, nlassert, NL3D::CVertexStreamManager::release(), NL3D::CIndexBuffer::setFormat(), NL3D::CIndexBuffer::setNumIndexes(), and NL3D::CVertexBuffer::setVertexFormat().

Referenced by NL3D::CSkeletonModel::renderCLod(), and NL3D::CRenderTrav::traverse().

bool NL3D::CLodCharacterManager::compile (  ) 

re-compile the shape map.

This must be called after changing shape bank list. It return false if same names have been found, but it is still correctly builded.

Definition at line 212 of file lod_character_manager.cpp.

References _ShapeBankArray, _ShapeMap, NLMISC::contReset(), NL3D::CLodCharacterShape::getName(), and nlwarning.

Referenced by NL3D::CSceneUser::deleteCLodShapeBank(), and NL3D::CSceneUser::loadCLodShapeBank().

uint32 NL3D::CLodCharacterManager::createShapeBank (  ) 

create a Shape Bank.

NB: a vector of ShapeBank is maintained internally, hence, not so many shapeBank should be created at same Time.

Returns:
id of the shape Bank.

Definition at line 134 of file lod_character_manager.cpp.

References _ShapeBankArray.

Referenced by NL3D::CSceneUser::loadCLodShapeBank().

void NL3D::CLodCharacterManager::deleteShapeBank ( uint32  bankId  ) 

delete a Shape Bank. No-op if bad id.

Definition at line 171 of file lod_character_manager.cpp.

References _ShapeBankArray.

Referenced by NL3D::CSceneUser::deleteCLodShapeBank().

void NL3D::CLodCharacterManager::endRender (  ) 
void NL3D::CLodCharacterManager::endTextureCompute ( CLodCharacterInstance instance,
uint  numBmpToReset 
)
bool NL3D::CLodCharacterManager::fastIntersect ( const CLodCharacterInstance instance,
const NLMISC::CMatrix toRaySpace,
float dist2D,
float distZ,
bool  computeDist2D 
)

test if the CLod intersect the ray (0, K) (after mul vertices by toRaySpace)

Returns:
false if not supported/no triangles, else true if can do the test (even if don't intersect!) if intersect, dist2D=0, and distZ= Depth Distance if don't intersect, dist2D="nearest distance to the ray", and distZ=0
Parameters:
computeDist2D if false and don't intersect, then return dist2D=FLT_MAX, and distZ=0

Definition at line 1055 of file lod_character_manager.cpp.

References a00, a01, a02, a10, a11, a12, a20, a21, a22, NL3D::CLodCharacterInstance::AnimId, NL3D::CLodCharacterInstance::AnimTime, NLMISC::CMatrix::get(), NL3D::CLodCharacterShape::getAnimKey(), NL3D::CLodCharacterShape::getNumVertices(), NLMISC::CMatrix::getPos(), NL3D::CRayMesh::getRayIntersection(), getShape(), NL3D::CLodCharacterShape::getTriangleIndices(), H_AUTO, NL3D::CLodCharacterInstance::ShapeId, NL3D::CLodCharacterInstance::WrapMode, NL3D::CLodCharacterShape::CVector3s::x, NLMISC::CVector::x, NL3D::CLodCharacterShape::CVector3s::y, NLMISC::CVector::y, NL3D::CLodCharacterShape::CVector3s::z, and NLMISC::CVector::z.

Referenced by NL3D::CSkeletonModel::fastIntersect().

uint32 NL3D::CLodCharacterManager::getMaxVertex (  )  const [inline]

see setMaxVertex()

Definition at line 160 of file lod_character_manager.h.

References _MaxNumVertices.

const CLodCharacterShape * NL3D::CLodCharacterManager::getShape ( uint32  shapeId  )  const

Get a const ref on a shape. Ptr not valid if shape Banks are modfied. NULL if not found.

Definition at line 194 of file lod_character_manager.cpp.

References NL3D::CLodCharacterShapeBank::getShape(), and getShapeBank().

Referenced by addRenderCharacterKey(), NL3D::CSkeletonModel::computeCLodVertexAlpha(), fastIntersect(), NL3D::CSceneUser::getCLodAnimIdByName(), and initInstance().

CLodCharacterShapeBank * NL3D::CLodCharacterManager::getShapeBank ( uint32  bankId  ) 

get a shape Bank. Useful for serialisation for example. return NULL if not found

Definition at line 162 of file lod_character_manager.cpp.

References _ShapeBankArray.

const CLodCharacterShapeBank * NL3D::CLodCharacterManager::getShapeBank ( uint32  bankId  )  const

get a shape Bank. Useful for serialisation for example. return NULL if not found

Definition at line 153 of file lod_character_manager.cpp.

References _ShapeBankArray.

Referenced by getShape(), and NL3D::CSceneUser::loadCLodShapeBank().

sint32 NL3D::CLodCharacterManager::getShapeIdByName ( const std::string &  name  )  const

Get a shapeId by its name.

-1 if not found. Call valid only if compile() has been correctly called

Definition at line 184 of file lod_character_manager.cpp.

References _ShapeMap.

Referenced by NL3D::CSceneUser::getCLodShapeIdByName().

CRGBA * NL3D::CLodCharacterManager::getTextureInstance ( CLodCharacterInstance instance  )  [private]
CLodCharacterTmpBitmap& NL3D::CLodCharacterManager::getTmpBitmap ( uint8  id  )  [inline]

get a tmp bitmap for a special slot. caller can fill RGBA texture for the associated material Id in it.

Definition at line 230 of file lod_character_manager.h.

References _TmpBitmaps.

Referenced by NL3D::CSkeletonModel::computeLodTexture().

uint32 NL3D::CLodCharacterManager::getVertexStreamNumVBHard (  )  const [inline]

see setVertexStreamNumVBHard

Definition at line 170 of file lod_character_manager.h.

References _NumVBHard.

void NL3D::CLodCharacterManager::initInstance ( CLodCharacterInstance instance  ) 
bool NL3D::CLodCharacterManager::isRendering (  )  const [inline]
void NL3D::CLodCharacterManager::releaseInstance ( CLodCharacterInstance instance  ) 
void NL3D::CLodCharacterManager::reset (  ) 
void NL3D::CLodCharacterManager::setMaxVertex ( uint32  maxVertex  ) 

set the max number of vertices the manager can render in one time.

Default is 3000 vertices. nlassert if isRendering()

Definition at line 260 of file lod_character_manager.cpp.

References _MaxNumVertices, isRendering(), and nlassert.

void NL3D::CLodCharacterManager::setupNormalCorrectionMatrix ( const CMatrix normalMatrix  ) 

Setup a correction matrix for Lighting.

Normals are multiplied with this matrix before lighting. This is important in Ryzom because models (and so Lods) are building with eye looking in Y<0. But they are animated with eye looking in X>0. The default setup is hence a matrix wich do a RotZ+=90.

See also:
addRenderCharacterKey

Definition at line 797 of file lod_character_manager.cpp.

References _LightCorrectionMatrix, NLMISC::CMatrix::invert(), NLMISC::CVector::Null, and NLMISC::CMatrix::setPos().

void NL3D::CLodCharacterManager::setVertexStreamNumVBHard ( uint32  numVBHard  ) 

set the number of vbhard to allocate for the vertexStream.

The more, the better (no lock stall). Default is 8. With MaxVertices==3000 and numVBHard==8, this led us with 576 Ko in AGP. And this is sufficient cause it can handle 300 entities of approx 80 vertices each frame with no lock at all.

Definition at line 268 of file lod_character_manager.cpp.

References _NumVBHard, isRendering(), and nlassert.

bool NL3D::CLodCharacterManager::startTextureCompute ( CLodCharacterInstance instance  ) 

reset the textureSpace. Instance must have been inited (nlassert). return false if no more texture space available

Definition at line 955 of file lod_character_manager.cpp.

References getTextureInstance(), NL3D_CLOD_BIGTEXT_WIDTH, NL3D_CLOD_DEFAULT_TEXCOLOR, NL3D_CLOD_TEXT_HEIGHT, and NL3D_CLOD_TEXT_WIDTH.

Referenced by NL3D::CSkeletonModel::computeLodTexture().


Member Data Documentation

Definition at line 285 of file lod_character_manager.h.

Referenced by addRenderCharacterKey(), beginRender(), and endRender().

Definition at line 275 of file lod_character_manager.h.

Referenced by addRenderCharacterKey(), beginRender(), and endRender().

Definition at line 300 of file lod_character_manager.h.

Referenced by CLodCharacterManager(), initInstance(), and releaseInstance().

Definition at line 270 of file lod_character_manager.h.

Referenced by addRenderCharacterKey(), beginRender(), and endRender().

Definition at line 273 of file lod_character_manager.h.

Referenced by CLodCharacterManager(), and endRender().

Definition at line 281 of file lod_character_manager.h.

Referenced by beginRender(), CLodCharacterManager(), endRender(), and isRendering().

Array of shapeBank.

Definition at line 261 of file lod_character_manager.h.

Referenced by compile(), createShapeBank(), deleteShapeBank(), getShapeBank(), and reset().

Map of shape id.

Definition at line 264 of file lod_character_manager.h.

Referenced by compile(), getShapeIdByName(), and reset().

Definition at line 303 of file lod_character_manager.h.

Referenced by addTextureCompute(), endTextureCompute(), and getTmpBitmap().

Definition at line 279 of file lod_character_manager.h.

Referenced by addRenderCharacterKey().

Definition at line 280 of file lod_character_manager.h.

Referenced by addRenderCharacterKey(), and beginRender().

Definition at line 278 of file lod_character_manager.h.

Referenced by addRenderCharacterKey(), beginRender(), endRender(), and reset().


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

Generated on Thu Jan 7 08:30:05 2010 for NeL by  doxygen 1.6.1