00001
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
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
00155 coarseMesh=(_MeshVector[i].Flags&CMeshSlot::CoarseMesh)!=0;
00156
00157
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 }
00262
00263
00264 #endif // NL_MESH_MULTI_LOD_H
00265
00266