mirror of
https://github.com/xivapi/ffxiv-datamining.git
synced 2026-07-24 10:59:11 +00:00
More accurate and simplified coordinate conversions.
This commit is contained in:
committed by
GitHub
parent
bc1a1de27e
commit
f17bb15883
+16
-41
@@ -1,57 +1,32 @@
|
||||
# Conversions to 2D Map
|
||||
|
||||
|
||||
### Version of an in-game coordinate to a 2D map coordinate
|
||||
|
||||
**By: Clorifex, slightly modified by: Vekien - In C#**
|
||||
https://github.com/xivapi/xivapi-mappy/blob/master/Mappy/Helpers/MapHelper.cs
|
||||
### Conversion of world coordinates to a 2D map texture coordinate (in pixels):
|
||||
|
||||
```csharp
|
||||
public static double ConvertCoordinatesIntoMapPosition(double scale, double offset, double val)
|
||||
public static Vector2 GetPixelCoordinates( Vector2 worldXZCoordinates, Vector2 mapOffset, UInt16 mapSizeFactor )
|
||||
{
|
||||
val = Math.Round(val, 3);
|
||||
val = (val + offset) * scale;
|
||||
return ((41.0 / scale) * ((val + 1024.0) / 2048.0)) + 1;
|
||||
return ( worldXZCoordinates + mapOffset ) / 100f * mapSizeFactor + new Vector2( 1024f );
|
||||
}
|
||||
```
|
||||
This assumes using the normal map textures that are 2048x2048. If you're using the small (1024x1024) map textures, divide the result by two.
|
||||
|
||||
### Conversion of a Level coordinate into a 2D map coordinate:
|
||||
|
||||
**By: Clorifex - In C#**
|
||||
|
||||
### Conversion of map texture pixel coordinates (such as FishingSpot coordinates) to in-game 2D map coordinates:
|
||||
```csharp
|
||||
private double ToMapCoordinate(double val) {
|
||||
var c = Map.SizeFactor / 100.0;
|
||||
|
||||
val *= c;
|
||||
return ((41.0 / c) * ((val + 1024.0) / 2048.0)) + 1;
|
||||
}
|
||||
```
|
||||
|
||||
### Conversion of a FishingSpot coordinate into a 2D map coordinate:
|
||||
|
||||
**By: Clorifex - In C#**
|
||||
|
||||
```csharp
|
||||
private double ToMapCoordinate(double val) {
|
||||
var c = TerritoryType.Map.SizeFactor / 100.0;
|
||||
|
||||
return (41.0 / c) * ((val) / 2048.0) + 1;
|
||||
}
|
||||
```
|
||||
|
||||
### Conversion of MapPosition to Pixels
|
||||
|
||||
**By: Vekien - In C#**
|
||||
https://github.com/xivapi/xivapi-mappy/blob/master/Mappy/Helpers/MapHelper.cs
|
||||
|
||||
```csharp
|
||||
public static int ConvertMapPositionToPixels(double value, double scale)
|
||||
public static Vector2 GetGameMapCoordinates( Vector2 mapPixelCoordinates, UInt16 mapSizeFactor )
|
||||
{
|
||||
return Convert.ToInt32((value - 1) * 50 * scale);
|
||||
return mapPixelCoordinates / mapSizeFactor * 2f + Vector2.One;
|
||||
}
|
||||
```
|
||||
|
||||
### Conversion of world coordinates to in-game 2D map coordinates (using the above functions):
|
||||
```csharp
|
||||
public static Vector2 WorldToMapCoordinates( Vector2 worldXZCoordinates, Vector2 mapOffset, UInt16 mapSizeFactor )
|
||||
{
|
||||
return GetGameMapCoordinates( GetPixelCoordinates( worldXZCoordinates, mapOffset, mapSizeFactor ), mapSizeFactor );
|
||||
}
|
||||
```
|
||||
The game *truncates* the result of this to the first decimal place.
|
||||
|
||||
----
|
||||
|
||||
To translate a `levels.exd` position to an in-game X/Y:
|
||||
|
||||
Reference in New Issue
Block a user