diff --git a/src/engine/InterestManagement/HeightMap.java b/src/engine/InterestManagement/HeightMap.java index 0b1bf7bf..44712e89 100644 --- a/src/engine/InterestManagement/HeightMap.java +++ b/src/engine/InterestManagement/HeightMap.java @@ -40,7 +40,7 @@ public class HeightMap { public static final HashMap heightmapByLoadNum = new HashMap<>(); - public static final HashMap _pixelData = new HashMap<>(); + public static final HashMap _pixelData = new HashMap<>(); // Heightmap data for all zones. public static float SCALEVALUE = 1.0f / 255; @@ -310,7 +310,7 @@ public class HeightMap { Logger.info(HeightMap.heightmapByLoadNum.size() + " Heightmaps cached."); - // Load pixel data + // Load pixel data for heightmaps try (Stream filePathStream = Files.walk(Paths.get(ConfigManager.DEFAULT_DATA_DIR + "heightmaps/TARGA/"))) { filePathStream.forEach(filePath -> { @@ -320,7 +320,24 @@ public class HeightMap { try { BufferedImage heightmapImage = ImageIO.read(imageFile); - int width = heightmapImage.getWidth(); + + // Generate pixel for this heightmap. RPG channels are all the same + // in this greyscale TGA heightmap. We will choose red. + + int[][] colorData = new int[heightmapImage.getWidth()][heightmapImage.getHeight()]; + + for (int y = 0; y < heightmapImage.getHeight(); y++) { + for (int x = 0; x < heightmapImage.getWidth(); x++) { + + Color color = new Color(heightmapImage.getRGB(x, y)); + colorData[x][y] = color.getRed(); + } + } + + // Insert color data into lookup table + + _pixelData.put(imageFile.getName().substring(0, imageFile.getName().lastIndexOf(".")), colorData); + } catch (IOException e) { throw new RuntimeException(e); }