H. Williams
2005-08-12 23:34:25 UTC
How do you convert mouse XY coordinates to world space?
I tried the following code (passing the mouse coordinates to x & y and
setting z to 0):
Vector3 v = new Vector3(x,y,z);
device.Transform.World =Matrix.Translation(0f,0f,0f);
v.Unproject(device.Viewport, device.Transform.Projection,
device.Transform.View, device.Transform.World);
Unfortunately v.X & v.Y only correspond correctly at the screen center.
thanks.
I tried the following code (passing the mouse coordinates to x & y and
setting z to 0):
Vector3 v = new Vector3(x,y,z);
device.Transform.World =Matrix.Translation(0f,0f,0f);
v.Unproject(device.Viewport, device.Transform.Projection,
device.Transform.View, device.Transform.World);
Unfortunately v.X & v.Y only correspond correctly at the screen center.
thanks.