I am trying to make the transition from 2D to 3D and I am having some issues with figuring certain things out. I have read through almost all of the programming guide on the OpenGL homepage. I am able to draw in 3D, but I can’t interact with 3D.
You can see what I mean at http://portfolio.eckish.net/010_3D_Conversion/load.jnlp. I basically took my 2D game map and rotated it around to something similar to isometric. Everything interacts with each other correctly, because nothing has changed as far as game mechanics go. The world has no real height and is still 2D in that sense. If you try clicking to move around, you will see my first obstacle. I need to translate the x and y I get from a mouse click to an x and y that corresponds to my 2D map that is flipped around.
My first thought is to approximate the line that would be generated if I shot a beam straight out from where my mouse cursor is. And then calculate where this beam intersects with the plane that rests along the x and y axis. Since I have no height, the z point of intersection would be 0, so I think it should be fairly easy to calculate. However, I can’t seem to figure out how to calculate that interesection. I googled line and plane intersection calculations and came up with a few pages that describe the process. However, they use equations for 3D lines and planes that use variables I don’t recognize. And to make it worse, they don’t explain the variables.
I am pretty strong in math. I got A’s in both Calc 1 and Calc 2. However, almost everything we did in those classes used 2 variables. What I am looking for is a book/guide that will assume I’m a 3D newb (because I am) and teach me 3D geometry. If anyone knows of a guide that describes the solution to my particular problem in detail, that would be helpful too. However, I think the former would better for me in the long run.
Thanks,
Dave