protected virtual void ReadMeshLodInfo( BinaryReader reader )
{
// Read the strategy to be used for this mesh
string strategyName = this.ReadString( reader );
LodStrategy strategy = LodStrategyManager.Instance.GetStrategy( strategyName );
this.mesh.LodStrategy = strategy;
// number of lod levels
short lodLevelCount = ReadShort( reader );
// bool manual; (true for manual alternate meshes, false for generated)
this.mesh.IsLodManual = this.ReadBool( reader ); //readBools(stream, &(pMesh->mIsLodManual), 1);
// Preallocate submesh lod face data if not manual
if ( !this.mesh.IsLodManual )
{
for ( ushort i = 0; i < this.mesh.SubMeshCount; ++i )
{
SubMesh sm = this.mesh.GetSubMesh( i );
// TODO: Create typed collection and implement resize
for ( int j = 1; j < lodLevelCount; j++ )
{
sm.lodFaceList.Add( null );
}
}
MeshChunkID chunkId;
// Loop from 1 rather than 0 (full detail index is not in file)
for ( int i = 1; i < lodLevelCount; i++ )
{
chunkId = this.ReadChunk( reader );
if ( chunkId != MeshChunkID.MeshLODUsage )
throw new AxiomException( "Missing MeshLODUsage stream in '{0}'.", this.mesh.Name );
// Read depth
MeshLodUsage usage = new MeshLodUsage();
usage.Value = ReadFloat( reader );
usage.UserValue = Utility.Sqrt( usage.Value );
if ( this.mesh.IsLodManual )
{
this.ReadMeshLodUsageManual( reader, i, ref usage );
}
else //(!pMesh->isLodManual)
{
this.ReadMeshLodUsageGenerated( reader, i, ref usage );
}
usage.EdgeData = null;
// Save usage
this.mesh.MeshLodUsageList.Add( usage );
}
Debug.Assert( mesh.LodLevelCount == lodLevelCount );
}
}