Jump to content
  • Advertisement
Sign in to follow this  
PLCMeister

Why does D3DXGeneratePMesh fail?!?

This topic is 3848 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, I am trying to create a progressive mesh so that I can decrease the number of vertices in a mesh so that it renders faster. I clean, weld and validate it and there are no errors, but if the number of vertices or faces is greater than a certain amount, it fails to create the progressive mesh. How do I tell what the problem is? According to the MSDN site, the three errors that can occur - D3DXERR_CANNOTATTRSORT, D3DERR_INVALIDCALL and E_OUTOFMEMORY. None of these are occurring. I use the following code:

	hr = D3DXGeneratePMesh(m_pD3DXMesh, (DWORD*)dwAdj1,
		NULL, NULL, 1, D3DXMESHSIMP_VERTEX, &m_pD3DXPMesh);
	if (FAILED(hr))
	{
		MessageBox("Failed to create progressive mesh!", "Oh, snap!");
		m_bPMesh = false;
		if (hr == D3DXERR_CANNOTATTRSORT)
		{
			MessageBox("Attribute sort is not supported", "Error type...");
		}
		if (hr == D3DERR_INVALIDCALL)
		{
			MessageBox("The method call is invalid", "Error type...");
		}
		if (hr == E_OUTOFMEMORY)
		{
			MessageBox("Out of memory", "Error type...");
		}
	}
	else
	{
		m_bPMesh = true;
		m_pD3DXPMesh->TrimByVertices(1000, 1750, NULL, NULL);
		m_pD3DXPMesh->OptimizeBaseLOD(D3DXMESHOPT_VERTEXCACHE, NULL);
		D3DXComputeNormals(m_pD3DXPMesh, NULL);
	}


Is there another way of finding out why it fails? Oh, wait a minute, I just found out about DXGetErrorString9. Hmmm... it says "D3DXERR_INVALIDMESH". How can that be? Just before this code, I do this:

	MessageBox("Validating mesh...", "Progress...");
	if (FAILED(hr = D3DXValidMesh(m_pD3DXMesh, (DWORD*)dwAdj, &ew)))
	{
		MessageBox("Failed to validate mesh!", "Oh, snap!");
		char *chErr = new char[ew->GetBufferSize()];
		int *ptrErr = (int*)ew->GetBufferPointer();
		chErr = (char*)ptrErr;
		MessageBox(chErr, "Oh, snap!"); // Show the errors.
	}


DX9 says it's valid! What gives here? Can someone please save me from this madness? I would appreciate it.

Share this post


Link to post
Share on other sites
Advertisement
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!