PDA

View Full Version : Fixing a 3D object in relation to the camera



Simo00
08-21-2009, 04:57 PM
Basically i have my 3D game world and a 3D compass model (which rotates as you move the game world around, and therefore allowing you to always know which direction you are facing).

The problem is i need to 'attach' this 3D compass to my screen so it is always in the corner of the viewport, regardless of where you point the camera. Something similar to drawing my menus in 2D/ortho mode would be nice. Or am i going to have to use some complicated maths?

Thanks in advance :)

todayman
08-22-2009, 08:44 AM
I would use similar techniques to drawing menus. Essentially, (I'm in GL2), setup your projection and modelview matricies to draw the compass, then set them up to draw the scene. This way, there is no connection between the compass and the camera, but if you get your transformations correct, it will be in the corner of the screen.

Simo00
08-22-2009, 02:59 PM
nice one, hadn't thought of anything like that :) i'll give it a go. Cheers