• Advertisement

Archived

This topic is now archived and is closed to further replies.

Translation Error

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

When I build I get this error: 3dx9.lib(d3dxmath.obj) : error LNK2005: _D3DXVec2Normalize@8 already defined in d3dx.lib(d3dumath.obj) d3dx9.lib(d3dxmath.obj) : error LNK2005: _D3DXVec2Hermite@24 already defined in d3dx.lib(d3dumath.obj) There are 56 more errors just like these, it lists all the different commands, presumably in d3dmath. The line that seems to be causing the error is: D3DXMatrixTranslation(&matTranslate, position.x, position.y, position.z); I'm using it like this:
void CGfxEntityModel::render(const D3DXVECTOR3 &position)
{
	D3DXMATRIX matTranslate;
	
//	Translate into position

	D3DXMatrixTranslation(&matTranslate, position.x, position.y, position.z);
	
//	Apply our world matrix

	gD3dDevice->SetTransform(D3DTS_WORLD, &matTranslate);

	for (DWORD i = 0; i < m_NumMaterials; i++)
	{	
//		Set the material and texture for this subset

		gD3dDevice->SetMaterial(&m_MeshMaterials[i]);
		gD3dDevice->SetTexture(0, m_MeshTextures[i]);
	
//		Draw the mesh subset

		m_Mesh->DrawSubset(i);
	}
}

d3d9.h and d3d9x.h are included. I have also checked that the position being passed into the function, it passes the correct position. Also when I edit out the translation line and the gD3DDevice line, my program exits when it gets to: m_Mesh->DrawSubset(i); Any help would be appreciated, and a solution to the problem would be even more appreciated. --Dannon [edited by - Dannon on April 16, 2004 5:18:26 AM]

Share this post


Link to post
Share on other sites
Advertisement
You don't need to link to both d3dx.lib and d3dx9.lib, choose one of them. Check your linker options* and if any source file adds d3dx.lib via a #pragma. Change them to use d3dx9.lib instead.

* In Visual Studio: Project -> Properties -> Linker -> Input -> Additional Dependencies

[edited by - EliasAE on April 16, 2004 5:54:15 AM]

Share this post


Link to post
Share on other sites
Thanks a lot, that solved the linking problem.

Anyone know why it would crash when getting to:

m_Mesh->DrawSubset(i);

--Dannon

Share this post


Link to post
Share on other sites
The most obvious reason for that line to crash is that the pointer m_Mesh is invalid. Double check that you initialize it correctly.

Do you get an access violation? Does the debug output say anything interesting? Use your DirectX-debug runtime with debug output set to high to see if that gives you more information.

You could also set a breakpoint at that line to check that everything seems ok, before executing it.

/EliasAE

Share this post


Link to post
Share on other sites

  • Advertisement