Problem reading mesh vertices

Started by
7 comments, last by Muhammad Haggag 18 years, 5 months ago
hey guys i am using this function to get vertex data from a mesh but i am having an error when i want to use these vertexs so i don't get the same result of the original mesh vertexs the vertexs are arranged like circles but not like the ellipse mesh i have plz see this sourse for the function i used and the pictures that shows 1st the vertexs as points and the ellipse that i took the vertex from it which is around the car and in the 2nd picture see when i draw the triangles of the vertexs in white collor it gave me a terrible shape

private PositionNormalTexVertex[] vbData;
		public struct PositionNormalTexVertex
		{
			public Vector3 Position;
			public Vector3 Normal;
			public  float Tu0, Tv0;
			public static readonly VertexFormats FVF = VertexFormats.Position | VertexFormats.Texture1;
		}
		public void ArrayBasedReadWrite()
		{
			//Create a vertex buffer in the managed pool
			VertexBuffer vb = BoundMeshClass.mesh.VertexBuffer;
			//Fill an array of the appropriate type with the VB data using Lock()
			//This lock overload simply locks the entire VB -- setting ReadOnly can improve perf when reading a vertexbuffer
			vbData = vb.Lock(
				0, typeof(PositionNormalTexVertex), 
				LockFlags.None, BoundMeshClass.mesh.NumberVertices) as
				PositionNormalTexVertex[];
		
			//Unlock the buffer
			vb.Unlock();
			vb.Dispose();
		}


1.jpg 2.jpg [Edited by - Muhammad Haggag on November 13, 2005 2:47:16 AM]
Advertisement
how to add pictures ????????????? it's in a:\1.jpg and a:\2.jpg
Upload them to someplace like http://tinypic.com/ and post the link in here.
see the pictures on those links plz and thanks DrEvil

http://tinypic.com/flztc6.jpg

http://tinypic.com/flzti8.jpg
Could be that you're not specifying the normal in the FVF.

no i don't think so , i tried it but the same problem :(

it is a littel better see it in this picture on the following URL : http://tinypic.com/fm0zuv.jpg
Are you sure that the mesh data you are locking is in the same format as you're extracting? if it isn't then you'll get all sorts of funky corruption [grin]

Check the FVF you're using against the one that the mesh reports; if they're *not* the same then you've found your problem.

Secondly, meshes tend to have index buffers to arrange the vertices into actual triangles - which is probably part of the reason why you're getting a complete mess when you try to render the vertex data as triangles (second picture).

hth
Jack

<hr align="left" width="25%" />
Jack Hoxley <small>[</small><small> Forum FAQ | Revised FAQ | MVP Profile | Developer Journal ]</small>

You have managed to skillfully ignore not only the sticky rules thread and the Forum FAQ, but also common sense. There's nothing important about your thread. It's a thread, like every other thread. Except it's given a meaningless title.

Thread closed. Don't try to create another on the same problem, because I'll delete it. Read the rules. And follow them.

EDIT: Now that you've hopefully read the rules, thread re-opened. However, the next time you break the rules, I will suspend you.

[Edited by - Muhammad Haggag on November 13, 2005 2:27:20 AM]

This topic is closed to new replies.

Advertisement