Changes to terrain heightmap loading: removing AWT dependencies

I committed some changes to the terrain classes, in particular TerrainGrid and ImageBasedHeightMap, that removed the dependency to AWT. These classes now rely on the asset manager to load heightmap images.



You will have to slightly modify your existing code like this to remove any compilation errors:

[java]

// old way

heightmap = new ImageBasedHeightMap(ImageToAwt.convert(heightMapImage.getImage(), false, true, 0), 1f);



// new way:

heightmap = new ImageBasedHeightMap(heightMapImage.getImage(), 1f);

// notice no more ImageToAwt.convert()

[/java]

(example code from TerrainTest.java)



Along with this, ImageBasedHeightMap now supports 16bit grayscale heightmaps as well as 8bit.



There will be some more changes in the next few days removing the last of the AWT dependencies (notably in FractalTileLoader)

7 Likes

Nice one!



What’s one the immediate to do list on the terrain system?

awesowenesowenwsowenes !

@iamcreasy said:
What's one the immediate to do list on the terrain system?

Getting it release ready ;) Basically feature-wise we look into getting "endless" terrain into the system and editor before release, else theres probably only fixes and optimizations like these.

Will it be possible to write generated height map images without AWT also?

Just look at the changes, you just use normal jme3 images now instead of awt BufferedImages, which were not a good idea in the first place.

1 Like

Awesome, less to worry about.

@androlo said:
Will it be possible to write generated height map images without AWT also?

Yep
2 Likes

@Sploreg TerrainGridTest still shows no result. Just empty blue screen.



And the jME testes still had old ImageToAwt code, I had to manually remove them from all the examples after updating to latest nightly.

  1. Move the cam down in the test.
  2. You have to create a new test project after you updated, the old one obviously contains the old code.
@iamcreasy said:
@Sploreg TerrainGridTest still shows no result. Just empty blue screen.

And the jME testes still had old ImageToAwt code, I had to manually remove them from all the examples after updating to latest nightly.

The tests definitely have been updated, you must have the wrong version.

Great change! :slight_smile: