3

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?

4

1 回答 1

2

通常在将模型从 Blender 转移到 JME 之类的东西时,纹理会颠倒过来。加载纹理的位置:

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

而是使用 loadTexture() 方法的 TextureKey 形式并传递 yFlip false,因为 true 是默认值。

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

那应该可以解决您的问题。

参考:

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

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

于 2014-02-05T08:53:44.563 回答