Hey all,
I’m working on Lesson 34 of the NeHe tutorial which is about heightmaps. I’m trying to adjust it by making the terrain look how I’d like it to look so I’m adding my own data to the data file to be read in.
If I don’t change the code and leave it as is from the tutorial, it works, but if I change the MAP_SIZE to be 8 (instead of 1024) and creat e an ascii file with 8 * 8 ascii characters (instead of the orig 1024 * 1024 size file), the map doesn’t appear.
Anyone have an idea what I’m doing wrong?
private static final int MAP_SIZE = 8;
private byte[] heightMap = new byte[MAP_SIZE * MAP_SIZE];
private void loadTerrainFile(String fileName, byte[] pHeightMap) throws IOException {
FileInputStream inputStream = new FileInputStream(fileName);
int bytesRead = 0;
int bytesToRead = pHeightMap.length;
while (bytesToRead > 0) {
int read = inputStream.read(pHeightMap, bytesRead, bytesToRead);
bytesRead += read;
bytesToRead -= read;
}
inputStream.close();
for (int i = 0; i < pHeightMap.length; i++) {
pHeightMap[i] &= 0xFF;
}
}
This is my data file …
aaaaaaaaccccccccggggggggllllllllrrrrrrrrssssssssttttttttzzzzzzzz
It seems like such a simple change, I don’t know why it stopped working.