Archived

This topic is now archived and is closed to further replies.

D3DXIntersect()

This topic is 5333 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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????????

Share this post


Link to post
Share on other sites