Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
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 |
||||
|
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. :) |
||||
|
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... |
||||
|
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. |
|