Sign in to follow this  
jad_salloum

Problem reading mesh vertices

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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]

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