Jump to content
  • Advertisement
Sign in to follow this  

Progressive Meshing

This topic is 4532 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 code from Frank D. Luna's book that loads in a ID3DXMesh from an X file using D3DXLoadMeshFromX(). In his provided .x file, he has a model that can change from about 8000 polys down to about 200. I am trying to load in .x files that I exported from Blender, and they load in fine, and the progressive mesh is made, however the max faces equals the min faces (or only one or two edge collapses occur ie face count goes down a whopping two). I tried this with an icosphere, a complex 3d model (suzanne the monkey provided by Blender), and with various landscapes (which are not solid) that I created. The Progressive Mesh would have the min faces equal to the max faces equal to the Source Mesh' numfaces, meaning the Progressive Mesh is created, but it's exactly the same as the Source Mesh. I did however get one of the landscape meshes to actually change in size by a whopping two faces. So, I was wondering if there was something wrong with the .x files I am exporting from Blender? I am retrieving the adjacency buffer immediately upon call to D3DXLoadMeshFromX(), optimizing the Source Mesh, and then creating the Progressive Mesh. Here is the code:
ID3DXMesh*                      SourceMesh = 0;
ID3DXPMesh*                     PMesh      = 0; // progressive mesh

ID3DXBuffer* adjBuffer  = 0;
ID3DXBuffer* mtrlBuffer = 0;
DWORD        numMtrls   = 0;

hr = D3DXLoadMeshFromX(  

/* Skipped Material loading code */

	// Optimize the mesh.

	hr = SourceMesh->OptimizeInplace(		
		(DWORD*)adjBuffer->GetBufferPointer(), // new adjacency info
		0, 0);

		::MessageBox(0, "OptimizeInplace() - FAILED", 0, 0);
		d3d::Release<ID3DXBuffer*>(adjBuffer); // free
		return false;

	// Generate the progressive mesh. 

	hr = D3DXGeneratePMesh(
		(DWORD*)adjBuffer->GetBufferPointer(), // adjacency
		0,                  // default vertex attribute weights
		0,                  // default vertex weights
		1,                  // simplify as low as possible
		D3DXMESHSIMP_FACE,  // simplify by face count

	d3d::Release<ID3DXMesh*>(SourceMesh);  // done w/ source mesh
	d3d::Release<ID3DXBuffer*>(adjBuffer); // done w/ buffer

		::MessageBox(0, "D3DXGeneratePMesh() - FAILED", 0, 0);
		return false;

	// set to original detail
	DWORD maxFaces = PMesh->GetMaxFaces();

Edit: I added code to check if the Source Mesh was valid using D3DXValidMesh and D3DXCleanMesh but they return S_OK, so that is not a problem. If no one can really explain what may be going wrong, maybe I could get a link to some sample .x file's that I may be able to load. I tried to view a couple from a game I dled on this site, but they were really low in face count to begin with, and not really made for progressive meshing. Again, only one edge collapse was occurring on a model that was about 200 polys. [Edited by - rpreller on June 26, 2006 3:26:04 AM]

Share this post

Link to post
Share on other sites
*bump* Still having the problem, which is seriously cramping my style. Still the same problem with the Dwarf model that the DirectX progressive meshing sample uses.

Edit: Great. I finally went into the DirectX progressive meshing sample and compared their code to mine. They cleaned the mesh before validating it, and then called the following. The progressive meshes work perfectly now with this one function call.

ZeroMemory( &Epsilons, sizeof(D3DXWELDEPSILONS) );
hr = D3DXWeldVertices( SMesh, 0, &Epsilons,
(DWORD*)this->adjBuffer->GetBufferPointer(), NULL, NULL );

[Edited by - rpreller on June 26, 2006 9:07:51 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!