I'm trying to do some ray intersection detection but I'm having some problems.
My app starts by loading a cube object into a .x file.
I have a player class and a target class that both use the same model, but each has it's own world matrix.
D3DXMATRIX shotOrigin = m_vecShots[i]->World; D3DXVECTOR3 rayOrigin(shotOrigin._41, 0, shotOrigin._43); CMatrixModifier::TranslateZ(shotOrigin, 1.0f, false); D3DXVECTOR3 rayDirection(shotOrigin._41, 0, shotOrigin._43); D3DXMATRIX Inv; D3DXMatrixIdentity(&Inv); D3DXMatrixInverse(&Inv, NULL, CApplication::GetInstance()->m_pTest->GetMatrix()); // Inverse of the world matrix of the target (object I want to detect collision with) D3DXVec3TransformCoord(&rayOrigin, &rayOrigin, &Inv); D3DXVec3TransformNormal(&rayDirection, &rayDirection, &Inv); D3DXIntersect(m_pXManager->GetModel(0)->GetMesh(), &rayOrigin, &rayDirection, &bHit, NULL, NULL, NULL, NULL, NULL, NULL);
It's odd because it'll detect the collision when the two cubes are sitting on top of each other but as soon as the center of the PLAYER cube leaves the TARGET cube mesh, it no longer detects the collisions.
I think I'm doing something wrong when I convert the ray into model space, but I'm not sure.
Edited 6 Years Ago by HealBrains: n/a