• Advertisement
Sign in to follow this  

Paramter conversion help.

This topic is 3347 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 am trying to clone one of my mesh's to a different vertex format in order to make normal maps, but I get this error. Not really sure why. Any ideas? : error C2664: 'D3DXComputeTangentFrameEx' : cannot convert parameter 15 from 'ID3DXMesh *' to 'ID3DXMesh **' 1> Types pointed to are unrelated; conversion requires reinterpret_cast, C-style cast or function-style cast 1>Network.cpp
// Load the mesh.
	ID3DXBuffer *materialBuffer, *adjacencyBuffer;
	D3DXLoadMeshFromX( GetFilename(), D3DXMESH_MANAGED, g_engine->GetDevice(), &adjacencyBuffer, &materialBuffer, NULL, &m_staticMesh->NumMaterials, &tempMesh );


	// Get the vertex declaration for the NMapVertex.
	D3DVERTEXELEMENT9 elems[MAX_FVF_DECL_SIZE];
	UINT numElems = 0;
	NMapVertex::Decl->GetDeclaration(elems, &numElems);

	// Clone the mesh to the NMapVertex format.
	ID3DXMesh* clonedTempMesh = 0;
	tempMesh->CloneMesh(D3DXMESH_MANAGED, elems, g_engine->GetDevice(), &clonedTempMesh);

	// Now use D3DXComputeTangentFrameEx to build the TNB-basis for each vertex
	// in the mesh.  
	
	D3DXComputeTangentFrameEx(
	  clonedTempMesh, // Input mesh
	  D3DDECLUSAGE_TEXCOORD, 0, // Vertex element of input tex-coords.  
      D3DDECLUSAGE_BINORMAL, 0, // Vertex element to output binormal.
	  D3DDECLUSAGE_TANGENT, 0,  // Vertex element to output tangent.
      D3DDECLUSAGE_NORMAL, 0,   // Vertex element to output normal.
      0, // Options
      0, // Adjacency
	  0.01f, 0.25f, 0.01f, // Thresholds for handling errors
	  m_staticMesh->originalMesh, // Output mesh
	  0);         // Vertex Remapping
	
	SAFE_RELEASE( tempMesh );
	SAFE_RELEASE( clonedTempMesh );
	
	
	// Optimise the mesh for better rendering performance.
	m_staticMesh->originalMesh->OptimizeInplace( D3DXMESHOPT_COMPACT | D3DXMESHOPT_ATTRSORT | D3DXMESHOPT_VERTEXCACHE, (DWORD*)adjacencyBuffer->GetBufferPointer(), NULL, NULL, NULL );


Here's the vertex structure
 struct NMapVertex
{
	D3DXVECTOR3 pos;
	D3DXVECTOR3 tangent;
	D3DXVECTOR3 binormal;
	D3DXVECTOR3 normal;
	D3DXVECTOR2 tex0;

	static IDirect3DVertexDeclaration9* Decl;
}; 

Share this post


Link to post
Share on other sites
Advertisement
The error is telling you the exact problem: the function expects a parameter of type "ID3DXMesh**", and you're giving it a "ID3DXMesh*". You need to pass the address of your interface pointer, like you do when you first create the mesh and when you clone it.

Share this post


Link to post
Share on other sites
Thanks that did it, but now I get this error when I try and compile the application that runs off of the lib. This one i'm really lost on, I have had this problem before. I can see that the application cannot find the vertex declaration from the error, but I am not sure you to go about fixing it.

1>------ Build started: Project: Test, Configuration: Debug Win32 ------
1>Compiling...
1>Main.cpp
1>Linking...
1>engine.lib(Mesh.obj) : error LNK2001: unresolved external symbol "public: static struct IDirect3DVertexDeclaration9 * NMapVertex::Decl" (?Decl@NMapVertex@@2PAUIDirect3DVertexDeclaration9@@A)
1>.\Debug/Test.exe : fatal error LNK1120: 1 unresolved externals
1>Build log was saved at "file://c:\Documents and Settings\HP_Administrator\Desktop\Source\Chapter 8\Test\Debug\BuildLog.htm"
1>Test - 2 error(s), 0 warning(s)
========== Build: 0 succeeded, 1 failed, 1 up-to-date, 0 skipped ==========

Share this post


Link to post
Share on other sites
Quote:
Original post by XVincentX
Have you linked d3d9.lib?


I have compiled directx before, so that doesn't seem to be it. Do I have to put something in the header, to tell the compiler where the structure is?

Share this post


Link to post
Share on other sites
The problem is that in C++ static members are declared at class scope, but defined at file scope. This means that just declaring it like you've done doesn't mean it'll be defined in all of your translation units, which means the linker will keel over when it tries to find the definition. You'll have to define it in every translation unit (.cpp file) that uses it.

See the MSDN docs.

Share this post


Link to post
Share on other sites
Quote:
Original post by MJP
The problem is that in C++ static members are declared at class scope, but defined at file scope. This means that just declaring it like you've done doesn't mean it'll be defined in all of your translation units, which means the linker will keel over when it tries to find the definition. You'll have to define it in every translation unit (.cpp file) that uses it.

See the MSDN docs.


Thats exactly the problem, I looked through the link you gave me, but I cannot seem to be able to apply the concept to my app. Would you be able to show me what to put in. I have been trying and trying, but can't seem to get any results. Thanks though. You set me on the right track.

Share this post


Link to post
Share on other sites
Put

IDirect3DVertexDeclaration9 * NMapVertex::Decl;

in one source file at namespace scope (not inside a class or function definition).

Share this post


Link to post
Share on other sites
Thank you so much that did it. I don't know why I couldn't do that myself. I tried it in so many ways similar to that, but I didn't get it. Thank you though. I see how its done now.

Share this post


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

  • Advertisement