returning verts from mesh...

Started by
2 comments, last by devronious 18 years, 3 months ago
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
Advertisement
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?
Dustin Franklin ( circlesoft :: KBase :: Mystic GD :: ApolloNL )
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.
Thanks, that was it!

This topic is closed to new replies.

Advertisement