#### Archived

This topic is now archived and is closed to further replies.

# OpenGL OpenGL Compass

This topic is 5305 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

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...

##### Share on other sites
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 ).

##### Share on other sites
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..

##### Share on other sites
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
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.

1. 1
Rutin
23
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 29
• 40
• 23
• 13
• 13
• ### Forum Statistics

• Total Topics
631740
• Total Posts
3001959
×