D3DXVECTOR3 get3dWorldCoordFrom2dPoint(float point2dX, float point2dY, float objectZCoord, D3DXMATRIX worldMatrix) { //Get the Viewport D3D10_VIEWPORT viewport; UINT numOfVP = 1; G_Direct3D->device->RSGetViewports(&numOfVP, &viewport); //First point of a ray D3DXVECTOR3 point3d; point3d.x = (float) point2dX; point3d.y = (float) point2dY; point3d.z = -100.0f; //Translate from 2d to 3d World D3DXVECTOR3 rayStart; D3DXVec3Unproject(&rayStart, &point3d, &viewport, &G_Direct3D->projectionMatrix, &G_Direct3D->viewMatrix, &worldMatrix); //Second point of a ray point3d.z = 100.0f; //Translate from 2d to 3d World D3DXVECTOR3 rayEnd; D3DXVec3Unproject(&rayEnd, &point3d, &viewport, &G_Direct3D->projectionMatrix, &G_Direct3D->viewMatrix, &worldMatrix); // --- And now ??? //I've copied this code from the web, but I really don't understand it float point3dX = ( ( 0.0f - rayStart.z ) * ( rayEnd.x - rayStart.x ) ) / ( rayEnd.z - rayStart.z ) + rayStart.x; float point3dY = ( ( 0.0f - rayStart.z ) * ( rayEnd.y - rayStart.y ) ) / ( rayEnd.z - rayStart.z ) + rayStart.y; float point3dZ = objectZCoord; return D3DXVECTOR3 (point3dX, point3dY, point3dZ); }As you can see, I don't exactly know how to get the 3D point from the ray. Perhaps I've to get the intersection between the ray and the plane, but I don't know the equation of the plane... I'm a bit confused, especially with the math beyond all that stuff. Could you please help me? Thank you. [Edited by - donlucacorleone on September 28, 2009 8:18:40 AM]