Flipped textures?

So I create a model and texture in Blender, export it as an Orge mesh, convert it to to a j3o binary and load it into the engine and it loads fine. The call I use is:



[java]

box = (Node) assetManager.loadModel(“Models/Body1.mesh.j3o”);

rootNode.attachChild(box);

[/java]



However, as soon as I try and assign it a custom texture, such as the following code:

[java]

box = (Node) assetManager.loadModel(“Models/Body1.mesh.j3o”);

Material mat_tt = new Material(assetManager, “Common/MatDefs/Light/Lighting.j3md”);

Texture skin = assetManager.loadTexture(“Models/Body.png”);

mat_tt.setTexture(“m_DiffuseMap”, skin);

box.setMaterial(mat_tt);

rootNode.attachChild(box);

[/java]



It flips the texture vertically. If I go into photoshop, take the texture and flip it, it loads fine, it’s just flipped along the X axis.



However, if I go into the files tab, create a new material, edit the j3o object in the SceneExplorer, and modify the geometry’s properties to link the new material, it works fine without having to flip it.



Is there a reason for this? Am I doing it wrong? Thanks in advance for this puzzling issue. :slight_smile:

This is kind of goes into the discussion here:

http://hub.jmonkeyengine.org/groups/jmonkeyplatform/forum/topic/jmp-suggestion-thread/?topic_page=2&num=15#post-121613



How the decision to flip a texture depends on how its loaded

Ah, thanks for posting that. At least I know it’s normal. How does one flip the texture without physically altering the texture file?

Create a new material in jMP with these textures and set the texture to flip, then apply it to your model.

How do you do that in the code? Would it be some kind of .setBoolean call on the material set to true?

You could either load the texture with an TextureAssetKey with flip set or create a j3m and apply that to your model (which is basically the same as the jMP solution).

Ah, thanks! I didn’t know about TextureKey. The code that worked was:



[java]

TextureKey tk = new TextureKey(“Models/Body.png”, false);

Texture skin = assetManager.loadTexture(tk);

[/java]