Sign in to follow this  
CGameProgrammer

MDX: Accessing the vertices/indices from a Mesh

Recommended Posts

I know you're supposed to use Mesh.LockVertexBuffer() and Mesh.LockIndexBuffer() but they are both returning nothing, even though the mesh is loaded correctly.
Mesh X = Mesh.FromFile( @"C:\car.x", MeshFlags.Dynamic, Device );
if( X != null )
{
    Vertex[] Vertices = (Vertex[])X.LockVertexBuffer( typeof(Vertex), LockFlags.None, 0 );
    ushort[] Indices = (ushort[])X.LockIndexBuffer( typeof(ushort), LockFlags.None, 0 );
}
What am I doing wrong?

Share this post


Link to post
Share on other sites
Are you sure that the vertex format of the mesh's vertices is the same as the Vertex struct? Also, are you sure you can pass zero for the third parameter (I ask because I don't quite understand how it's used from the documentation)?

Does it work if you use the overload that returns a GraphicsStream?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this