sirinsidiator / ESO-LibGPS

https://www.esoui.com/downloads/info601-LibGPS2.html
0 stars 3 forks source link

Add new measurements for world space #3

Closed sirinsidiator closed 4 years ago

sirinsidiator commented 4 years ago

Add a separate set of scale and offset for the world coordinate space. This should be useful for addons using 3d features and also in order to calculate distances in meters.

votan73 commented 4 years ago

I did that already. This should indeed be done after https://github.com/sirinsidiator/ESO-LibGPS/issues/2. Restoring the waypoint is unnecessary complicate otherwise. The pain is to keep the ping sound muted.

votan73 commented 4 years ago

Maybe one should work the other way round: Intercepting the PingMap function and identify pings done by user.

votan73 commented 4 years ago
-- p=player
-- w=waypoint
-- n=normalized
-- w=world

local _, pwx, _, pwy = GetUnitWorldPosition("player")
local pnx, pny = GetMapPlayerPosition("player")

local wwx, wwy = 2000000, 2000000
SetPlayerWaypointByWorldLocation(wwx, 1, wwy)
local wnx, wny = GetMapPlayerWaypoint()

local dwx, dwy = wwx-pwx, wwy-pwy
local dnx, dny = wnx-pnx, wny-pny
local scale = math.sqrt((dwx*dwx+dwy*dwy)/(dnx*dnx+dny*dny))
d("---", scale, math.sqrt((dwx*dwx)/(dnx*dnx)))
-- as the normalized width/height is 1, scale is also width/height in world-units

local wx2, wy2 = 0.15, 0.85
SetPlayerWaypointByWorldLocation((wx2-pnx)*scale+pwx, 1, (wy2-pny)*scale+pwy)
sirinsidiator commented 4 years ago

Will have to take a closer look at your code later.

Not sure intercepting the pings at set time would really make anything easier, since they are usually not passed as world coordinates, so converting them would still be necessary. Maybe we should try to get ZOS to add a new function GetMapPlayerWaypointWorldPosition? Another idea could be a separate new type of map ping which addons can use, which never shows up or makes a sound. That way it would all become quite simple.

As for measuring world coords, there are a few differences to measuring maps:

The first two points mean we could utilize it to simplify measuring maps by setting the waypoint to world coords 1/1/1, since that should always work regardless. It just means we have to calculate the map offset afterwards.

Third one requires us to store world measurements independently of maps, since there could be maps with multiple worlds (like the Tamriel map). The main question here is how we would know which world measurements we should use in a case there are multiple available on a map with overlapping bounds.

The last one implies we have to improve how our api notifies about failures, e.g. when an addon tries to get a world position in a zone that has not been measured yet. This could for example happen when trying to display a distance in meters on a map with a world the player hasn't visited yet.