# 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_multi_lod.h

Go to the documentation of this file.
00001 
00007 /* Copyright, 2001 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_MULTI_LOD_H
00027 #define NL_MESH_MULTI_LOD_H
00028 
00029 #include "nel/misc/types_nl.h"
00030 
00031 #include "3d/mesh.h"
00032 #include "3d/mesh_base.h"
00033 #include "3d/mesh_geom.h"
00034 #include "3d/mrm_parameters.h"
00035 
00036 namespace NL3D 
00037 {
00038 
00039 class CMeshMultiLodInstance;
00040 class CCoarseMeshManager;
00041 
00052 class CMeshMultiLod : public CMeshBase
00053 {
00054 public:
00055 
00057 
00058 
00060         class CMeshMultiLodBuild
00061         {
00062         public:
00063 
00065                 class CBuildSlot
00066                 {
00067                 public:
00077                         enum
00078                         {
00079                                 BlendIn                         =       0x01,
00080                                 BlendOut                        =       0x02,
00081                                 CoarseMesh                      =       0x04,
00082                                 IsOpaque                        =       0x08,
00083                                 IsTransparent           =       0x10,
00084                         };
00085 
00090                         IMeshGeom                       *MeshGeom;
00091 
00093                         float                           DistMax;
00094 
00096                         float                           BlendLength;
00097 
00099                         uint8                           Flags;
00100                 };
00101 
00103                 bool                                            StaticLod;
00104 
00106                 CMeshBase::CMeshBaseBuild       BaseMesh;
00107 
00109                 std::vector<CBuildSlot>         LodMeshes;
00110         };
00111 
00113         void                    build(CMeshMultiLodBuild &mbuild);
00114         // @}
00115 
00117         // @{
00118 
00120         virtual CTransformShape         *createInstance(CScene &scene);
00121 
00123         virtual bool    clip(const std::vector<CPlane>  &pyramid, const CMatrix &worldMatrix) ;
00124 
00126         virtual void    render(IDriver *drv, CTransformShape *trans, bool passOpaque);
00127 
00129         virtual float   getNumTriangles (float distance);
00130 
00132         virtual void    getAABBox(NLMISC::CAABBox &bbox) const;
00133 
00135         virtual void    serial(NLMISC::IStream &f) throw(NLMISC::EStream);
00136 
00138         NLMISC_DECLARE_CLASS(CMeshMultiLod);
00139 
00140         // @}
00141 
00143         const IMeshGeom& getMeshGeom (uint slot) const;
00144 
00146         uint                    getNumSlotMesh () const
00147         {
00148                 return _MeshVector.size();
00149         }
00150 
00152         IMeshGeom               *getSlotMesh (uint i, bool& coarseMesh)
00153         {
00154                 // Coarse mesh ?
00155                 coarseMesh=(_MeshVector[i].Flags&CMeshSlot::CoarseMesh)!=0;
00156 
00157                 // Return the mesh pointer
00158                 return _MeshVector[i].MeshGeom;
00159         }
00160 
00162         bool isStatic () const
00163         {
00164                 return _StaticLod;
00165         }
00166 
00173         void                    changeMRMDistanceSetup(float distanceFinest, float distanceMiddle, float distanceCoarsest);
00174 
00175 
00177         // @{
00178         virtual IMeshGeom       *supportMeshBlockRendering (CTransformShape *trans, float &polygonCount ) const;
00179         // @}
00180 
00181 private:
00182 
00190         class CMeshSlot
00191         {
00192         public:
00194                 enum
00195                 {
00196                         BlendIn                         =       0x01,
00197                         BlendOut                        =       0x02,
00198                         CoarseMesh                      =       0x04,
00199                         IsOpaque                        =       0x08,
00200                         IsTransparent           =       0x10,
00201                         CoarseMeshId            =       0x20,
00202                 };
00203 
00205                 CMeshSlot ();
00206                 ~CMeshSlot ();
00207 
00209                 IMeshGeom       *MeshGeom;
00210 
00212                 float           A;
00213 
00215                 float           B;
00216 
00218                 float           DistMax;
00219 
00221                 float           EndPolygonCount;
00222 
00224                 float           BlendLength;
00225 
00227                 uint8           Flags;
00228 
00230                 void serial(NLMISC::IStream &f) throw(NLMISC::EStream);
00231 
00233                 bool isOpaque() { return (Flags&IsOpaque)!=0; }
00234 
00236                 bool isTransparent() { return (Flags&IsTransparent)!=0; }
00237         };
00238 
00240         bool                                            _StaticLod;
00241 
00243         std::vector<CMeshSlot>          _MeshVector;
00244 
00246         void    clear ();
00247 
00249         void    renderMeshGeom (uint slot, IDriver *drv, CMeshMultiLodInstance *trans, float numPoylgons, uint32 rdrFlags, float alpha, CCoarseMeshManager *manager);
00250 
00252         void    renderCoarseMesh (uint slot, IDriver *drv, CMeshMultiLodInstance *trans, CCoarseMeshManager *manager);
00253 
00255         void    compileDistMax();
00256 
00257         friend class CMeshMultiLodBalancingObs;
00258 };
00259 
00260 
00261 } // NL3D
00262 
00263 
00264 #endif // NL_MESH_MULTI_LOD_H
00265 
00266 /* End of mesh_multi_lod.h */