|
|
@ -30,17 +30,17 @@ import java.sql.SQLException; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.stream.Stream; |
|
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
|
|
|
|
public class HeightMap { |
|
|
|
public class Terrain { |
|
|
|
|
|
|
|
|
|
|
|
// Class variables
|
|
|
|
// Class variables
|
|
|
|
|
|
|
|
|
|
|
|
public static final HashMap<Integer, HeightMap> heightmapByLoadNum = new HashMap<>(); |
|
|
|
public static final HashMap<Integer, Terrain> heightmapByLoadNum = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
public static final HashMap<Integer, short[][]> _pixelData = new HashMap<>(); |
|
|
|
public static final HashMap<Integer, short[][]> _pixelData = new HashMap<>(); |
|
|
|
|
|
|
|
|
|
|
|
// Bootstrap Tracking
|
|
|
|
// Bootstrap Tracking
|
|
|
|
public static int heightMapsCreated = 0; |
|
|
|
public static int heightMapsCreated = 0; |
|
|
|
public static HeightMap PlayerCityHeightMap; |
|
|
|
public static Terrain playerCityTerrain; |
|
|
|
|
|
|
|
|
|
|
|
// Heightmap data for this heightmap
|
|
|
|
// Heightmap data for this heightmap
|
|
|
|
public final int heightMapID; |
|
|
|
public final int heightMapID; |
|
|
@ -60,7 +60,7 @@ public class HeightMap { |
|
|
|
|
|
|
|
|
|
|
|
public float terrain_scale; |
|
|
|
public float terrain_scale; |
|
|
|
|
|
|
|
|
|
|
|
public HeightMap(ResultSet rs) throws SQLException { |
|
|
|
public Terrain(ResultSet rs) throws SQLException { |
|
|
|
|
|
|
|
|
|
|
|
this.heightMapID = rs.getInt("heightMapID"); |
|
|
|
this.heightMapID = rs.getInt("heightMapID"); |
|
|
|
this.maxHeight = rs.getInt("maxHeight"); |
|
|
|
this.maxHeight = rs.getInt("maxHeight"); |
|
|
@ -107,13 +107,13 @@ public class HeightMap { |
|
|
|
|
|
|
|
|
|
|
|
generatePixelData(this); |
|
|
|
generatePixelData(this); |
|
|
|
|
|
|
|
|
|
|
|
HeightMap.heightmapByLoadNum.put(this.zoneLoadID, this); |
|
|
|
Terrain.heightmapByLoadNum.put(this.zoneLoadID, this); |
|
|
|
|
|
|
|
|
|
|
|
heightMapsCreated++; |
|
|
|
heightMapsCreated++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
//Created for PlayerCities
|
|
|
|
//Created for PlayerCities
|
|
|
|
public HeightMap() { |
|
|
|
public Terrain() { |
|
|
|
|
|
|
|
|
|
|
|
this.heightMapID = 999999; |
|
|
|
this.heightMapID = 999999; |
|
|
|
this.maxHeight = 5; // for real...
|
|
|
|
this.maxHeight = 5; // for real...
|
|
|
@ -149,7 +149,7 @@ public class HeightMap { |
|
|
|
this.terrain_scale = this.maxHeight / 255f; |
|
|
|
this.terrain_scale = this.maxHeight / 255f; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public HeightMap(Zone zone) { |
|
|
|
public Terrain(Zone zone) { |
|
|
|
|
|
|
|
|
|
|
|
this.heightMapID = 999999; |
|
|
|
this.heightMapID = 999999; |
|
|
|
this.maxHeight = 0; |
|
|
|
this.maxHeight = 0; |
|
|
@ -185,15 +185,15 @@ public class HeightMap { |
|
|
|
|
|
|
|
|
|
|
|
public static void GeneratePlayerCityHeightMap() { |
|
|
|
public static void GeneratePlayerCityHeightMap() { |
|
|
|
|
|
|
|
|
|
|
|
HeightMap.PlayerCityHeightMap = new HeightMap(); |
|
|
|
Terrain.playerCityTerrain = new Terrain(); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public static void GenerateCustomHeightMap(Zone zone) { |
|
|
|
public static void GenerateCustomHeightMap(Zone zone) { |
|
|
|
|
|
|
|
|
|
|
|
HeightMap heightMap = new HeightMap(zone); |
|
|
|
Terrain heightMap = new Terrain(zone); |
|
|
|
|
|
|
|
|
|
|
|
HeightMap.heightmapByLoadNum.put(zone.template, heightMap); |
|
|
|
Terrain.heightmapByLoadNum.put(zone.template, heightMap); |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -260,9 +260,9 @@ public class HeightMap { |
|
|
|
|
|
|
|
|
|
|
|
//generate static player city heightmap.
|
|
|
|
//generate static player city heightmap.
|
|
|
|
|
|
|
|
|
|
|
|
HeightMap.GeneratePlayerCityHeightMap(); |
|
|
|
Terrain.GeneratePlayerCityHeightMap(); |
|
|
|
|
|
|
|
|
|
|
|
Logger.info(HeightMap.heightmapByLoadNum.size() + " Heightmaps cached."); |
|
|
|
Logger.info(Terrain.heightmapByLoadNum.size() + " Heightmaps cached."); |
|
|
|
|
|
|
|
|
|
|
|
// Load pixel data for heightmaps
|
|
|
|
// Load pixel data for heightmaps
|
|
|
|
|
|
|
|
|
|
|
@ -305,19 +305,19 @@ public class HeightMap { |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private static void generatePixelData(HeightMap heightMap) { |
|
|
|
private static void generatePixelData(Terrain terrain) { |
|
|
|
|
|
|
|
|
|
|
|
Color color; |
|
|
|
Color color; |
|
|
|
|
|
|
|
|
|
|
|
// Generate altitude lookup table for this heightmap
|
|
|
|
// Generate altitude lookup table for this heightmap
|
|
|
|
|
|
|
|
|
|
|
|
heightMap.pixelColorValues = new short[heightMap.heightmapImage.getWidth()][heightMap.heightmapImage.getHeight()]; |
|
|
|
terrain.pixelColorValues = new short[terrain.heightmapImage.getWidth()][terrain.heightmapImage.getHeight()]; |
|
|
|
|
|
|
|
|
|
|
|
for (int y = 0; y < heightMap.heightmapImage.getHeight(); y++) { |
|
|
|
for (int y = 0; y < terrain.heightmapImage.getHeight(); y++) { |
|
|
|
for (int x = 0; x < heightMap.heightmapImage.getWidth(); x++) { |
|
|
|
for (int x = 0; x < terrain.heightmapImage.getWidth(); x++) { |
|
|
|
|
|
|
|
|
|
|
|
color = new Color(heightMap.heightmapImage.getRGB(x, y)); |
|
|
|
color = new Color(terrain.heightmapImage.getRGB(x, y)); |
|
|
|
heightMap.pixelColorValues[x][y] = (short) color.getRed(); |
|
|
|
terrain.pixelColorValues[x][y] = (short) color.getRed(); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|