Skip to main content
gamedev.net
🔒 Locked

Problem with D3DXIntersect

Started by ms291052 1 reply 350+ views
Original Post
ms291052
ms291052
My problem is that when calling D3DXIntersect, the function returns bHit as true, only if I haven't moved my camera around at all. After I have, it always returns false, no matter how obvious it is that it should return false. I have posted the code I used below and an example program I made to demonstrate the problem can be found at http://www.geocities.com/knightsinexile/target.zip. Any help would be appriciated .
BOOL Intersect(D3DXVECTOR3 pos, D3DXVECTOR3 dir, LPD3DXMESH mesh)
{
	BOOL bHit;
	D3DXIntersect(mesh, &pos, &dir, &bHit, 0, 0, 0, 0, 0, 0);
	return bHit;
}


   
if( Intersect(PlayerPos, Normalize(LPos), g_Targets[0].m_Mesh.m_pMesh) && g_Targets[0].m_Visible && !g_Targets[0].m_Hit && g_Targets[0].m_Ready)
	{
		g_Targets[0].m_Hit = true;
		g_Targets[0].m_Visible = false;
		cout << "Target #0 hit!" << endl;
	}
P.S. In the sample there are actually 10 (it shows them loading) targets because I was expirementing, but only one should be tested or rendered. [edited by - ms291052 on November 27, 2003 12:12:44 AM] [edited by - ms291052 on November 27, 2003 12:14:05 AM] [edited by - ms291052 on November 27, 2003 12:15:08 AM]
Night Elf
Night Elf
You should post a little bit more of code. For example, how do you calculate LPos?

The intersect funcionts of D3DX are independent of any camera transforms, so chances are that you''re miscalculating either the PlayerPos or the LPos variables.



Mariano Ruggiero
Lead Programmer
ONIRIC GAMES
Coincoin
Coincoin
D3DXIntersect is calculated in object space. That means you must send camera position and direction in object space.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.