Jump to content
  • Advertisement
Sign in to follow this  

Strange Error when generating Mesh from Vertexbuffer

This topic is 4717 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);  
		Microsoft.DirectX.Direct3D.Mesh tempMesh = mesh.Clone(mesh.Options.Value,mesh.VertexFormat | VertexFormats.Normal,dev);
		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
Sign in to follow this  

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!