Skip to main content
gamedev.net
🔒 Locked

OpenGL Compass

Started by OpenGL_Guru Jan 7, 2004 at 8:43 AM 2 replies 3.3k views
Original Post
OpenGL_Guru
OpenGL_Guru
i now have my terrain rendered out and have some ideas about making a compass, starting by facing North.. there are many ideas out there on how to do this by googling.. was just wanting to know your opinion on maybe the best way to do this and at the same time making it look good..thanks...
heh
_walrus
_walrus
maybe you could use the look vector of your avatar (that is holding the compas) and define a north vector (maybe {0,0,-1} or something) and then use the angle between these to vectors to compute the value on the compas (I dont know how compas'' work... cuz i faild scouts ).
OpenGL_Guru
OpenGL_Guru
well i was thinking of just making a 3-D compass, 4 ends, one with N, E, S, W. then as you turn in the 3d world, the compass turns accordingly.. i am trying to possibly get this to make it easier for me to compute the lat,lon that i am at. how do you do this btw? this is not trivial..
heh
bzroom
bzroom
Asuming your using 2 vertices for your camera, a from and a to point. Find the angle on your horizontal plane (XZ?) to a given point (0,1 XZ). Rotate your compass model the opposite angle.


Clear
LoadIdentity
Translate(compass position);
Rotate(0,1,0, - atan2(lookfat.x - lookfrom.x, lookat.z - lookfrom.z))
DrawCompass
SetCamera(lookfrom, lookat)
Draw rest of world


Looks good in words too me.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.