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]
Strange Error when generating Mesh from Vertexbuffer
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.
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement