Skip to main content
gamedev.net
🔒 Locked

Radar

Started by middy Nov 3, 2004 at 3:57 PM 3 replies 900+ views
Original Post
middy
middy
OK I am trying to get soem thoughts confirmed here. So I hope you can speed me away. Perhaps its a math question, so sorry if its wrong forum (I am using OpenGl though) I am doing a radar, wich is basicly a 2D circle with small red dots in it. My radar have a range and recives a message when an object passes into that range. My problem is to render it in a scale. I draw a circle in origo, with a radious of say 5. I want to draw a red dot somewhere within that circle, that corresponds to the relative distance from the object with the radar and to the blib. How do I calculate this?
grekster
grekster
Something like (distance to object/radius of radar) multiplied by radius of on screen radar.

So if your radar cover 300 world units, and an object was 150 units away you would do 150/300 = 1/2. You then multiply that by the radius of you on screen radar (say 5) which will give you 2.5

I hope thats helpful (and I hope ive understood your question) :)
Quote: Original post by BosskIn Soviet Russia, you STFU WITH THOSE LAME JOKES!
hplus0603
hplus0603
Even easier. Just get the position in world space, then do something like:

glTranslatefv( &radarCenterScreenPos.x );float s = VISIBLE_RANGE/RADAR_UNITS;glScalef( s, s, s );glRotatef( myUp.x, myUp.y, myUp.z, -myFacing );glTranslatef( -myPos.x, -myPos.y, -myPos.z );for( int i = 0; i < numObjects; ++i ) {  if( distance( object.pos, myPos ) < VISIBLE_RANGE ) {    renderPointAt( object.pos );  }}


You probably want to make sure you have an ortho projection that flattens everything to your UI plane first, though :-)
enum Bool { True, False, FileNotFound };
middy
middy
thankyou both of you. :-)
middy
middy
quick question RADAR_UNITS would be size of screen radar in world units right?

Topic Locked

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

Sign in to reply to this topic.