Original Post
I''m working on a shoot ''em up game where you control a tank. I would like to have the tank''s turret rotated so that it always faces in the direction of a mouse cursor. The tank is drawn from a top-down view with perspective projection, and the mouse cursor is just a textured poly rendered in ortho mode afterwards.
I have it all worked out in theory: Use gluProject to get the screen coords of the center of the tank, and then calculate the necessary angle of rotation using arctan from the screen coords of the 2 objects (tank and crosshair). But when I coded it I found that it doesn''t work as I expected. (Sorry for not explaining what happens exactly. I can post more details when I get home from work)
I''m not sure I fully understand what gluProject is doing (I have searched the forums but couldn''t find what I''m looking for), so here are a couple of questions that might help me if they were answered:
1) Ortho mode for the mouse cursor is set up to be the same size as the screen resolution (1024x768 in this case). So does that mean the final screen coords will be in the range (0,0) to (1024,768)? i.e. Can I just take the cursor''s coords at render time and use them in the arctan calculation, or do I have to gluProject those too?
2) Similar question for the tank - What will the range of the screen coords be after gluProject? (0,0) for the top left corner to (1024,768) in the bottom right?
Thanks for any help. I can post some code/screenshots when I get home from work if that would help to explain what I''m trying to do.
