Original Post
This is a function in a game I am making. Can anyone see why I am not able to detect a intersection with Objects in the Tank List ? I am able to detect intersection with the Terrain mesh though. I am passing the function a Projectile Position and a Direction it is traveling.
BOOL CMyD3DApplication::CheckHit(D3DXVECTOR3 vPos,D3DXVECTOR3 vDir)
{
BOOL Hit;
float u, v, Dist;
DWORD FaceIndex;
vDir += vPos;
cObject* TankPtr = m_TankList.GetParentNode();
while(TankPtr != NULL)
{
D3DXIntersect(TankPtr->mp_Mesh->GetSysMemMesh(),&vPos, &vDir,&Hit,&FaceIndex,&u,&v,&Dist,NULL,NULL);
if( Hit == TRUE && TankPtr->ID != m_pSelectedObject->ID && Dist < 0.2f)
{
return TRUE;
}
TankPtr = TankPtr->Next;
}
// This part works
D3DXIntersect(m_pTerrain->GetSysMemMesh(), &vPos, &vDir, &Hit, &FaceIndex, &u, &v, &Dist,NULL,NULL);
if(Hit == TRUE && Dist < 0.01f)
return TRUE;
return FALSE;
}
Inno