Advertisement Jump to content
Sign in to follow this  

Device.DrawIndexedPrimitive to Mesh.DrawSubset -- not working?

This topic is 4904 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

I have a working terrain grid with dynamic height that I drew using Device.DrawIndexedPrimitive. I wish to create a mesh using the same data, but when I use the exact same vertex array and index array, the outcome isn't the same. The working version is a square terrain with different heights, and the mesh version is displaying a left-bottom 3d triangle of sorts, where every triangle seems to be connected to (0,0) as one point. Any ideas on why this isn't working the same? They are both using a PositionNormalTextured format. My mesh code is below, WIDTH and HEIGHT are my max X and Z variables.
        meshTerrain = new Mesh(indices.Length/3, WIDTH * HEIGHT,0,CustomVertex.PositionNormalTextured.Format, device);

	int[] adjacency = new int[meshTerrain.NumberFaces * 10];
	meshTerrain.GenerateAdjacency(0.01F, adjacency);
	meshTerrain.OptimizeInPlace(MeshFlags.OptimizeVertexCache, adjacency); 
	numSubSets = meshTerrain.GetAttributeTable().Length;


// in render sub
	for (int i = 0; i < numSubSets; ++i)
vertices and indices are the arrays that feed my vertex and index buffers that are working properly in Device.DrawIndexedPrimitive. Any ideas?

Share this post

Link to post
Share on other sites
Okay while I've been searching for the answer, it looks like it's probably because the mesh is defaulted as a triangle fan instead of strip... so looking for how to tell the mesh to be a strip.

Share this post

Link to post
Share on other sites
Sign in to follow this  

  • Advertisement

Important Information

By using, you agree to our community Guidelines, Terms of Use, and Privacy Policy. is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!