Microsoft DirectX 9.0 SDK Update (October 2004)

BaseMesh.VertexFormat Property

Language:

Note: This documentation is preliminary and is subject to change.
How Do I...?

Retrieves the vertex format that describes the contents of vertices.

Definition

Visual Basic .NET Public ReadOnly Property VertexFormat As VertexFormats
C# public VertexFormats VertexFormat { get; }
Managed C++ public: __property VertexFormats get_VertexFormat();
JScript .NET public function get VertexFormat() : VertexFormats

Property Value

Microsoft.DirectX.Direct3D.VertexFormats . A VertexFormats object that describes the content of the vertices associated with the mesh.

This property is read-only. 

Remarks

If the vertex format cannot be mapped directly to a flexible vertex format (FVF) code, this method can return 0. This can occur when a mesh created from a vertex declaration does not have the same order and elements as those supported by the FVF codes.

Exceptions
InvalidCallException The method call is invalid. For example, a method's parameter might contain an invalid value.

How Do I...?

Clone a Mesh

This example shows how to clone a mesh to add space for normals, texture coordinates, colors, weights, etc. that were not originally present.

In the following C# code example, after the mesh is loaded from a file, the Mesh.Clone method is called. The call to pMesh.Clone obtains mesh flags from pMesh, and adds flags for supported VertexFormats and vertex normals.

The original pMesh mesh object is overwritten to contain these additional values. Note that pMesh is disposed before setting to the updated temporary mesh object.

In this example, device is assumed to be the rendering Device.

              [C#]
              
using Microsoft.DirectX.Direct3D; pMesh = Mesh.FromFile("a_mesh_file.x", MeshFlags.Managed, device); if ((pMesh.VertexFormat & VertexFormats.Normal) == 0) { Mesh pTempMesh = pMesh.Clone(pMesh.Options.Value, pMesh.VertexFormat | VertexFormats.Normal, device); pTempMesh.ComputeNormals(); pMesh.Dispose(); pMesh = pTempMesh; }

Applies To

Mesh, ProgressiveMesh

© 2004 Microsoft Corporation. All rights reserved. Terms of use.

Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center