# returning verts from mesh...

This topic is 4437 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

will this return the vertices of my mesh???
[source lang=c#]
VertexBuffer vb = mesh.VertexBuffer;
int[] p = { mesh.mesh.NumberVertices };
Array na = vb.Lock(0, typeof(Vector3), LockFlags.ReadOnly, p);


thanks, Devin

##### Share on other sites
I am not really experienced with MDX, but I will give it a shot. I was looking at the documentation here and just about everything you are doing seems right. Except for the 2nd parameter, the type of the vertex structure. Are you sure that the vertex structure of this VB is just a Vector3? Normally, you are going to have a structure with multiple members, such as:

struct MyVertexStruct{   Vector3 position;   Vector3 normal;   Vector2 texCoords;};

Beyond that, are you getting any messages from the debug output?

##### Share on other sites
Sure looks ok to me other than what Mr. Dustin Franklin talked about.
using (VertexBuffer vb = mesh.VertexBuffer){	int[] p = {mesh.NumberVertices};	Array ar = vb.Lock(0, typeof(CustomVertex.PositionNormalTextured), LockFlags.None, p);}

This should work. Remember that you can get the mesh's vertex format from the Mesh.VertexFormat property and then plug that into the appropriate field for the lock method.

I hope this helps.
Take care.
PS: thanks for Dustin that highlighted the fact of the vertex format.

##### Share on other sites
Thanks, that was it!