Incorrect D3DXComputeTangentFrameEx FVF format?

Started by
0 comments, last by Carradine 17 years, 4 months ago
Hello, I have been scouring the forums about this problem, and has helped out quite a bit until this hitch. I am loading in a directX mesh, and attempting to generate the tangent and binormals of the mesh. I clone the mesh, and clean it and validate it, which both return S_OK, however when I run the D3DXComputeTangentFrameEx() function itself while debugging it with the debug libraries I get the message "U Partial channel not present in output mesh". I figure this is a problem with the FVF, but I do not understand what space it needs exactly? I have entered D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEXCOORDSIZE3(0) in the cloned mesh to have the space to enter the values. Below is my code:

		//For checking to see if the mesh was loaded with normals
		int tPreNormal = pMesh->GetFVF() & D3DFVF_NORMAL;

		//Clone the mesh
		if(FAILED(pMesh->CloneMeshFVF(D3DXMESH_MANAGED, pMesh->GetFVF() | D3DFVF_NORMAL | D3DFVF_TEXCOORDSIZE3(0) | D3DFVF_TEXCOORDSIZE3(0)
			, g_pd3dDevice, &tempMesh.g_pMesh)))
			MessageBox(NULL,"Incorrect Mesh Format", "Mesh Problem",MB_OK);
		else
		{
	
		}

		HRESULT hr;
		
		//If the mesh did not have pre-calculated normals, then calculate them
		if( !tPreNormal )
			hr = D3DXComputeNormals( tempMesh.g_pMesh, NULL );

		//Prepare mesh for tangent calculations
		DWORD* adjacency = new DWORD[3 * tempMesh.g_pMesh->GetNumFaces()];
		hr = tempMesh.g_pMesh->GenerateAdjacency( 1e-4f, adjacency );


		hr = D3DXCleanMesh( D3DXCLEAN_BOWTIES, tempMesh.g_pMesh, (DWORD*)pD3DXAdjacencyBuffer->GetBufferPointer(), &tempMesh.g_pMesh, (DWORD*)pD3DXAdjacencyBuffer->GetBufferPointer(), NULL );


		hr = D3DXValidMesh( tempMesh.g_pMesh, (DWORD*)pD3DXAdjacencyBuffer->GetBufferPointer(), NULL );


		//Create and store the tangent information
		hr = D3DXComputeTangentFrameEx(tempMesh.g_pMesh, D3DDECLUSAGE_TEXCOORD, 0,   
			D3DDECLUSAGE_TANGENT, 0, 
			D3DDECLUSAGE_BINORMAL, 0, 
			D3DDECLUSAGE_NORMAL, 0, 
			D3DXTANGENT_GENERATE_IN_PLACE,
			(DWORD*)pD3DXAdjacencyBuffer->GetBufferPointer(), 0.01f, 0.25f, 0.01f, NULL, NULL);

thanks for any help. Carradine

--------------------------Vantage: Greenlit on Steam / Independent Games Festival Submission http://www.crystaldragon.com

Advertisement
Okay I believe I figured it out and switched over to the D3DVERTEXELEMENT9 Structure delcaration method since it is the current declaration style, and just used the CloneMesh() function (not the CloneMeshFVF()) since D3DVERTEXELEMENT9 sctructures can actually specify for tangents and binormals.

--------------------------Vantage: Greenlit on Steam / Independent Games Festival Submission http://www.crystaldragon.com

This topic is closed to new replies.

Advertisement