# 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  

mesh_block_manager.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2000-2002 Nevrax Ltd.
00008  *
00009  * This file is part of NEVRAX NEL.
00010  * NEVRAX NEL is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2, or (at your option)
00013  * any later version.
00014 
00015  * NEVRAX NEL is distributed in the hope that it will be useful, but
00016  * WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
00018  * General Public License for more details.
00019 
00020  * You should have received a copy of the GNU General Public License
00021  * along with NEVRAX NEL; see the file COPYING. If not, write to the
00022  * Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00023  * MA 02111-1307, USA.
00024  */
00025 
00026 #ifndef NL_MESH_BLOCK_MANAGER_H
00027 #define NL_MESH_BLOCK_MANAGER_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 #include "3d/mesh_geom.h"
00031 #include "3d/vertex_buffer_heap.h"
00032 
00033 
00034 namespace NL3D 
00035 {
00036 
00037 
00038 class   CMeshBaseInstance;
00039 class   IDriver;
00040 class   CScene;
00041 class   CRenderTrav;
00042 
00043 // ***************************************************************************
00056 class CMeshBlockManager
00057 {
00058 public:
00059 
00061         CMeshBlockManager();
00062         ~CMeshBlockManager();
00063 
00067         void                    addInstance(IMeshGeom *meshGeom, CMeshBaseInstance *inst, float polygonCount);
00068 
00071         void                    flush(IDriver *drv, CScene *scene, CRenderTrav *renderTrav);
00072 
00073 
00075         // @{
00076 
00078         void                    releaseVBHeaps();
00079 
00084         bool                    addVBHeap(IDriver *drv, uint vertexFormat, uint maxVertices);
00085 
00087         void                    freeMeshVBHeap(IMeshGeom *mesh);
00088 
00089         // @}
00090 
00091 // ************************
00092 private:
00093 
00094         // An instance information.
00095         struct  CInstanceInfo
00096         {
00097                 IMeshGeom                       *MeshGeom;
00098                 CMeshBaseInstance       *MBI;
00099                 float                           PolygonCount;
00100                 // Next instance to render in the list. -1 if end of list.
00101                 sint32                          NextInstance;
00102         };
00103 
00104         // A VBHeap information.
00105         struct  CVBHeapBlock
00106         {
00108                 std::vector<CInstanceInfo>      RdrInstances;
00109 
00111                 std::vector<IMeshGeom*>         RdrMeshGeoms;
00112 
00114                 CVertexBufferHeap                       VBHeap;
00116                 std::vector<IMeshGeom*>         AllocatedMeshGeoms;
00118                 std::vector<uint>                       FreeIds;
00119         };
00120 
00122         typedef std::map<uint, uint>    TVBHeapMap;
00123         TVBHeapMap                                              _VBHeapMap;
00124 
00128         std::vector<CVBHeapBlock*>              _VBHeapBlocks;
00129 
00131         void                    allocateMeshVBHeap(IMeshGeom *mesh);
00132 
00133         // render all instance of this meshGeoms, sorting by material, VP etc....
00134         void                    render(IMeshGeom *meshGeom, std::vector<CInstanceInfo>  &rdrInstances);
00135 
00136         // current flush setup
00137         CMeshGeomRenderContext          _RenderCtx;
00138 };
00139 
00140 
00141 } // NL3D
00142 
00143 
00144 #endif // NL_MESH_BLOCK_MANAGER_H
00145 
00146 /* End of mesh_block_manager.h */