This is a follow-up to my earlier question:
Game Editor - When screen is clicked, how do you identify which object that is clicked?
Something I've noticed is that picking only calculates a ray and checks for the closest objects that intersects it, but since this method isn't working for placing object in a 3D World what are the best way of doing that? A ray is just a line that goes from one point in a certain direction, it checks the first object that intersects it that is closest. But not if you don't have any objects.
I've used one method for calculating a position with an Isometric Camera, but currently I have an arc ball camera and it doesn't produce the same results. Is there a general way that actually produces a good coordinate?
This is currently the method I'm trying to understand, but I've found no tutorials/information on how to actually translate numbers between 0 and 1 to real coordinates on the screen.
3D Arc Ball Camera with this method:
public static Vector3 GetScreenCoordinates(MouseState Mouse, Viewport viewport, Matrix Projection, Matrix View, Matrix World)
{
Vector3 pos1 = viewport.Unproject(new Vector3(Mouse.X, Mouse.Y, 0), Projection, View, World);
Vector3 pos2 = viewport.Unproject(new Vector3(Mouse.X, Mouse.Y, 1), Projection, View, World);
Vector3 dir = Vector3.Normalize(pos2 - pos1);
dir.Normalize();
return dir;
}
Mouse.X/Mouse.Y), View Coordinates (3d from the viewer's location), or World Coordinates. – Shotgun Ninja Mar 18 at 18:08Mouse.XandMouse.Yand apply the correct transformations. – Shotgun Ninja Mar 18 at 18:14