Original Post
Hi I have a bit of trouble with D3DXIntersect. I am using it in a fps in the shooting function and there is something wrong. Hopefully someone will be able to help me. for(vector::iterator it = world->GetSoldiers()->begin(); it != world->GetSoldiers()->end(); it++) { if((*it)->GetActive() == true) { rayDir = *m_pCamera->GetLookAt() - *m_pCamera->GetPos(); D3DXVec3Normalize(&rayDir, &rayDir); float32 detG = D3DXMatrixDeterminant((*it)->GetMatrixLocal()); D3DXMATRIX m_lInverse; D3DXMatrixInverse( &m_lInverse, &detG, (*it)->GetMatrixLocal()); D3DXVECTOR3 rayPos; D3DXVec3TransformCoord( &rayPos, &m_vPos, &m_lInverse); D3DXVec3TransformNormal( &rayDir , &rayDir, &m_lInverse); D3DXVec3Normalize(&rayDir, &rayDir); D3DXIntersect((LPD3DXBASEMESH)(*it)->GetMesh()->GetD3DMesh(), &rayPos , &rayDir, &hit, &faceIndex, &u, &v, &dist, &ppAllHits, &pCountOfHits); &rayPos , &rayDir, &hit, &faceIndex, &u, &v, &dist, &ppAllHits, &pCountOfHits); if(hit == true) { (*it)->SetActive(false); } } }