|
|
@ -199,28 +199,31 @@ public class HeightMap { |
|
|
|
|
|
|
|
|
|
|
|
public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) { |
|
|
|
public static float getWorldHeight(Zone currentZone, Vector3fImmutable worldLoc) { |
|
|
|
|
|
|
|
|
|
|
|
if (currentZone == null) |
|
|
|
Zone heightMapZone; |
|
|
|
return 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
currentZone = getNextZoneWithTerrain(currentZone); |
|
|
|
// Seafloor is rather flat.
|
|
|
|
|
|
|
|
|
|
|
|
if (currentZone == ZoneManager.getSeaFloor()) |
|
|
|
if (currentZone == ZoneManager.getSeaFloor()) |
|
|
|
return currentZone.getAbsY(); |
|
|
|
return currentZone.worldAltitude; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// Retrieve the next zone with a heightmap attached.
|
|
|
|
|
|
|
|
// Zones without a heightmap use the next zone up the
|
|
|
|
|
|
|
|
// tree to calculate heights from.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
heightMapZone = getNextZoneWithTerrain(currentZone); |
|
|
|
|
|
|
|
|
|
|
|
HeightMap heightMap = currentZone.getHeightMap(); |
|
|
|
// Transform world loc into zone space coordinate system
|
|
|
|
|
|
|
|
|
|
|
|
if ((heightMap == null) || (currentZone == ZoneManager.getSeaFloor())) |
|
|
|
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(worldLoc, heightMapZone); |
|
|
|
return currentZone.getAbsY(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vector2f zoneLoc = ZoneManager.worldToZoneSpace(worldLoc, currentZone); |
|
|
|
// Interpolate height for this position using pixel array.
|
|
|
|
|
|
|
|
|
|
|
|
float interaltitude = currentZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); |
|
|
|
float interpolatedTerrainHeight = heightMapZone.getHeightMap().getInterpolatedTerrainHeight(zoneLoc); |
|
|
|
|
|
|
|
|
|
|
|
float worldAltitude = currentZone.worldAltitude; |
|
|
|
// Position returned from Heightmap engine is relative to zone world height
|
|
|
|
|
|
|
|
|
|
|
|
float realWorldAltitude = interaltitude + worldAltitude; |
|
|
|
return interpolatedTerrainHeight + heightMapZone.worldAltitude; |
|
|
|
|
|
|
|
|
|
|
|
return realWorldAltitude; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static float getWorldHeight(Vector3fImmutable worldLoc) { |
|
|
|
public static float getWorldHeight(Vector3fImmutable worldLoc) { |
|
|
|