   Ok Picking again
  First of all I would just like to say, yes I have looked at the picking sample in the SDK but I really still don''t understand it. (So please no posts with, look at the sdk sample)Now to the problem. I think that I have managed to calculate a vector for the ray, but I''m having problems to figure what I should use as a starting point (At the moment I''m using the cameras position which seems to give me an incorrect ray).Here is what I did so far: POINT ptCursor;   GetCursorPos( &ptCursor );   ScreenToClient(cWindow.GethWnd(), &ptCursor );mouse=D3DXVECTOR3(ptCursor.x,ptCursor.y,1.0f);c3DGraphic.p3dDevice->GetViewport(&viewport);c3DGraphic.p3dDevice->GetTransform( D3DTS_PROJECTION, &projection );c3DGraphic.p3dDevice->GetTransform( D3DTS_VIEW, &matCurrentView );c3DGraphic.p3dDevice->GetTransform( D3DTS_WORLD, &matCurrentWorld);D3DXVec3Unproject(&Output,&mouse,&viewport,&projection,&matCurrentView,&matCurrentWorld);Output should now be my vector for the ray right?And then if I would draw a line to symblise this it would be from Camera position in direction of ray or? 
  Any one, please?;  Hi - I know you said don't talk about the pick sample, but if you look at the code in the pick sample: POINT ptCursor;   GetCursorPos( &ptCursor );   ScreenToClient( m_hWnd, &ptCursor );   // Compute the vector of the pick ray in screen space   D3DXVECTOR3 v;   v.x =  ( ( ( 2.0f * ptCursor.x ) / m_d3dsdBackBuffer.Width  ) - 1 ) / matProj._11;   v.y = -( ( ( 2.0f * ptCursor.y ) / m_d3dsdBackBuffer.Height ) - 1 ) / matProj._22;   v.z =  1.0f;   // Get the inverse view matrix   D3DXMATRIXA16 matView, m;   m_pd3dDevice->GetTransform( D3DTS_VIEW, &matView );   D3DXMatrixInverse( &m, NULL, &matView );   // Transform the screen space pick ray into 3D space   vPickRayDir.x  = v.x*m._11 + v.y*m._21 + v.z*m._31;   vPickRayDir.y  = v.x*m._12 + v.y*m._22 + v.z*m._32;   vPickRayDir.z  = v.x*m._13 + v.y*m._23 + v.z*m._33;   vPickRayOrig.x = m._41;   vPickRayOrig.y = m._42;   vPickRayOrig.z = m._43;  It determines the origin vector by calculating the inverse of the view matrix and using the 4_1, 4_2, and 4_3 members of this matrix: // Get the inverse view matrixD3DXMATRIXA16 matView, m;m_pd3dDevice->GetTransform( D3DTS_VIEW, &matView );D3DXMatrixInverse( &m, NULL, &matView );...vPickRayOrig.x = m._41;vPickRayOrig.y = m._42;vPickRayOrig.z = m._43;  And it determines the direction vector by doing the following calculations: // Compute the vector of the pick ray in screen space   D3DXVECTOR3 v;   v.x =  ( ( ( 2.0f * ptCursor.x ) / m_d3dsdBackBuffer.Width  ) - 1 ) / matProj._11;   v.y = -( ( ( 2.0f * ptCursor.y ) / m_d3dsdBackBuffer.Height ) - 1 ) / matProj._22;   v.z =  1.0f;...vPickRayDir.x  = v.x*m._11 + v.y*m._21 + v.z*m._31;vPickRayDir.y  = v.x*m._12 + v.y*m._22 + v.z*m._32;vPickRayDir.z  = v.x*m._13 + v.y*m._23 + v.z*m._33;  Have you tried implementing the above in your own code? It works very well for me.Maybe someone who is more adept at math can explain why this works in more detail...BM   [edited by - bmoberly on July 31, 2003 5:42:24 PM]