Original Post
the Problem tbat i am having is that sometime when i do a mouseclick on the mesh the intersection does not get register unless i click in the center of the screen, here is my code below.
bool IsHit(LPD3DXMESH mesh,LPDIRECT3DDEVICE9 device,D3DVIEWPORT9 v)
{
D3DXVECTOR3 RayPos;
D3DXVECTOR3 RayDir;
POINT Mouse;
GetCursorPos(&Mouse);
D3DXMATRIX Projection;
D3DXMATRIX View;
D3DXMATRIX World;
D3DXMATRIX Local;
D3DXVECTOR3 m;
BOOL hit=FALSE;
device->GetTransform(D3DTS_PROJECTION,&Projection);
device->GetTransform(D3DTS_VIEW,&View);
device->GetTransform(D3DTS_WORLD,&World);
D3DXMATRIX NView=World*View;
D3DXMatrixInverse(&Local,0,&NView);
m.x=(((2*Mouse.x)/v.Width)-1)/Projection._11;
m.y=-(((2*Mouse.y)/v.Height)-1)/Projection._22;
m.z=1.0f;
RayDir.x=(m.x*Local._11)+(m.y*Local._21)+(m.z*Local._31);
RayDir.y=(m.x*Local._12)+(m.y*Local._22)+(m.z*Local._32);
RayDir.z=(m.x*Local._13)+(m.y*Local._23)+(m.z*Local._33);
RayPos.x=Local._41;
RayPos.y=Local._42;
RayPos.z=Local._43;
D3DXIntersect(mesh,&RayPos,&RayDir,&hit,0,0,0,0,0);
return hit;
}