Since Im having big trouble getting any work done with the RAW format that RawHeightMap (and MomokeFan's excellent Terrain generation code) uses I thought i would write my own heightmap generator based on any kind of image. Thinking that this might have been thought of before I opted to check around and what do you know - its already there. Its even in the Newbie tutorials so i figured it would be easy to get it done as it does exactly what i would do.
But it doesnt work… Here is my code:
//Create the heightmap from the generated Image
heightMap = new ImageBasedHeightMap(heightmapImage);
//Create the terrainpage
terrain = new TerrainPage("Terrain", 33, heightMap.getSize(), terrainScale, heightMap.getHeightMap(), false);
//Set location and lock it for transforms
terrain.getLocalTranslation().set(0, 10, 0);
When i run this it creates a plane in the correct size but it is completely flat... I have checked the integer array created by the function and it is fully populated so that part works. So why nothing happening with the Terrainpage?
Any help is apprciated :?
and MomokeFan's excellent Terrain generation code
I have never wrote any terrain generators.. although I did write a terrain splatting system. That one used jME's terrain generator classes so maybe you had them confused..
For the thread question, try doing a few things
- Call updateGeometricState() on the terrain page after you create it
- Remove the lockBounds/lockTransforms calls
- Try changing the Y value of the terrainScale variable to big or small values
- Make sure the image type you're using for the heightmap is compatible with AWT
Hey, Thanks for the quick response. Yeah I know it was a splatting system you did, but the source code for that is basically what im using to learn from since it looks a lot better than the tutorial example hehe!
Turns out it was the scaling that made it so small that it actually did draw, but just scaled so much it looked flat. Thought for sure I had already tried that - doh :-o
I was wondering another thing about your splatting engine - if you have the time to answer - how did you generate your rock detail texture alphamaps? What I thought would be smart would be to identify where the slope was steep and not and have it autogenerated to be a high alpha value of the rock texture at these points… Im assuming you did something similar? Or did you hand paint them? Any tips?
Thanks for all your help!
The latest splatting system uses the included splat textures in jME to make the terrain. The very first version generated them based on terrain height, but adding support for slopes shouldn't be difficult. There's one really nice texture generator in the jME planet generator demo which is under user code, can probably be modded to make alpha maps instead of textures.