Terrain Texture Loading on Reversed

I made a quick search around the forums for something similar and could not find anything.



I have a problem where I'm trying to load a complete terrain from EarthSculptor into JME and when I do this the result is correct almost but the terrain texture is reversed according to the heightmap.(So I guess the heightmap could be the one that's reversed but according to the default view in EarthSculptor it's the texture that is).



I have a program that could flip the image for me(I believe it's called paint) but it seems tedious to have this done for each of my terrains.(Especially since someone else could be the one making them)



Here is my code



Forgive me for some bad code I'm new, I'm using StandardGame for this, this code is inside the only Active Gamestate and it runs on load.


 
private void createTerrain() throws IOException {
    URL grayScale = GameUtils.createLocalURL("src/gamebatch/terrain/heightmap.png");
    final ImageBasedHeightMap heightMap = new ImageBasedHeightMap(new ImageIcon(grayScale)
            .getImage());

    Vector3f terrainScale = new Vector3f(1, 0.2f, 1);
    page = new TerrainPage("Terrain", 33, heightMap.getSize(), terrainScale, heightMap
            .getHeightMap());
    page.getLocalTranslation().set(0, 0, 0);
    page.setDetailTexture(1, 16);

    Future<Object> future = GameTaskQueueManager.getManager().update(new Callable<Object>() {
      public Object call() throws Exception {
        TextureState ts = glThread.getDisplay().getRenderer().createTextureState();
        ts.setEnabled(true);

        Texture t1 = TextureManager.loadTexture(GameUtils
                .createLocalURL("src/gamebatch/terrain/texturedetail.jpg"));
        ts.setTexture(t1, 0);
        t1.setApply(ApplyMode.Replace);
        page.setRenderState(ts);
        return null;
      }
    });
    try {
      future.get();
    } catch (Exception e) {
    }

    splatTerrain = page;

    this.getRootNode().attachChild(splatTerrain);
  }



Thanks for any help.

What do you mean by "reversed" ?  Upside down, negative image ?



A smart man once said, a picture paints a thousand words :slight_smile:

Important

At the end of writing this I realized that saying it's mirrored is the best explanation. But the heightmap was not mirrored. I'm also home from work now and have attached the two files.

*



Thanks for the reply, I'm at work so I don't have a picture I could get one later, but I don't know if that would help because the terrain texture doesn't look incorrect, I only know it's wrong because I know that I put this one texture on a certain hill and it's on the opposite side. The texture looks like it was flipped like a pancake(So all the colors look the same) so they are all on the other side of the map.







Example -



In Earth Sculptor

123

456

789



In JME



321

654

987



So it's kinda like they got flipped right to left but stayed the same up and down. So it's not like it got turned 180 degrees either it's like it got flipped like a pancake.



I guess saying a Mirror Image is the most correct way of explaining it. But the HeightMap looks correct, it's not mirrored.(Or the heightmap is and the texture is not).



Thanks again for your reply.





Edit

I have now attached the two files, as you can see they are both facing the same direction. But in game the extra colored part ends up flipped to the top of it.(So when I said it flips right/left earlier I meant up/down now that I can see the pictures and am not just looking through a camera). These are not the exact files I'm uploading I simply resaved them as JPG's to save space when I attach them.(Don't know why it put the heightmap twice…) But the last one is an example of what it looks like in game(I flipped it with paint)

Try using the TextureManager.loadTexture() variation that takes a boolean "flipped" argument for the detail texture.

I didn't realize there was a method with that argument, but I took a look and now I see that the overloaded method calls the other with flipped as the default??? that doesn't seem right.

The reason is that OpenGL handles texture coordinates in such a way that flipping along the Y axis is required. Try loading the texture with the flag off.

Oh Sorry I forgot to mention yes, it does work with the flag off. I just thought it was odd that true was the default, seems like it would make more sense for flipped true to be used anywhere where that corner case is neccesary.

Just checked earthsculptor and there isn't an option to flip it. But ok if I'm the corner case that makes sense then. Not like it's a trouble I was just confused.



Thanks for the replys

I get the same thing with GROME terrain/textures.