Question

I created a simple model of a barrel (.zip) in Blender 2.69. Then I created a UV map in Blender and made a UV mapped texture out of it (its in the archive, too). Then I imported my texture in Blender, now the mapping matches:

The mapping

In Blender the model looks fine so far:

Model in Blender

By using the Ogre exporter plugin that I installed via the jmonkeyengine SDK, I exported the model. The result of this is my OgreXML format file of the barrel (I did not export material).

Now, I tried to add the barrel to my world like this:

this.barrel = this.assetManager.loadModel("models/barrel/Barrel.mesh.xml");

Material barrelMat = new Material(this.assetManager,
        "Common/MatDefs/Light/Lighting.j3md");
barrelMat.setTexture("DiffuseMap",
        this.assetManager.loadTexture("models/barrel/Barrel.jpg"));
barrelMat.setBoolean("UseMaterialColors", true);
barrelMat.setColor("Diffuse", ColorRGBA.White);
barrelMat.setColor("Specular", new ColorRGBA(0.3f, 0.1f, 0, 1));
barrelMat.setFloat("Shininess", 4f);
this.barrel.setMaterial(barrelMat);

this.rootNode.attachChild(this.barrel);

The result is this:

The failed barrel image

Is there something else I have to consider when setting the texture for my UV mapped model?

Was it helpful?

Solution

Often when transferring models from Blender to something like JME, the textures will be upside down. Where you load the texture:

barrelMat.setTexture(“DiffuseMap”, 
                     assetManager.loadTexture(“models/barrel/Barrel.jpg”));

Instead use the TextureKey form of the loadTexture() method and pass yFlip false since true is the default.

assetManager.loadTexture(new TextureKey(“models/barrel/Barrel.jpg”, false));

That should fix your issue.

References:

loadTexture() : http://hub.jmonkeyengine.org/javadoc/com/jme3/asset/AssetManager.html#loadTexture(com.jme3.asset.TextureKey)

TextureKey : http://hub.jmonkeyengine.org/javadoc/com/jme3/asset/TextureKey.html#TextureKey(java.lang.String,%20boolean)

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top