Calculating In-Game map positions

Started by
2 comments, last by BauerGL 11 years, 4 months ago
Hello everyone,

I have an issue. I'm not going to send what I have because it's extremely hard to understand and most likely horribly written because of my lack of knowledge on this subject. So lets just start from a simple approach, if I want to take a game object and put its position on a world map or mini map how would I take that 3D position and convert it to a 2D position that can be used to position the map marker?

Thanks to anyone who can help me!
Advertisement
One of the approaches is to make two more render passes for your scene. The first new one would render to texture everything from the camera which is located in the sky. In the second new render pass you render this texture to the place on the screen you want.
Thanks DgekGD, I'll try that out. It actually sounds like a really good way of doing it. If anyone else has any suggestions on this, please let me know.
If you already have a top-down overview image of your map, you could just convert your object's position into "minimap coords".

To convert between real coordinates and minimap coordinates:
normalized_coordinate = object_position / map_bounds
minimap_coordinate = normalized_coordinate * minimap_bounds

For example:
Real map is 100 units X and 100 units Y
Minimap is 256 pixels wide and 256 pixels high
Object is positioned at 50,50 (center of map)

50 / 100 = 0.5 so the normalized object position would be 0.5, 0.5
0.5 * 256 = 128 so the unit should be positioned at pixel 128,128 in the minimap

Hope that makes sense, this was written while eating a donut :)

Cheers

@mikaelbauer

Super Sportmatchen - A retro multiplayer competitive sports game project!

This topic is closed to new replies.

Advertisement