Skip to main content
GameDev.net gamedev.net
🔒 Locked

D3DXIntersect()

Started by Tamer_Malas May 7, 2003 at 4:44 AM 0 replies 300+ views
Original Post
Tamer_Malas
Tamer_Malas
In the dx9 there is a new function called D3DXIntersect() that gives you the array of faces that been passed by a line. This function works when the world is identity and the mesh too but what if we have a matrix for the mesh MeshMat and we need it to be intersected with a line???? i have tried a code but didnt work,see this: void Intersect_Triangle(LPD3DXMESH mesh,D3DXMATRIX MeshMat,D3DXVECTOR3 Orig,D3DXVECTOR3 Dir,unsigned int *face); { D3DXMATRIX invmat; D3DXVECTOR3 neworig,newdir; D3DXMatrixInverse(&invmat,&MeshMat); // compute the new locations for the line neworig.x=invmat._11*Orig.x+invmat._12*Orig.y+invmat._13*Orig.z+mat._41; neworig.y=invmat._21*Orig.x+invmat._22*Orig.y+invmat._23*Orig.z+mat._42; neworig.z=invmat._31*Orig.x+invmat._32*Orig.y+invmat._33*Orig.z+mat._43; newdir.x=invmat._11*Dir.x+invmat._12*Dir.y+invmat._13*Dir.z+mat._41; newdir.y=invmat._21*Dir.x+invmat._22*Dir.y+invmat._23*Dir.z+mat._42; newdir.z=invmat._31*Dir.x+invmat._32*Dir.y+invmat._33*Dir.z+mat._43; // Then Call the function D3DXIntersect() D3DXIntersect(mesh,neworig,newdir,...........); } And it returns wholy diffrent face????????
Tmm

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.