Share via


(SDK root)\Samples\Managed\Direct3D\ProgressiveMesh

This sample shows how an application can use the D3DX progressive mesh functionality to simplify meshes for faster rendering. A progressive mesh is a specialized mesh object that can increase or decrease its geometry complexity, thereby providing flexibility when drawing the mesh so that performance can be maintained at a steady level. This feature is useful when providing level of detail (LOD) support in an application.

ProgressiveMesh sample

  • Supported Languages
  • Path
  • How the Sample Works

Supported Languages

  • C#

Path

Source: (SDK root)\Samples\Managed\Direct3D\ProgressiveMesh
Executable: (SDK root)\Samples\Managed\Direct3D\Bin\x86\csProgressiveMesh.exe

How the Sample Works

The functionalities of progressive meshes are provided by the ProgressiveMesh object. This ProgressiveMesh object is similar to the Mesh object with additional methods for managing the mesh's complexity. The progressive mesh can be used just like a regular mesh. To render it, the sample loops through its materials and calls DrawSubset to send the geometry subset to the device. To adjust the progressive mesh's LOD, the sample sets the ProgressiveMesh.NumberVertices property to the desired number of vertices. A progressive mesh will simplify or enhance its geometry to match the number of vertices as closely as possible.

The sample also shows an optimization technique for progressive meshes by trimming multiple progressive meshes. Trimming limits the maximum and minimum number of vertices or faces a progressive mesh can have. The sample divides the range (maximum - minimum) of the progressive mesh vertices into ten sub-ranges. After the sub-ranges are computed, the sample creates ten progressive meshes by calling ProgressiveMesh.Clone on the original mesh. Then the sample calls ProgressiveMesh.TrimByVertices on each progressive mesh using a different sub-range. After setting the range of vertices, the sample calls ProgressiveMesh.OptimizeBaseLevelOfDetail to optimize the mesh's vertex and index buffers. Whenever the user changes the vertex count, the new vertex count is checked against the range of the optimized progressive mesh set, and the mesh whose range contains the desired vertex count is selected the ProgressiveMesh.NumberVertices property.

The advantage of using multiple meshes is that adjusting LOD is more efficient than using a single progressive mesh. The performance load of changing LOD is directly proportional to the difference in complexity (represented by vertex count in this sample). Simplifying a mesh by reducing the number of vertices by ten takes less time than reducing the vertex count by 100. That is why this sample achieves better performance by trimming several progressive meshes, each of which covers a smaller LOD range.