JME : Error while loading texture, imageWidth: 450 != imageHeight: 338

Hello friends,

I am trying to load a static image in a Terrain, which is a football goal post(JPG image). I don’t want this image to move and at the appropriate position(just like in a football game). As of now, I am first trying to load the image as a Texture, but it’s not working. Is there no way, I can directly add this goal image in the Scene(.j3o file) at appropriate position, so I don’t have to add it in code all time.

Code :

Texture goalTexture = assetManager.loadTexture(“Textures/cartoon.jpg”);
AbstractHeightMap heightmap = null;
heightmap = new ImageBasedHeightMap(goalTexture.getImage());
heightmap.load();

Error log :

SEVERE: Uncaught exception thrown in Thread[LWJGL Renderer Thread,5,main]
java.lang.RuntimeException: imageWidth: 450 != imageHeight: 338
at com.jme3.terrain.heightmap.ImageBasedHeightMap.load(ImageBasedHeightMap.java:106)
at com.jme3.terrain.heightmap.ImageBasedHeightMap.load(ImageBasedHeightMap.java:82)
at mygame.Main.simpleInitApp(Main.java:83)

Above error happens at heightMap.load(); . Thank you.

You are treating the image like a height map. Height maps have to be square I guess… but that’s certainly not what you want.

Nothing in any way related to terrain is going to get you what you want. If you want a goal situated somewhere then you will have to make a separate geometry and put it there.

I’m guessing the width and the height of the image must be the same. OR your graphics card doesn’t support NonPowerOfTwo textures.

Try to load a 32x32 image, and then a now power of two image, for example 50x50.

Thank you. The Test-data which is part of tutorials, there in the tutorials they are able to load the PNG images for buildings directly in the terrain. How is that?

So the buildings are flat and painted on the terrain? I’ve never seen that.

Usually we see building models loaded. 100000% different than terrain. Those are models. Terrain is terrain. Apples and oranges.

a) This Section is for User Developments, Troubleshooting would be the right category for this
b) You get that Terrain Thing wrong. A Terrain is simply the hills up and down. This has nothing to do with your football-sign.

Textures are somewhat right, but only a Texture won’t help you. You also need the “Model” file.
For that you could create a simple box in blender and apply the texture there (googling will help much)
You could also use the Scene Composer with “Create new Primitive → Box” and then apply the Material but let’s start simple and follow the blender part.

Something like this: https://www.youtube.com/results?search_query=blender+create+textured+cube
Also you should work through http://wiki.jmonkeyengine.org/doku.php/jme3:beginner:hello_asset and the one’s before.

Hello Asset states:

 // Create a wall with a simple texture from test_data
        Box box = new Box(2.5f,2.5f,1.0f);
        Spatial wall = new Geometry("Box", box );
        Material mat_brick = new Material( 
            assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
        mat_brick.setTexture("ColorMap", 
            assetManager.loadTexture("Textures/Terrain/BrickWall/BrickWall.jpg"));
        wall.setMaterial(mat_brick);
        wall.setLocalTranslation(2.0f,-2.5f,0.0f);
        rootNode.attachChild(wall);

This is exactly what you want.

1 Like

Note: I’ve moved your thread to the right topic. Please be careful about that in the future.

By the way, it will save you from asking the next 100 questions if you go ahead and do all of the tutorials. Certainly the beginner ones at least.

Probably you mean terrain.zip. That thing was made in Blender and not using TerraMonkey.

okay. I will check out the tutorials. Thank you.