Ambiera Forum

Discussions, Help and Support.

Ambiera Forum > CopperLicht
2D worldmap radar

cylontis
Registered User
Quote
2015-09-09 23:18:33

Hi all,

can someone provide an algorithm for how to transform 3D player coordinates on a 2d Overlay to use as a radar? I lost with the math :-(

Thanks a lot


niko
Moderator
Quote
2015-09-10 05:07:38

I'd simply do it like that: You usually have coordinates like (120, 34,45) etc. The Y coordinate is height, so you just ignore that, and just use the X and Z coordinates for drawing. If you draw a 2D map, then simply for the example point (120, 34,45), draw a 2D point at (120, 45). No math needed, actually :)

If you want to change the scale a bit (= zoom) for the 2D map, just apply a zoom value. So for 50 zoom, draw it for example with these coordinates:

(120*0.5, 45*0.5). That's it. :)


cylontis
Registered User
Quote
2015-09-10 14:49:53

Hi Niko,

thank for your answer, the problem with the math was more ment in regards to the transformation of the 2D element boundaries.
At the moment I use simply a DIV as the map lets say 400x300px of size and a 5px span inside which will be the player.

When I do something like this:
App.player.elem.style.left = "" + Math.round(player.Pos.X) + "px";
App.player.elem.style.top = "" + Math.round(player.Pos.Z) + "px";

it surely works at first place, but without regards of the boundaries and dimensions of the wordmap DIV...


niko
Moderator
Quote
2015-09-12 06:44:03

Yes, you need to scale this probably, depending on how you made the map. Scaling is usually done by multiplying both values with a factor, for example 0.5 or similar.


Create reply:


Posted by: (you are not logged in)


Enter the missing letter in: "Intern?tional" (you are not logged in)


Text:

 

  

Possible Codes


Feature Code
Link [url] www.example.com [/url]
Bold [b]bold text[/b]
Image [img]http://www.example.com/image.jpg[/img]
Quote [quote]quoted text[/quote]
Code [code]source code[/code]

Emoticons


   






Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact