Share via


Mesh Class (Microsoft.DirectX.Direct3D)

How Do I...?

  • Create a Mesh Object

Manipulates mesh objects.

Definition

Visual Basic NotInheritable Public Class Mesh
    Inherits BaseMesh
C# public sealed class Mesh : BaseMesh
C++ public ref class Mesh sealed : BaseMesh
JScript public final class Mesh extends BaseMesh

Members Table

The following table lists the members exposed by the object.

Events

Event Description
Disposing Occurs when the Dispose method is called or when the Mesh object is finalized and collected by the garbage collector of the .NET common language runtime.

Methods

Method Description
static (Shared in Visual Basic) Box Uses a left-handed coordinate system to create a mesh that contains an axis-aligned box.
static (Shared in Visual Basic) Clean Cleans a mesh, preparing it for simplification.
Clone Clones, or copies, a mesh object. Inherited from BaseMesh.
ComputeNormals Computes normals for each vertex in a mesh. Inherited from BaseMesh.
ComputeTangent Computes the tangent vectors for the texture coordinates given in a texture stage.
ComputeTangentFrame Performs tangent frame computations on a mesh. Tangent, binormal, and optionally normal vectors are generated. Singularities are handled as required by grouping edges and splitting vertices.
ConvertAdjacencyToPointReps Converts mesh adjacency information to an array of point representatives. Inherited from BaseMesh.
static (Shared in Visual Basic) ConvertMeshSubsetToSingleStrip Converts the specified mesh subset into a single triangle strip..
static (Shared in Visual Basic) ConvertMeshSubsetToStrips Converts the specified mesh subset into a series of strips.
ConvertPointRepsToAdjacency Converts point representative data to mesh adjacency information. Inherited from BaseMesh.
static (Shared in Visual Basic) Cylinder Uses a left-handed coordinate system to create a mesh that contains a cylinder.
Dispose Immediately releases the unmanaged resources used by the Mesh object.
DrawSubset Draws a subset of a mesh. Inherited from BaseMesh.
Equals Returns a value that indicates whether the current instance is equal to a specified object.
Finalize Allows the Mesh object to free resources before it is destroyed by the garbage collector.
static (Shared in Visual Basic) FromFile Loads a mesh from a .x file.
static (Shared in Visual Basic) FromStream Loads a mesh from a StreamLeave Site.
static (Shared in Visual Basic) FromX Loads a mesh from an XFileData object.
GenerateAdjacency Generates adjacency information based on mesh indices. Inherited from BaseMesh.
GetAttributeTable Retrieves an attribute table for a mesh. Inherited from BaseMesh.
GetHashCode Returns the hash code for the current instance.
GetObjectByValue This member supports the infrastructure for Microsoft DirectX 9.0 for Managed Code and is not intended to be used directly from your code.
Intersect Determines whether a ray intersects with a mesh.
IntersectSubset Intersects the specified ray with a given mesh subset.
static (Shared in Visual Basic) LoadHierarchy Loads the first frame hierarchy from a StreamLeave Site.
static (Shared in Visual Basic) LoadHierarchyFromFile Loads the first frame hierarchy in a DirectX (.x) file.
LockAttributeBuffer Locks an attribute buffer and obtains its memory.
LockAttributeBufferArray Locks an attribute buffer and obtains its memory.
LockIndexBuffer Locks an index buffer and obtains the index buffer data. Inherited from BaseMesh.
LockVertexBuffer Locks a vertex buffer and obtains a pointer to the vertex buffer memory. Inherited from BaseMesh.
Mesh Creates a new Mesh instance.
static (Shared in Visual Basic) op_Equality Compares the current instance of a class to another instance to determine whether they are the same. Inherited from BaseMesh.
static (Shared in Visual Basic) op_Equality Compares the current instance of a class to another instance to determine whether they are the same.
static (Shared in Visual Basic) op_Inequality Compares the current instance of a class to another instance to determine whether they are different. Inherited from BaseMesh.
static (Shared in Visual Basic) op_Inequality Compares the current instance of a class to another instance to determine whether they are different.
Optimize Controls the reordering of mesh faces and vertices to optimize performance and generate an output mesh.
OptimizeInPlace Controls the reordering of mesh faces and vertices to optimize performance.
static (Shared in Visual Basic) Polygon Uses a left-handed coordinate system to create a mesh that contains an n-sided polygon.
raise_Disposing Raises the Microsoft.DirectX.Direct3D.Mesh.Disposing event when called from within a derived class.
Save Saves the mesh to the specified stream object.
static (Shared in Visual Basic) SaveHierarchyToFile Creates a DirectX (.x) file and saves the mesh hierarchy and corresponding animations in it.
SetAttributeTable Sets a mesh's attribute table and specifies the number of entries stored in it.
SetIndexBufferData Sets index buffer data. Inherited from BaseMesh.
SetVertexBufferData Sets vertex buffer data. Inherited from BaseMesh.
static (Shared in Visual Basic) Simplify Generates a simplified mesh using the provided weights that come as close as possible to the given minValue.
static (Shared in Visual Basic) Sphere Uses a left-handed coordinate system to create a mesh that contains a sphere.
static (Shared in Visual Basic) Split Splits a mesh into multiple meshes that are smaller than the specified size.
static (Shared in Visual Basic) Teapot Uses a left-handed coordinate system to create a mesh that contains a teapot.
static (Shared in Visual Basic) TessellateNPatches Tessellates the given mesh using the N-patch tessellation scheme.
static (Shared in Visual Basic) TextFromFont Creates a mesh that contains the specified text, using a .NET font object.
static (Shared in Visual Basic) Torus Uses a left-handed coordinate system to create a mesh that contains a torus.
UnlockAttributeBuffer Unlocks an attribute buffer.
UnlockIndexBuffer Unlocks an index buffer. Inherited from BaseMesh.
UnlockVertexBuffer Unlocks a vertex buffer. Inherited from BaseMesh.
UpdateSemantics Allows the user to change the mesh declaration without changing the data layout of the vertex buffer.

The call is valid only if the old and new declaration formats have the same vertex size. Inherited from BaseMesh.
UpdateUnmanagedPointer Updates the unmanaged pointer for this BaseMesh object. This method supports the Microsoft .NET Framework infrastructure and is not intended to be used directly in your code. Inherited from BaseMesh.
UpdateUnmanagedPointer Updates the unmanaged pointer for this Mesh object. This method supports the Framework infrastructure and is not intended to be used directly in your code.
Validate Validates a mesh.
WeldVertices Welds together replicated vertices that have equal attributes.

Properties

Property Description
Declaration Retrieves a declaration that describes the vertices in a mesh. Inherited from BaseMesh.
Device Retrieves the device associated with a mesh. Inherited from BaseMesh.
Disposed Gets a value that indicates whether the object is disposed.
IndexBuffer Retrieves the data in an index buffer. Inherited from BaseMesh.
NumberAttributes Retrieves the number of entries stored in an attribute table for a mesh. Inherited from BaseMesh.
NumberBytesPerVertex Retrieves the number of bytes per vertex. Inherited from BaseMesh.
NumberFaces Retrieves the number of faces in a mesh. Inherited from BaseMesh.
NumberVertices Retrieves the number of vertices in a mesh. Inherited from BaseMesh.
Options Retrieves the mesh options enabled for the current mesh at creation time. Inherited from BaseMesh.
UnmanagedComPointer Returns the unmanaged Component Object Model (COM) ID3DXMesh interface pointer.
UnmanagedComPointer Returns the unmanaged COM ID3DXBaseMesh interface pointer. Inherited from BaseMesh.
VertexBuffer Retrieves the vertex buffer of a mesh. Inherited from BaseMesh.
VertexFormat Retrieves the vertex format that describes the contents of vertices. Inherited from BaseMesh.

Inheritance Hierarchy

ObjectLeave Site

MarshalByRefObjectLeave Site

BaseMesh

Mesh

Remarks

This object inherits additional functionality from the BaseMesh object.

How Do I...?

Create a Mesh Object

This example shows how to create a Mesh object.

In the following C# code example, device is assumed to be the rendering Device.

              [C#]
              
int numberVerts = 8;
short[] indices = {
    0,1,2, // Front Face 
    1,3,2, // Front Face 
    4,5,6, // Back Face 
    6,5,7, // Back Face 
    0,5,4, // Top Face 
    0,2,5, // Top Face 
    1,6,7, // Bottom Face 
    1,7,3, // Bottom Face 
    0,6,1, // Left Face 
    4,6,0, // Left Face 
    2,3,7, // Right Face 
    5,2,7 // Right Face 
};

Mesh mesh = new Mesh(numberVerts * 3, numberVerts, MeshFlags.Managed,
                     CustomVertex.PositionColored.Format, device);

using(VertexBuffer vb = mesh.VertexBuffer)
{
    GraphicsStream data = vb.Lock(0, 0, LockFlags.None);

    data.Write(new CustomVertex.PositionColored(-1.0f, 1.0f, 1.0f, 0x00ff00ff));
    data.Write(new CustomVertex.PositionColored(-1.0f, -1.0f, 1.0f, 0x00ff00ff));
    data.Write(new CustomVertex.PositionColored(1.0f, 1.0f, 1.0f, 0x00ff00ff));
    data.Write(new CustomVertex.PositionColored(1.0f, -1.0f, 1.0f, 0x00ff00ff));
    data.Write(new CustomVertex.PositionColored(-1.0f, 1.0f, -1.0f, 0x00ff00ff));
    data.Write(new CustomVertex.PositionColored(1.0f, 1.0f, -1.0f, 0x00ff00ff));
    data.Write(new CustomVertex.PositionColored(-1.0f, -1.0f, -1.0f, 0x00ff00ff));
    data.Write(new CustomVertex.PositionColored(1.0f, -1.0f, -1.0f, 0x00ff00ff));

    vb.Unlock();
}

using (IndexBuffer ib = mesh.IndexBuffer)
{
    ib.SetData(indices, 0, LockFlags.None);
}

Class Information

Namespace Microsoft.DirectX.Direct3D
Assembly Microsoft.DirectX.Direct3DX (microsoft.directx.direct3dx.dll)
Strong Name Microsoft.DirectX.Direct3DX,  Version=1.0.900.0,  Culture=neutral,  PublicKeyToken=d3231b57b74a1492