   Picking emergency directx c++
  Hey, so i been trying to get my picking function but it won't work.  Just take a look at function and tell me what is wrong with because i can't tell what is wrong with itBOOL 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;d3ddev->GetTransform(D3DTS_WORLD, &matWorld);    // 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::mesh1->FillInTransformation(0, 0, 0, 0, 0, 0, rayDir.x, rayDir.y, Program::z, true, false, false);float distanceToCollision;BOOL hasHit = 0;if(FAILED(D3DXIntersect(entity->pDrawMesh, &rayPos, &rayDir, &hasHit, NULL, NULL, NULL, &distanceToCollision, NULL, NULL)))    {PostQuitMessage(0);    };if(hasHit!=0)PostQuitMessage(0);return hasHit;}
  As mentioned in this thread, you can't use that method to pick an animated mesh.If you're picking a static mesh, you need to use the world matrix for the object you're trying to pick. That was also discussed in that other thread. If FillInTransformation does anything significant, you need to describe what it does.   ;  I used that function to help me draw my ray,  When I drawed my ray i noticed that my ray doesn't follow my cursor(mouse). it draws the ray close to the orgin   ;  Your ray will be drawn as it is transformed by the current device world matrix - the last value that you set that value to. If it is drawn close to the origin, then that world matrix is probably close to an identity matrix.