View Single Post
07/03/20, 10:25 AM   #1
Shinni
AddOn Author - Click to view addons
Join Date: Mar 2014
Posts: 167
[open] WorldPositionToMapPosition

I would like to request the following API function:
WorldPositionToMapPosition(zoneId, worldX, worldY, worldZ)
- normalizedX, normalizedY

It takes 3d world coordinates and converts them to 2d map coordinates with respect to the current map.
For example WorldPositionToMapPosition(GetUnitWorldPosition(unitTag)) should behave just like GetMapPlayerPosition(unitTag).

So far, addons can only convert from 3d world to 2d map coordinates via
a) Use SetPlayerWaypointByWorldLocation(worldX, worldY, worldZ), then read the map location of the waypoint.
This is very slow and has a bunch of side effects because of all the callbacks/events it triggers. Also this approach only works for the currently visited zone.
b) Use SetPlayerWaypointByWorldLocation to "measure" the zone, i.e. figure out a linear transformation (scaling + translation) that converts between 3d world and 2d map coordinates. Then use the linear transformation for all to be converted points. This approach is used in the libraries libGPS and lib3D.
The problem with this is that it doesn't work in zones like Blackreach and Imperial City, because there the conversion is not linear. Also both libraries must measure a zone before conversion is possible, so the player must have visited it before.


PS:
For completeness sake it would also be nice to have the reverse function (i.e. MapPositionToWorldPosition), but from my understanding that might not be implementable.
Personally, just being able to reliably convert from 3d to 2d would already cover all my use cases.

Last edited by Shinni : 07/14/20 at 12:09 PM.
  Reply With Quote