Class for handling multiple levels of detail for a Mesh
This class reduces the complexity of the geometry it is given. This class is dedicated to reducing the number of triangles in a given mesh taking into account seams in both geometry and texture co-ordinates and meshes which have multiple frames. The primary use for this is generating LOD versions of Mesh objects, but it can be used by any geometry provider. The only limitation at the moment is that the provider uses a common vertex buffer for all LODs and one index buffer per LOD. Therefore at the moment this class can only handle indexed geometry. NB the interface of this class will certainly change when compiled vertex buffers are supported.
Ejemplo n.º 1
0
		public void GenerateLodLevels( LodValueList lodValues, ProgressiveMesh.VertexReductionQuota reductionMethod,
		                               Real reductionValue )
		{
			RemoveLodLevels();

			LogManager.Instance.Write( "Generating {0} lower LODs for mesh {1}.", lodValues.Count, Name );

			foreach ( var subMesh in this._subMeshList )
			{
				// check if triangles are present
				if ( subMesh.IndexData.indexCount > 0 )
				{
					// Set up data for reduction
					var vertexData = subMesh.useSharedVertices ? this._sharedVertexData : subMesh.vertexData;

					var pm = new ProgressiveMesh( vertexData, subMesh.indexData );
					pm.Build( (ushort)lodValues.Count, subMesh.lodFaceList, reductionMethod, reductionValue );
				}
				else
				{
					// create empty index data for each lod
					for ( var i = 0; i < lodValues.Count; ++i )
					{
						subMesh.LodFaceList.Add( new IndexData() );
					}
				}
			}

			// Iterate over the lods and record usage
			foreach ( var value in lodValues )
			{
				// Record usage
				var lod = new MeshLodUsage();
				lod.UserValue = value;
				lod.Value = this._lodStrategy.TransformUserValue( value );
				lod.EdgeData = null;
				lod.ManualMesh = null;
				this.meshLodUsageList.Add( lod );
			}
		}