• Advertisement
Sign in to follow this  

Making A Radar

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

For the life of me I can't figure out how to create a radar for a flight sim type game. Plotting objects based on distance is no big deal. The problem is when the view rotates around the blips stay in the same place. I imagine its something with the view matrix but I have no idea what.

Share this post


Link to post
Share on other sites
Advertisement
If I have understood your problem correctly then all you have to do is rotate the blip's position from the center by the same angle that the view is rotated (hope that makes sense). 2D vector rotation looks like this:

x2 = x1*cos(angle) + y1*sin(angle);
y2 = y1*cos(angle) - x1*sin(angle);

Share this post


Link to post
Share on other sites
Just calculate the position of the various objects relative to the object that radar is centred around in that object's space (if you camera is located in the front of the plane that the radar is centred around you can do this in view space). Project them on to a 2D plane (e.g. by dropping the z coordinate) and plot on your radar screen.

[edit]This assumes you want a head-up radar display, i.e. one where the stuff on the screen directly above the centre is directly in front of the place, if you want something else, so when you rotate your plane the entire display rotates around the centre. If you want the display to stay fixed when you rotate (in which case you'll want a line giving the current heading on the display) just do what I said above, but do it in world space.

Share this post


Link to post
Share on other sites
Yeah, I was taking the distance between two objects and then rotating it by the right, up, and forward vectors of the camera (player view). The problem was instead of adding all the pieces together I had a typo and was multiplying some of the parts together.

Instead of doing this:
pos.y = (temp.x*cam.uvec.x)+(temp.y*cam.uvec.y)+(temp.z*cam.uvec.z);

I was doing this:
pos.y = (temp.x*cam.uvec.x)+(temp.y*cam.uvec.y)*(temp.z*cam.uvec.z);

Spend hours messing with it and it was a simple error.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement