Microsoft DirectX 8.1 (C++) |
The ProgressiveMesh sample illustrates how to load and optimize a file-based mesh using the Microsoft® Direct3DX mesh utility functions. A progressive mesh is one in which the vertex information is stored internally in a special tree that can be accessed to render the mesh with any number of vertices. This procedure is fast, so progressive meshes are ideal for level-of-detail scenarios, where objects in the distance are rendered with fewer polygons.
For more information on Direct3DX, refer to the Microsoft® DirectX® SDK documentation.
Source: (SDK root)\Samples\Multimedia\Direct3D\ProgressiveMesh
Executable: (SDK root)\Samples\Multimedia\Direct3D\Bin
The following table lists the keys that are implemented. You can use menu commands for the same controls.
Key | Action |
---|---|
ENTER | Starts and stops the scene. |
SPACEBAR | Advances the scene by a small increment. |
F1 | Shows Help or available commands. |
F2 | Prompts the user to select a new rendering device or display mode. |
ALT+ENTER | Toggles between full-screen and windowed modes. |
ESC | Exits the application. |
UP ARROW | Adds one vertex to the progressive mesh. |
DOWN ARROW | Subtracts one vertex from the progressive mesh. |
PAGE UP | Adds 100 vertices to the progressive mesh. |
PAGE DOWN | Subtracts 100 vertices from the progressive mesh. |
HOME | Displays all available vertices for the progressive mesh. |
END | Displays the minimum vertices for the progressive mesh. |
Many Microsoft Direct3D® samples in the DirectX SDK use file-based meshes. However, the ProgressiveMesh sample is a good example of the basic code necessary for loading a mesh. The Direct3DX mesh loading functionality collapses the frame hierarchy of an .x file into one mesh.
The primary reason to use progressive meshes is the call to ID3DXPMesh::SetNumVertices for the mesh.
For other samples, the basic Direct3DX mesh functionality is wrapped in a common class CD3DMesh. To keep the frame hierarchy, you can use the common class CD3DFile.
This sample uses common DirectX code that consists programming elements such as helper functions. This code is shared with other samples in the DirectX SDK. You can find the common headers and source code in (SDK root)\Samples\Multimedia\Common.