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.
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.
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?
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.
// 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);