Original Post
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]