#include <coarse_mesh_manager.h>
This container will render meshes with very low polygon count efficiently.
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.
Nevrax France
Definition at line 85 of file coarse_mesh_manager.h.
Public Member Functions | |
bool | addMesh (uint numVertices, const uint8 *vBuffer, uint numTris, const uint32 *indexBuffer) |
CCoarseMeshManager () | |
Constructor. | |
void | flushRender (IDriver *drv) |
uint | getColorOff () const |
CMaterial & | getMaterial () |
uint | getUVOff () const |
uint | getVertexSize () const |
Get the VertexSize of the MGR format. | |
void | setTextureFile (const char *file) |
Set texture file to use with this coarse mesh. | |
Private Attributes | |
uint | _CurrentNumTriangles |
uint | _CurrentNumVertices |
CMaterial | _Material |
CSmartPtr< CTextureFile > | _Texture |
std::vector< uint32 > | _Triangles |
CVertexBuffer | _VBuffer |
|
Constructor.
|
|
Add a coarse mesh in the manager. If an error occured, it returns CantAddCoarseMesh.
Definition at line 84 of file coarse_mesh_manager.cpp. References _CurrentNumTriangles, _CurrentNumVertices, _Triangles, _VBuffer, NL3D::CVertexBuffer::getVertexCoordPointer(), NL3D::CVertexBuffer::getVertexSize(), H_AUTO_USE, NL3D_COARSEMESH_TRIANGLE_SIZE, NL3D_COARSEMESH_VERTEXBUFFER_SIZE, uint, uint32, and uint8. Referenced by NL3D::CMeshMultiLod::renderCoarseMesh().
00085 { 00086 H_AUTO_USE( NL3D_StaticLod_AddMesh ); 00087 00088 // if 0 mesh, quit 00089 if(numTris==0 || numVertices==0) 00090 return true; 00091 00092 // check vertex size 00093 if(_CurrentNumVertices + numVertices > NL3D_COARSEMESH_VERTEXBUFFER_SIZE) 00094 return false; 00095 00096 // check tri size 00097 if(_CurrentNumTriangles + numTris> NL3D_COARSEMESH_TRIANGLE_SIZE) 00098 return false; 00099 00100 // Copy Vertices to VBuffer 00101 uint baseVertex= _CurrentNumVertices; 00102 CFastMem::memcpy(_VBuffer.getVertexCoordPointer(baseVertex), vBuffer, numVertices*_VBuffer.getVertexSize()); 00103 // next 00104 _CurrentNumVertices+= numVertices; 00105 00106 // Copy tris to triangles, adding baseVertex to index 00107 uint32 *triDst= &_Triangles[_CurrentNumTriangles*3]; 00108 const uint32 *triSrc= indexBuffer; 00109 uint numIdx= numTris*3; 00110 // NB: for the majority of CoarseMesh (4 faces==48 bytes of indices), not interressant to use CFastMem::precache() 00111 for(;numIdx>0;numIdx--, triSrc++, triDst++) 00112 { 00113 *triDst= *triSrc + baseVertex; 00114 } 00115 // next 00116 _CurrentNumTriangles+= numTris; 00117 00118 return true; 00119 } |
|
Render the container Definition at line 123 of file coarse_mesh_manager.cpp. References _CurrentNumTriangles, _CurrentNumVertices, _Triangles, _VBuffer, NL3D::IDriver::activeVertexBuffer(), H_AUTO, NL3D::IDriver::renderTriangles(), and NL3D::IDriver::setupModelMatrix(). Referenced by NL3D::CMeshMultiLod::renderCoarseMesh(), and NL3D::CRenderTrav::traverse().
00124 { 00125 H_AUTO( NL3D_StaticLod_Render ); 00126 00127 // If not empty, render 00128 if(_CurrentNumVertices && _CurrentNumTriangles) 00129 { 00130 // Set Ident matrix 00131 drv->setupModelMatrix (CMatrix::Identity); 00132 00133 // Set VB 00134 drv->activeVertexBuffer(_VBuffer); 00135 00136 // render 00137 drv->renderTriangles(_Material, &_Triangles[0], _CurrentNumTriangles); 00138 } 00139 00140 // reset 00141 _CurrentNumVertices= 0; 00142 _CurrentNumTriangles= 0; 00143 } |
|
Definition at line 119 of file coarse_mesh_manager.h. References _VBuffer, NL3D::CVertexBuffer::getColorOff(), and uint. Referenced by NL3D::CMeshMultiLod::renderCoarseMesh().
|
|
Get material of the container. For rendering purpose only. Definition at line 114 of file coarse_mesh_manager.h. Referenced by NL3D::CMeshMultiLod::renderMeshGeom().
00114 {return _Material;} |
|
Definition at line 118 of file coarse_mesh_manager.h. References _VBuffer, NL3D::CVertexBuffer::getTexCoordOff(), and uint. Referenced by NL3D::CMeshMultiLod::renderCoarseMesh().
|
|
Get the VertexSize of the MGR format.
Definition at line 117 of file coarse_mesh_manager.h. References _VBuffer, NL3D::CVertexBuffer::getVertexSize(), and uint. Referenced by NL3D::CMeshMultiLod::instanciateCoarseMeshSpace(), and NL3D::CMeshMultiLod::renderCoarseMesh().
00117 {return _VBuffer.getVertexSize();} |
|
Set texture file to use with this coarse mesh.
Definition at line 77 of file coarse_mesh_manager.cpp. References file. Referenced by NL3D::CScene::CScene(), and NL3D::CSceneUser::setCoarseMeshManagerTexture().
00078 { 00079 _Texture->setFileName (file); 00080 } |
|
Definition at line 126 of file coarse_mesh_manager.h. Referenced by addMesh(), and flushRender(). |
|
Definition at line 125 of file coarse_mesh_manager.h. Referenced by addMesh(), and flushRender(). |
|
Definition at line 132 of file coarse_mesh_manager.h. |
|
Definition at line 129 of file coarse_mesh_manager.h. |
|
Definition at line 124 of file coarse_mesh_manager.h. Referenced by addMesh(), and flushRender(). |
|
Definition at line 123 of file coarse_mesh_manager.h. Referenced by addMesh(), flushRender(), getColorOff(), getUVOff(), and getVertexSize(). |