   My picking function not working
  I have this picking function that looks perfect to me but it won't work.  I have done this a while ago but i can't remember how to.  I let you have a remote access to my laptop.  anyway here is my codeBOOL Directx::Picking(HWND hWnd, AnimatedMesh *entity){    D3DXMATRIX matProj;    POINT pt;    D3DVIEWPORT9 vp;    D3DXMATRIX matWorld;    D3DXMATRIX matView;    GetCursorPos(&pt);    ScreenToClient(hWnd, &pt);    d3ddev->GetTransform(D3DTS_PROJECTION, &matProj);    d3ddev->GetViewport(&vp);    d3ddev->GetTransform(D3DTS_VIEW, &matView);s.x = pt.x;s.y = pt.y;matWorld = entity->objTransformation;    // Use inverse of matrix    D3DXVECTOR3 rayPos((float)pt.x, (float)pt.y,0); // near-plane position    D3DXVECTOR3 rayDir((float)pt.x, (float)pt.y,1); // far-plane position D3DXVec3Unproject(&rayPos,&rayPos,&vp,&matProj,&matView,&matWorld);    D3DXVec3Unproject(&rayDir,&rayDir,&vp,&matProj,&matView,&matWorld);    rayDir -= rayPos; // make a direction from the 2 positions    D3DXVec3Normalize(&rayDir,&rayDir);Program::mesh->FillInTransformation(0, 0, 0, 0, 0, 0, rayPos.x, rayPos.y, 1, true, false, false);float distanceToCollision;BOOL hasHit = 0;if(FAILED(D3DXIntersect(entity->pDrawMesh, &rayPos, &rayDir, &hasHit, NULL, NULL, NULL, &distanceToCollision, NULL, NULL)))    {PostQuitMessage(0);    };return hasHit;}PM me if you want to do remote access.   