【问题标题】:jme3 - UV map misplaced on model exported from Blenderjme3 - 从 Blender 导出的模型上的 UV 贴图错位
【发布时间】:2014-03-01 04:58:42
【问题描述】:

我在 Blender 2.69 中创建了一个simple model of a barrel (.zip)。然后我在 Blender 中创建了一个 UV 贴图,并用它制作了一个 UV 贴图纹理(它也在存档中)。然后我在 Blender 中导入我的纹理,现在映射匹配:

到目前为止,在 Blender 中模型看起来还不错:

通过使用我通过 jmonkeyengine SDK 安装的 Ogre 导出器插件,我导出了模型。这样做的结果是我的桶的 OgreXML 格式文件(我没有导出材料)。

现在,我尝试像这样将桶添加到我的世界中:

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);

结果是这样的:

在为我的 UV 映射模型设置纹理时,我还需要考虑其他什么吗?

【问题讨论】:

    标签: java 3d blender jmonkeyengine uv-mapping


    【解决方案1】:

    通常在将模型从 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)

    【讨论】:

    • 链接失效了。
    猜你喜欢
    • 2020-02-07
    • 2023-03-03
    • 2015-01-11
    • 2020-12-09
    • 2022-08-09
    • 2018-09-22
    • 2012-05-30
    • 2017-03-29
    • 2016-03-13
    相关资源
    最近更新 更多