Material not mapped properly when converted to .j3m

So, in the Hello Material tutorial, I got the example code working properly using both setting the material properties in the code, and also using a .j3m file. But when I try to do the same with an Object, the j3m results in a skewed texture. Example:

Regular way:
Material catMat = new Material(assetManager,
“Common/MatDefs/Light/Lighting.j3md”);
catMat.setTexture(“DiffuseMap”,
assetManager.loadTexture(“Models/cat/cat_diff.tga”));
cat.setMaterial(catMat);

That works. My cat has fur and eyeballs.

But when I create this file, MyCatMaterial.j3m:

Material shiny cat material : Common/MatDefs/Light/Lighting.j3md {
MaterialParameters {
DiffuseMap : Models/cat/cat_diff.tga
}
}

and then:

cat.setMaterial((Material) assetManager.loadMaterial(
“Materials/MyCatMaterial.j3m”));

Now the texture is all skewed sideways on the cat and it has an eyeball in it’s ear. The “way” it’s skewed looks like it’s exactly along the cat’s ZY Plane, bisecting the cat. Now, this cat object is a .j3o file that I created, and the cat comes with other files too like .mtl, .obj, .g3db…

Do I need to set some texture coordinates or…something when using the .j3m material I made???

The two should be identical. Something you aren’t showing us must be different.

…and just in case, what version of JME are you running? (Too many people are still running ancient 3.0 RC 2 by now.)

got this issue today still using jme 3.0, UVs are messed up when loading through j3m…refactored an existing j3m to the model I am testing now, so I know the j3m is “good” but the mapping gets broken for this model in particular when using j3m…the model itself will be discarded from the project, but I want to know how to fix it if I encounter it again

The j3m doesn’t store UV coordinates, the mesh does.

yeah but how is it that the engine seems able to load materials correctly when done by hand but not through j3m for some models,

here is a vanilla jme3 lighting j3m

Material Ghoul : Common/MatDefs/Light/Lighting.j3md {
     MaterialParameters {
         Shininess: 16.0
          DiffuseMap : assets/ghoul/diffuse.png
            NormalMap : assets/ghoul/normal.png
          SpecularMap : assets/ghoul/specular.png
      

     }
}

I don’t know how a material can influence the texture coordinates in any way, except it uses a different/faulty shader. Maybe you load different images with the j3m?

Well it seems that I will have to either stomach the mangled textures until I change the model or recreate a manual loading constructor for instances when models break with j3m as a workaround…because if you don’t know, I doubt that I will find the issue

It seems that textures loaded via code are flipped by default:

public Texture loadTexture(String name){
    TextureKey key = new TextureKey(name, true);
    key.setGenerateMips(true);
    Texture tex = loadTexture(key);
    logger.log(Level.FINE, "{0} - {1}", new Object[]{tex, tex.getMinFilter()});
    return tex;
}

Use ‘flipped’ parameter in j3m file.

yup that’s it thanks