Hello, in the past few days i've been trying to implement Mouse Picking on my 3D game, however i am getting some strange results. Below is the code i am using. If anyone know any algorithm which works or can help me figure out why this doesnt work i will appreciate it very much.
Vector4 world = new Vector4( (2 * mouse.X) / viewport.Width -1, -(2 * mouse.Y) / viewport.Height -1, -1, 1
Matrix4 invProj = Matrix4.Invert(proj);
Vector4 eye = Vector4.Transform(world, invProj);
world = new Vector4(eye.X, eye.Y, -1, 1);
Matrix4 invView = Matrix4.Invert(view);
Vector4 invVec = Vector4.Transform(world, invView);
Vector3 raydirection = new Vector3(invVec.X, invVec.Y, invVec.Z).Normalized();