Skip to main content
GameDev.net gamedev.net
🔒 Locked

Simplifying a Mesh - Please help!

Started by Jiia May 14, 2004 at 9:30 AM 3 replies 550+ views
Original Post
Jiia
Jiia
I've got a terrible headache from playing around with these SDK functions for so long. Can anyone see what I'm doing wrong? See results of simplification here. Please note that the boundries are not being screwed up, even though they appear to be in the image. Just from taking snapshots at different angles. See all of those faces that could be oh-so-easily removed? But DirectX seems to prefer only removing the easy ones on the top and bottom. This is useless to me. Here's the code I'm using to do this. Not much to it:
VOID KTileMesh::ReduceMesh(LPD3DXMESH *Mem)			// Simplifies mesh, stores new mesh in Mem

{
	ULONG *Adjacency = new ULONG[3 * Mesh->GetNumFaces()];
	ULONG *AdjacencyOut = new ULONG[3 * Mesh->GetNumFaces()];

	hVal = Mesh->GenerateAdjacency(0.01f, Adjacency);
	if(FAILED(hVal))
		Error("KTileMesh::ReduceMesh():GenerateAdjacency()");

	hVal = Mesh->OptimizeInplace(D3DXMESHOPT_COMPACT | D3DXMESHOPT_VERTEXCACHE, Adjacency, AdjacencyOut, NULL, NULL);
	if(FAILED(hVal))
		Error("KTileMesh::ReduceMesh():OptimizeInplace()");

	delete [] Adjacency;
	Adjacency = AdjacencyOut;

	hVal = D3DXSimplifyMesh(Mesh, Adjacency, NULL, NULL, 1 /* Min value */, D3DXMESHSIMP_FACE, Mem);
	if(FAILED(hVal))
		Error("KTileMesh::ReduceMesh():D3DXSimplifyMesh()");

	delete [] Adjacency;
}
Any help / pointers would be appreciated. [edited by - Jiia on May 14, 2004 10:31:55 AM]
Mezz
Mezz
You could try calling D3DXCleanMesh() before doing the simplification. Check it out in the docs for more info.

-Mezz
Jiia
Jiia
No luck. I tried cleaning it before, then after OptimizeInplace (not in the same run). No difference at all.

I guess it would help if I understood half of what I was sending to these functions. The SDK documentation and included samples tell you NOTHING about them. The only sample that uses the simplify-mesh function is the donut demo, which has no comments at all in the 100 lines of code where they do this.
Jiia
Jiia
Here are the Face-Counts it's accomplishing:

Direct3D: 12552 -> 6165
3DStudio: 12552 -> 1744

But most of the reason Direct3D even came close to 3D Studio was because my terrain is right now just a flat plane containing 8184 faces. This won't hold true in the game. On the corners and extrusions, Direct3D doesn't seem to be doing anything at all. Some areas it completely ignores a 32x32 square grid of totally flat faces.

[edited by - Jiia on May 14, 2004 1:04:39 PM]
Muhammad Haggag
Muhammad Haggag
Try changing the MinValue to something more reasonable. I don''t know how this value affects the simplifier, but who knows. Start, for example, with half the number of faces in the mesh. If that doesn''t help much, post your results to the DIRECTXDEV mailing list. Someone from the D3DX team is likely to respond.

Muhammad Haggag,
Optimize
Bitwise account: MHaggag -

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.