Jump to content
  • Advertisement
Sign in to follow this  
gunhawk

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

This topic is 4841 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);
		
	meshTerrain.SetVertexBufferData(vertices,LockFlags.None);
	meshTerrain.SetIndexBufferData(indices,LockFlags.None);	

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

....

// in render sub
	for (int i = 0; i < numSubSets; ++i)
	{
		meshTerrain.DrawSubset(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
Advertisement
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 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!