# Home    # nevrax.com   
Nevrax
Nevrax.org
#News
#Mailing-list
#Documentation
#CVS
#Bugs
#License
Docs
 
Documentation  
Main Page   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages   Search  

NL3D::CCoarseMeshManager Class Reference

Management of coarse meshes. More...

#include <coarse_mesh_manager.h>

Inheritance diagram for NL3D::CCoarseMeshManager:

NL3D::CTransform NL3D::IModel NL3D::ITransformable NLMISC::CRefCount NL3D::IAnimatable List of all members.

Public Types

enum  { CantAddCoarseMesh = 0xffffffff }

Public Methods

 CCoarseMeshManager ()
 Constructor. More...

void setTextureFile (const char *file)
 Set texture file to use with this coarse mesh. More...

uint64 addMesh (const CMeshGeom &geom)
 Add a coarse mesh in the manager. More...

void removeMesh (uint64 id)
 Remove a coarse mesh in the manager. More...

void setMatrixMesh (uint64 id, const CMeshGeom &geom, const CMatrix &matrix)
 Set the matrix of a mesh. More...

void setColorMesh (uint64 id, const CMeshGeom &geom, NLMISC::CRGBA color)
 Set color of a mesh. More...

void render (IDriver *drv)
 Render the container. More...

CMaterialgetMaterial ()
 Get material of the container. More...


Static Public Methods

void registerBasic ()
 Register class id. More...


Private Types

typedef std::map< uint, CRenderPassTRenderingPassMap

Static Private Methods

uint64 buildId (uint32 renderPassId, uint32 renderPassMeshId)
 Build a manager id. More...

uint32 getRenderPassId (uint64 id)
 Get the render pass id. More...

uint32 getRenderPassMeshId (uint64 id)
 Get the render pass mesh id. More...

IModelcreator ()

Private Attributes

TRenderingPassMap _RenderPass
CSmartPtr< CTextureFile_Texture
CMaterial _Material

Detailed Description

Management of coarse meshes.

This container will render meshes with very low polygon count efficiently.

Coarse meshes are merged in render passes. They are inserted in the render pass depending there number of vertices, with a granularity (NL3D_COARSEMESH_VERTEXBUFFER_GRANULARITY).

If NL3D_COARSEMESH_VERTEXBUFFER_GRANULARITY is 8, all meshes with 1 to 7 vertices will be rendered at the same time using the same vertex buffer, the same material and the same matrix. Then, meshes with 8 to 15 vertices will be rendered at the same time. etc..

Vertices are softly transformed in world space at the "setMatrixMesh" call.

Vertices get a uniform color per instance at the "setColorMesh" call.

All coarse meshes must use a common vertex format. It is a pos + UV vertex format. (NL3D_COARSEMESH_VERTEX_FORMAT_EXPORT)

Internally the CCoarseMeshManager store meshes with pos + UV + color vertex format, to color instances (NL3D_COARSEMESH_VERTEX_FORMAT_MGR)

Coarse meshes must use indexed triangle primitive in a single render pass in a single matrix block.

All coarse meshes musts use a single material. It is a simple mapping with alpha test rendering and a common texture.

The coarse meshes must have been preprocessed to build the common texture and remap the UV mapping coordinates in the new common texture.

The manager must have been setuped with the common texture.

NB: the manager is not renderable, because CoarseMeshManager must be rendered at end of frame in a direct call by CRenderTrav::traverse(), after coarse mesh instances added/removed in

Author:
Cyril 'Hulud' Corvazier , Nevrax France
Date:
2001

Definition at line 103 of file coarse_mesh_manager.h.


Member Typedef Documentation

typedef std::map< uint, CRenderPass > NL3D::CCoarseMeshManager::TRenderingPassMap [private]
 

Definition at line 309 of file coarse_mesh_manager.h.


Member Enumeration Documentation

anonymous enum
 

Enumeration values:
CantAddCoarseMesh 

Definition at line 107 of file coarse_mesh_manager.h.


Constructor & Destructor Documentation

NL3D::CCoarseMeshManager::CCoarseMeshManager  
 

Constructor.

Definition at line 53 of file coarse_mesh_manager.cpp.

References _Material, _Texture, NL3D::CTransform::setOpacity, and NL3D::CTransform::setTransparency.

Referenced by creator.


Member Function Documentation

uint64 NL3D::CCoarseMeshManager::addMesh const CMeshGeom   geom
 

Add a coarse mesh in the manager.

If an error occured, it returns CantAddCoarseMesh. Error can be too much vertex, wrong vertex format.

Definition at line 87 of file coarse_mesh_manager.cpp.

References _RenderPass, buildId, CantAddCoarseMesh, H_AUTO_USE, id, NL3D_COARSEMESH_VERTEXBUFFER_GRANULARITY, and NL3D_COARSEMESH_VERTEXBUFFER_GRANULARITY_MASK.

uint64 NL3D::CCoarseMeshManager::buildId uint32    renderPassId,
uint32    renderPassMeshId
[inline, static, private]
 

Build a manager id.

Definition at line 159 of file coarse_mesh_manager.h.

Referenced by addMesh.

IModel* NL3D::CCoarseMeshManager::creator   [inline, static, private]
 

Reimplemented from NL3D::CTransform.

Definition at line 318 of file coarse_mesh_manager.h.

References CCoarseMeshManager, and NL3D::IModel::IModel.

CMaterial& NL3D::CCoarseMeshManager::getMaterial   [inline]
 

Get material of the container.

For rendering purpose only.

Definition at line 152 of file coarse_mesh_manager.h.

References _Material.

uint32 NL3D::CCoarseMeshManager::getRenderPassId uint64    id [inline, static, private]
 

Get the render pass id.

Definition at line 167 of file coarse_mesh_manager.h.

References id.

Referenced by removeMesh, setColorMesh, and setMatrixMesh.

uint32 NL3D::CCoarseMeshManager::getRenderPassMeshId uint64    id [inline, static, private]
 

Get the render pass mesh id.

Definition at line 175 of file coarse_mesh_manager.h.

References id.

Referenced by removeMesh, setColorMesh, and setMatrixMesh.

void NL3D::CCoarseMeshManager::registerBasic   [static]
 

Register class id.

Reimplemented from NL3D::CTransform.

Definition at line 45 of file coarse_mesh_manager.cpp.

References NL3D::ClipTravId, NL3D::CoarseMeshManagerId, and NL3D::TransformId.

void NL3D::CCoarseMeshManager::removeMesh uint64    id
 

Remove a coarse mesh in the manager.

Definition at line 124 of file coarse_mesh_manager.cpp.

References _RenderPass, getRenderPassId, getRenderPassMeshId, H_AUTO_USE, id, and nlassert.

void NL3D::CCoarseMeshManager::render IDriver   drv
 

Render the container.

Definition at line 181 of file coarse_mesh_manager.cpp.

References _Material, _RenderPass, and H_AUTO.

void NL3D::CCoarseMeshManager::setColorMesh uint64    id,
const CMeshGeom   geom,
NLMISC::CRGBA    color
 

Set color of a mesh.

Definition at line 162 of file coarse_mesh_manager.cpp.

References _RenderPass, getRenderPassId, getRenderPassMeshId, H_AUTO_USE, id, and nlassert.

void NL3D::CCoarseMeshManager::setMatrixMesh uint64    id,
const CMeshGeom   geom,
const CMatrix &    matrix
 

Set the matrix of a mesh.

Definition at line 143 of file coarse_mesh_manager.cpp.

References _RenderPass, getRenderPassId, getRenderPassMeshId, H_AUTO_USE, id, matrix, and nlassert.

void NL3D::CCoarseMeshManager::setTextureFile const char *    file
 

Set texture file to use with this coarse mesh.

Definition at line 80 of file coarse_mesh_manager.cpp.

References _Texture, and file.


Member Data Documentation

CMaterial NL3D::CCoarseMeshManager::_Material [private]
 

Definition at line 316 of file coarse_mesh_manager.h.

Referenced by CCoarseMeshManager, getMaterial, and render.

TRenderingPassMap NL3D::CCoarseMeshManager::_RenderPass [private]
 

Definition at line 310 of file coarse_mesh_manager.h.

Referenced by addMesh, removeMesh, render, setColorMesh, and setMatrixMesh.

CSmartPtr<CTextureFile> NL3D::CCoarseMeshManager::_Texture [private]
 

Definition at line 313 of file coarse_mesh_manager.h.

Referenced by CCoarseMeshManager, and setTextureFile.


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