I am creating a 2.5D game with the camera at a slight angle, like so:
The grid is the "playing field," and the positive x, y, and z directions are labelled.
I already know all the details about where the camera is, where the point on the grid that corresponds to the center of the screen is, and what the angle between the positive z axis and the direction the camera is pointing is.
What I want to do is be able to click on the screen, and figure out where on the grid I clicked. There are two ways that I have considered approaching this problem:
I could create a vector or ray of some sort that starts at the camera and goes in the direction the mouse is pointing. I could then solve the equation for the ray for
xandyatz = 0. The problem with this is I don't know how computationally expensive it would be.I could figure out the transformation matrix for something (I'm not sure exactly what it would have to be), then apply it to the
[x y]position of the mouse. The problem with this is I have no idea where to start when finding the necessary transformation matrix.
Is one of these likely to be better than the other? Is there a different way that might be better? If I should use the transformation matrix option, how do I find that matrix?
