Sign in to follow this  

Strange Error when generating Mesh from Vertexbuffer

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello together. As part of my terrain code i created a terrain from a heightmap. it all works and renders fine. now i convert the vertex and index buffer to a mesh. when i render the mesh i only see dots of black rectangles which follow the terrain drawn by DrawPrimitive. This black triangles form a pattern like ......../\....... /| |\...../| |.|\/|.......|\/|. The strange thing is, that they seem to follow the heightmap, but som triangles are missing. and they are not textured or materialed.
public Microsoft.DirectX.Direct3D.Mesh GetMesh(ref Device dev)
	{
                mesh = new Microsoft.DirectX.Direct3D.Mesh(m_numIndices-2, m_numVerts*3, MeshFlags.Dynamic,  CustomVertex.PositionTextured.Format  , dev);  
			
		mesh.SetVertexBufferData(m_verts,LockFlags.None );
		mesh.SetIndexBufferData(m_indices, LockFlags.None);  
		int[] adjacency = new int[mesh.NumberFaces * 3];  
		mesh.GenerateAdjacency(0.1f, adjacency);  
		//mesh.ComputeNormals(adjacency);  
		Microsoft.DirectX.Direct3D.Mesh tempMesh = mesh.Clone(mesh.Options.Value,mesh.VertexFormat | VertexFormats.Normal,dev);
		tempMesh.ComputeNormals(adjacency);
		mesh.Dispose();
		mesh = tempMesh;  
		mesh.OptimizeInPlace(MeshFlags.OptimizeVertexCache, adjacency);  
		m_material = new Material();  
		m_material.Diffuse = Color.Green;  
		return mesh;
	
Can Anyone help? [EDIT] the triangles get textured correctly if i switch lighting explicitly off. but there are still those pattern and not every triangle drawn. Im orienting myself after Chads Tutorials at C-Unit [EDIT2] After setting the CullMode to Cull.None i get the same pattern inverted and a bit offset. Now i seem to understand it. Every second row of my TriangleStrip is not rendered by Mesh.DrawSubset(). But it is rendered by DrawIndexedPrimitive() [Edited by - Nukleon on December 19, 2005 6:53:27 PM]

Share this post


Link to post
Share on other sites

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

If you intended to correct an error in the post then please contact us.

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