• Popular Now

• 13
• 15
• 19
• 27
• 9

Archived

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

Problem with D3DXIntersect

This topic is 5224 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

Recommended Posts

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]

Share on other sites
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
ONIRIC GAMES