|
|
@ -315,79 +315,6 @@ public class HeightMap { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static float getOutsetHeight(float interpolatedAltitude, Zone zone, Vector3fImmutable worldLocation) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vector2f parentLoc; |
|
|
|
|
|
|
|
float outsetALt = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (zone.getParent() == null || zone.getParent().getHeightMap() == null) |
|
|
|
|
|
|
|
return interpolatedAltitude + zone.getWorldAltitude(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (zone.getParent() != null && zone.getParent().getHeightMap() != null) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parentLoc = ZoneManager.worldToZoneSpace(worldLocation, zone.getParent()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Vector3fImmutable localLocFromCenter = ZoneManager.worldToLocal(worldLocation, zone); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float parentXRadius = zone.getBounds().getHalfExtents().x; |
|
|
|
|
|
|
|
float parentZRadius = zone.getBounds().getHalfExtents().y; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float bucketScaleX = zone.getHeightMap().outsetX / parentXRadius; |
|
|
|
|
|
|
|
float bucketScaleZ = zone.getHeightMap().outsetZ / parentZRadius; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float outsideGridSizeX = 1 - bucketScaleX; //32/256
|
|
|
|
|
|
|
|
float outsideGridSizeZ = 1 - bucketScaleZ; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float weight; |
|
|
|
|
|
|
|
double scale; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float offsetX = Math.abs((localLocFromCenter.x / parentXRadius)); |
|
|
|
|
|
|
|
float offsetZ = Math.abs((localLocFromCenter.z / parentZRadius)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (offsetX > outsideGridSizeX && offsetX > offsetZ) { |
|
|
|
|
|
|
|
weight = (offsetX - outsideGridSizeX) / bucketScaleX; |
|
|
|
|
|
|
|
scale = Math.atan2((.5 - weight) * 3.1415927, 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float scaleChild = (float) ((scale + 1) * .5); |
|
|
|
|
|
|
|
float scaleParent = 1 - scaleChild; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float parentAltitude = zone.getParent().getHeightMap().getInterpolatedTerrainHeight(parentLoc); |
|
|
|
|
|
|
|
float parentCenterAltitude = zone.getParent().getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(zone.getLoc(), zone.getParent())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parentCenterAltitude += zone.getYCoord(); |
|
|
|
|
|
|
|
parentCenterAltitude += interpolatedAltitude; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float firstScale = parentAltitude * scaleParent; |
|
|
|
|
|
|
|
float secondScale = parentCenterAltitude * scaleChild; |
|
|
|
|
|
|
|
outsetALt = firstScale + secondScale; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outsetALt += zone.getParent().getAbsY(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else if (offsetZ > outsideGridSizeZ) { |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
weight = (offsetZ - outsideGridSizeZ) / bucketScaleZ; |
|
|
|
|
|
|
|
scale = Math.atan2((.5 - weight) * 3.1415927, 1); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float scaleChild = (float) ((scale + 1) * .5); |
|
|
|
|
|
|
|
float scaleParent = 1 - scaleChild; |
|
|
|
|
|
|
|
float parentAltitude = zone.getParent().getHeightMap().getInterpolatedTerrainHeight(parentLoc); |
|
|
|
|
|
|
|
float parentCenterAltitude = zone.getHeightMap().getInterpolatedTerrainHeight(ZoneManager.worldToZoneSpace(zone.getLoc(), zone)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
parentCenterAltitude += zone.getYCoord(); |
|
|
|
|
|
|
|
parentCenterAltitude += interpolatedAltitude; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float firstScale = parentAltitude * scaleParent; |
|
|
|
|
|
|
|
float secondScale = parentCenterAltitude * scaleChild; |
|
|
|
|
|
|
|
outsetALt = firstScale + secondScale; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
outsetALt += zone.getParent().getAbsY(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return outsetALt; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static void loadAlHeightMaps() { |
|
|
|
public static void loadAlHeightMaps() { |
|
|
|
|
|
|
|
|
|
|
|
// Load the heightmaps into staging hashmap keyed by HashMapID
|
|
|
|
// Load the heightmaps into staging hashmap keyed by HashMapID
|
|
|
|