• Advertisement
Sign in to follow this  

[Odd] mview spmesh not equal to my own spmesh

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

Hi everyone, I got quite a problem here. I'm making a terrain generator which is nicely optimizing everything before it is loaded into the game. Everything is lookin fine right now, except the optimization functions of D3DX. The quadtree which is calculated, is visible in the mesh, because all those vertices have the corresponding attribute ID. When the mesh is all optimized I leave the D3DX world again, and put the vertex/index data in my own map file format again. This should work out all fine. The problem is that if I try to optimize my mesh I get: While, if I save my mesh (using D3DX functions) to an .x file, and do it manually in the DirectX8 or DirectX9 mview: It's perfect there! I've been stepping through the code of the mview project, which is included with the DX9 sdk. I've changed my code to do the same, yet I still get the same problems:
if (FAILED(D3DXCreateBuffer((myMesh->GetNumFaces())*sizeof(DWORD)*3, &m_pAdjacency))) OutputDebugString(_T("1. Error"));
if (FAILED(myMesh->GenerateAdjacency(1.0e-6f, (DWORD*)m_pAdjacency->GetBufferPointer()))) OutputDebugString(_T("2. Error"));

if(FAILED(D3DXValidMesh(myMesh, (DWORD*)m_pAdjacency->GetBufferPointer(), NULL))) 
	OutputDebugString(_T("Invalid mesh originally.\n")); 
	OutputDebugString(_T("Valid mesh originally.\n")); 

memset(&AttributeWeights, 0, sizeof(AttributeWeights));
AttributeWeights.Position = 1.0f;
AttributeWeights.Boundary = 1.0f;
AttributeWeights.Normal = 1.0f;

ID3DXSPMesh* SPMesh;
ID3DXPMesh* pPMeshTemp;

D3DXCreateSPMesh(myMesh, (DWORD*)m_pAdjacency->GetBufferPointer(), &AttributeWeights, NULL, &SPMesh);
SPMesh->ClonePMesh(SPMesh->GetOptions(), NULL, m_d3d_device, NULL,&pPMeshTemp);


D3DXSaveMeshToX(&"mesh.x",pMesh,  NULL, NULL, 0, DXFILEFORMAT_BINARY );
I have tried all kinds of things, regenerating adjacency before saving, resorting the attributes, yet it still looks messed up somehow. Does anyone have code (or an example) that does this without making it look odd? So, generating a simplified/progressive mesh without making the attribute groups look odd..? Regards, ajoling

Share this post

Link to post
Share on other sites
Hm, no one ever tried to apply attributes and then optimize the mesh? There is really a lack of information on the web and newsgroups.

Any suggestions? :)

Share this post

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

  • Advertisement