NL3D::CMRMLevelDetail Class Reference

#include <mrm_level_detail.h>


Detailed Description

Degradation Control for MRM. used by CMeshMRM and CSkeletonModel
Author:
Lionel Berenguier

Nevrax France

Date:
2002

Definition at line 51 of file mrm_level_detail.h.

Public Member Functions

 CMRMLevelDetail ()
 Constructor.

void compileDistanceSetup ()
 compile OODistanceDelta and DistancePow

float getLevelDetailFromDist (float dist)
 return a float [0,1], computed from a distance (should be >0).

float getLevelDetailFromPolyCount (float polygonCount)
 return a float [0,1], computed from number of poly wanted (should be >0)

float getNumTriangles (float dist)
 return number of triangles for a distance


Data Fields

float DistanceCoarsest
 The MRM has faces/Divisor when dist>=DistanceCoarsest. nlassert if <= DistanceMiddle.

float DistanceFinest
 The MRM has its max faces when dist<=DistanceFinest. nlassert if <0.

float DistanceMiddle
 The MRM has 50% of its faces at dist==DistanceMiddle. nlassert if <= DistanceFinest.

float DistancePow
uint32 MaxFaceUsed
 For Load balancing, the max number of faces this MRM use.

uint32 MinFaceUsed
 For Load balancing, the min number of faces this MRM use.

float OODistanceDelta
 compiled info (public for faster serial)


Constructor & Destructor Documentation

NL3D::CMRMLevelDetail::CMRMLevelDetail  )  [inline]
 

Constructor.

Definition at line 73 of file mrm_level_detail.h.

00073 {}


Member Function Documentation

void NL3D::CMRMLevelDetail::compileDistanceSetup  ) 
 

compile OODistanceDelta and DistancePow

Definition at line 37 of file mrm_level_detail.cpp.

References DistancePow, and OODistanceDelta.

Referenced by NL3D::CMeshMRMSkinnedGeom::build(), NL3D::CMeshMRMGeom::build(), NL3D::CSkeletonModel::buildDefaultLevelDetail(), NL3D::CSkeletonModel::changeMRMDistanceSetup(), NL3D::CMeshMRMSkinnedGeom::changeMRMDistanceSetup(), NL3D::CMeshMRMGeom::changeMRMDistanceSetup(), and NL3D::CSkeletonModel::updateSkinRenderLists().

00038 {
00039         // Compute _OODistDelta.
00040         OODistanceDelta= 1.0f / (DistanceCoarsest - DistanceFinest);
00041         /* Compute exponent pow, such that 0.5= dMiddle^pow;
00042                 ie 0.5= e(ln dMiddle * pow)
00043         */
00044         float   dMiddle= (DistanceCoarsest - DistanceMiddle) * OODistanceDelta;
00045         DistancePow= (float)(log(0.5) / log(dMiddle));
00046 }

float NL3D::CMRMLevelDetail::getLevelDetailFromDist float  dist  ) 
 

return a float [0,1], computed from a distance (should be >0).

Definition at line 50 of file mrm_level_detail.cpp.

References DistancePow, and OODistanceDelta.

Referenced by getNumTriangles().

00051 {
00052         if(dist <= DistanceFinest)
00053                 return 1;
00054         if(dist >= DistanceCoarsest)
00055                 return 0;
00056 
00057         float   d= (DistanceCoarsest - dist) * OODistanceDelta;
00058         return  (float)pow(d, DistancePow);
00059 }

float NL3D::CMRMLevelDetail::getLevelDetailFromPolyCount float  polygonCount  )  [inline]
 

return a float [0,1], computed from number of poly wanted (should be >0)

Definition at line 101 of file mrm_level_detail.h.

References NLMISC::clamp(), MaxFaceUsed, MinFaceUsed, and NL3D_MRM_LD_SHIFT_POLY_COUNT.

Referenced by NL3D::CMeshMRMGeom::activeInstance(), NL3D::CMeshMRMSkinnedGeom::profileSceneRender(), NL3D::CMeshMRMGeom::profileSceneRender(), NL3D::CMeshMRMSkinnedGeom::render(), NL3D::CMeshMRMGeom::render(), and NL3D::CSkeletonModel::renderSkins().

00102         {
00103                 float   ld;
00104                 if(MaxFaceUsed > MinFaceUsed)
00105                 {
00106                         // compute the level of detail we want.
00107                         ld= (polygonCount - MinFaceUsed) / (MaxFaceUsed - MinFaceUsed);
00108                         /* remove the value added in getNumTriangles(). For the same reason:
00109                                 this is always the higher Lod which is rendered, geomorphing to the coarser one.
00110                                 Hence we must degrade a bit.
00111                                 NB: if polygonCount==MinFaceUsed, then we have here ld= -NL3D_MRM_LD_SHIFT_POLY_COUNT (ie -0.05f)
00112                                 but it is clamped below
00113                         */
00114                         ld-= NL3D_MRM_LD_SHIFT_POLY_COUNT;
00115                         NLMISC::clamp(ld, 0, 1);
00116                 }
00117                 else
00118                         ld= 1;
00119 
00120                 return ld;
00121         }

float NL3D::CMRMLevelDetail::getNumTriangles float  dist  )  [inline]
 

return number of triangles for a distance

Definition at line 82 of file mrm_level_detail.h.

References getLevelDetailFromDist(), MaxFaceUsed, MinFaceUsed, and NL3D_MRM_LD_SHIFT_POLY_COUNT.

Referenced by NL3D::CSkeletonModel::getNumTriangles(), NL3D::CMeshMRMSkinnedGeom::getNumTriangles(), and NL3D::CMeshMRMGeom::getNumTriangles().

00083         {
00084                 // return the lod detail [0,1].
00085                 float   ld= getLevelDetailFromDist(dist);
00086                 // return in nb face.
00087                 if(ld<=0)
00088                         return (float)MinFaceUsed;
00089                 else
00090                 {
00091                         /* over-estimate the number of poly rendered 
00092                                 because this is always the higher Lod which is rendered, geomorphing to the coarser one.
00093                                 NB: still need to over-estimate if ld==1, because getLevelDetailFromPolyCount() remove the shift...
00094                         */
00095                         ld+= NL3D_MRM_LD_SHIFT_POLY_COUNT;
00096                         return MinFaceUsed + ld * (MaxFaceUsed - MinFaceUsed);
00097                 }
00098         }


Field Documentation

float NL3D::CMRMLevelDetail::DistanceCoarsest
 

The MRM has faces/Divisor when dist>=DistanceCoarsest. nlassert if <= DistanceMiddle.

Definition at line 65 of file mrm_level_detail.h.

Referenced by NL3D::CMeshMRMSkinnedGeom::build(), NL3D::CMeshMRMGeom::build(), NL3D::CSkeletonModel::buildDefaultLevelDetail(), NL3D::CSkeletonModel::changeMRMDistanceSetup(), NL3D::CMeshMRMSkinnedGeom::changeMRMDistanceSetup(), NL3D::CMeshMRMGeom::changeMRMDistanceSetup(), NL3D::CMeshMRMSkinnedGeom::serial(), and NL3D::CSkeletonModel::updateSkinRenderLists().

float NL3D::CMRMLevelDetail::DistanceFinest
 

The MRM has its max faces when dist<=DistanceFinest. nlassert if <0.

Definition at line 61 of file mrm_level_detail.h.

Referenced by NL3D::CMeshMRMSkinnedGeom::build(), NL3D::CMeshMRMGeom::build(), NL3D::CSkeletonModel::buildDefaultLevelDetail(), NL3D::CSkeletonModel::changeMRMDistanceSetup(), NL3D::CMeshMRMSkinnedGeom::changeMRMDistanceSetup(), NL3D::CMeshMRMGeom::changeMRMDistanceSetup(), NL3D::CMeshMRMSkinnedGeom::serial(), and NL3D::CSkeletonModel::updateSkinRenderLists().

float NL3D::CMRMLevelDetail::DistanceMiddle
 

The MRM has 50% of its faces at dist==DistanceMiddle. nlassert if <= DistanceFinest.

Definition at line 63 of file mrm_level_detail.h.

Referenced by NL3D::CMeshMRMSkinnedGeom::build(), NL3D::CMeshMRMGeom::build(), NL3D::CSkeletonModel::buildDefaultLevelDetail(), NL3D::CSkeletonModel::changeMRMDistanceSetup(), NL3D::CMeshMRMSkinnedGeom::changeMRMDistanceSetup(), NL3D::CMeshMRMGeom::changeMRMDistanceSetup(), NL3D::CMeshMRMSkinnedGeom::serial(), and NL3D::CSkeletonModel::updateSkinRenderLists().

float NL3D::CMRMLevelDetail::DistancePow
 

Definition at line 69 of file mrm_level_detail.h.

Referenced by compileDistanceSetup(), getLevelDetailFromDist(), and NL3D::CMeshMRMSkinnedGeom::serial().

uint32 NL3D::CMRMLevelDetail::MaxFaceUsed
 

For Load balancing, the max number of faces this MRM use.

Definition at line 58 of file mrm_level_detail.h.

Referenced by NL3D::CMeshMRMSkinnedGeom::build(), NL3D::CMeshMRMGeom::build(), NL3D::CSkeletonModel::buildDefaultLevelDetail(), getLevelDetailFromPolyCount(), getNumTriangles(), NL3D::CMeshMRMSkinnedGeom::serial(), and NL3D::CSkeletonModel::updateSkinRenderLists().

uint32 NL3D::CMRMLevelDetail::MinFaceUsed
 

For Load balancing, the min number of faces this MRM use.

Definition at line 56 of file mrm_level_detail.h.

Referenced by NL3D::CMeshMRMSkinnedGeom::build(), NL3D::CMeshMRMGeom::build(), NL3D::CSkeletonModel::buildDefaultLevelDetail(), getLevelDetailFromPolyCount(), getNumTriangles(), NL3D::CMeshMRMSkinnedGeom::serial(), and NL3D::CSkeletonModel::updateSkinRenderLists().

float NL3D::CMRMLevelDetail::OODistanceDelta
 

compiled info (public for faster serial)

Definition at line 68 of file mrm_level_detail.h.

Referenced by compileDistanceSetup(), getLevelDetailFromDist(), and NL3D::CMeshMRMSkinnedGeom::serial().


The documentation for this class was generated from the following files:
Generated on Tue Mar 16 06:56:55 2004 for NeL by doxygen 1.3.6