Hello,
for creating a large terrain of golf courses based on GPS data I was using the ImageBasedHeightMap but
with this method we got only 256 Values for the height difference. this is too less for an smooth terrain.
So I want to use RawHeightmap with 16-Bit Greyscale Images.
The process is as follows:
At first we create an 2D 16-Bit grayscale image (.PNG ) from the given GPS Data of the golf course.
Then I load this image into Photoshop CS5 for editing parts like sand bunkers and water areas.
At the end of editing I export the Image into Photoshop RAW format.
When I load the photoshop raw image into the RawHeightmap it doesn’t work? Seems that this is the wrong raw format?
How could I solve this problem? What raw format does jME3 Alpha 4 need? Are there converters to convert .png file (16 bit)
to a working raw file?
greetings mw
Hi,
As far as I know, 16 bit grayscale PNGs can be loaded into ImageBasedHeightmap. I had some trouble with it, making the slopes in the terrain like stairs, and not having the time to figure it out here’s a short code, that will surely work:
[java]
try {
BufferedImage im = ImageIO.read(new File(“heightmap.png”));
WritableRaster r = im.getRaster();
int i = 0;
for (int y = 0; y < size; y++) {
for (int x = 0; x < size; x++) {
if (r.getTransferType() == DataBuffer.TYPE_USHORT) {
short[] bands = (short[]) r.getDataElements(x, y, null);
heightData[i++] = heightScale * (bands[0] & 0x0000FFFF) / 65536f;
}
}
}
} catch (IOException e) {
e.printStackTrace();
}
[/java]
Might not be the most elegant way to do it, but it works.
Hey anthyon,
I tried your method and it works. thank you very much. Terrain looks smooth now.