Problem with ImageToAwt.convert (can’t compile tutorial)

The following code returns the error

no suitable constructor found for ImageBasedHeightMap(java.awt.image.BufferedImage)

constructor com.jme3.terrain.heightmap.ImageBasedHeightMap.ImageBasedHeightMap(com.jme3.texture.Image,float) is not applicable

(actual and formal argument lists differ in length)

constructor com.jme3.terrain.heightmap.ImageBasedHeightMap.ImageBasedHeightMap(com.jme3.texture.Image) is not applicable

(actual argument java.awt.image.BufferedImage cannot be converted to com.jme3.texture.Image by method invocation conversion)




[java] AbstractHeightMap heightmap = null;

Texture heightMapImage = assetManager.loadTexture(“Textures/Terrain/splat/mountains512.png”);

heightmap = new ImageBasedHeightMap(

ImageToAwt.convert(heightMapImage.getImage(), false, true, 0));



heightmap.load();[/java]

The error is on line 3.



This is taken directly out of the tutorial Progress Bar as well as I get the same error in this project which seems to compile fine with everyone else. I have tried clean and build (to just get the error), my jme sdk says there are no updates found. Is it a problem with my coding environment or just something that recently changed in jme3?

oof that old terrain code is peppered throughout. It is actually out of date and from an old version, sorry about that (I just updated it now).

Thanks! I got it working now.

I’m having the same issue and I can’t quite figure out how to get it working.

I’m running the latest update,

guys please read the error output and the little hint that java skills are required for jme.

@danoso42 re-read the tutorial page, I corrected the error in it.

1 Like

I do have good general Java skills. I’m sure that as a developer you can realize, however, that it takes a little while to get set up with a new engine.



I was messing around with the code and discovered that fix to get rid of the error. Thank you for the fast response and confirmation. :slight_smile:



However, I now encounter a new issue. The terrain is perfectly flat. These terrain issues (mentioned above and what I am now describing) first arose when I updated to the latest release. My code worked perfectly before this, so I know the image should be working. I also tried loading the image directly from the assetManager, and the same thing happened. I tried using it with a different image as well, and got the same result.



Any ideas?

“latest version” as in latest stable or “latest version” as in nightly. Stable is what you should be targeting so don’t update to nightly if you haven’t already… just wanted to confirm what you meant.

1 Like

Can you provide a test case with the image you are using and show that it isn’t loading? All of the terrain test cases use an image heightmap and they load just fine, so maybe in the process of distilling down your code to a test case you can find what is going wrong; it often helps me when I do that. Then in the end if you cannot find the issue, we have some code to go by and help.

1 Like

I do indeed have the Nightly version already, pspeed, but I’ll change my settings as you suggest.



I’ll create a test case and post back my results next chance I get.

Thank you very much for the speedy replies!

After some trial and error, I solved the problem by re-exporting my terrain images from photoshop. For some reason, the engine didn’t like my old files.