Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class HeightMap
- {
- float[][] heightMap;
- public HeightMap (String fileName)
- {
- int height, width;
- try
- {
- BufferedImage image = ImageIO.read(getClass().getResourceAsStream(fileName));
- heightMap = new float[image.getWidth()][image.getHeight()];
- for (int x = 0; x < image.getHeight(); ++x)
- {
- for (int z = 0; z < image.getWidth(); ++z)
- {
- heightMap[x][z] = new Color(image.getRGB(x, z)).getRed() / 255f;
- }
- }
- }
- catch (IOException e)
- {
- e.printStackTrace();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement