gpt4 book ai didi

java - 立方体渲染 : Textures displaying incorrectly

转载 作者:行者123 更新时间:2023-12-04 05:45:20 25 4
gpt4 key购买 nike

我试图通过创建 4 个彼此相邻的立方体来渲染墙,应用纹理时出现问题 - JME3 确实渲染了立方体并应用了纹理,但我看到了立方体的内部。这是我可以更改的某种形式的“ View ”吗?如果是这样,如何?

下面是代码和我的意思的图像 enter image description here

    Box ground = new Box(new Vector3f(1.0f, -1.0f, 1.0f), 5, 0,-5);
Geometry groundPlane = new Geometry("GroundPlane", ground);
Material groundMat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
groundMat.setColor("Color", ColorRGBA.Brown);
groundPlane.setMaterial(groundMat);

for(int i = 1; i < 5; i++)
{
Box wall = new Box(new Vector3f(0.0f, -1.0f, 0.0f), new Vector3f((float)i, 0.0f, -1.0f));
Geometry wallFace = new Geometry("WallMesh", wall);
Material wallSkin = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
Texture tex_ml = assetManager.loadTexture("Interface/Wall.png");
wallSkin.setTexture("ColorMap", tex_ml);
wallFace.setMaterial(wallSkin);
rootNode.attachChild(wallFace);
}

rootNode.attachChild(groundPlane);

亲切的问候

艾登·斯特里多姆

完成 - 最终代码
    Vector3f oldVec = Vector3f.ZERO;
Vector3f newVec = Vector3f.ZERO;

for(int i = 0; i < 5; i++)
{
newVec = new Vector3f((float)i, 0.0f, 0.0f);
Box wall = new Box(oldVec, newVec);
Geometry wallFace = new Geometry("WallMesh", wall);
Material wallSkin = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
wallSkin.setTexture("ColorMap", tex_ml);
wallFace.setMaterial(wallSkin);
//wallSkin.getAdditionalRenderState().setWireframe(true);
oldVec = new Vector3f((float)i, -1.0f, -1.0f);
rootNode.attachChild(wallFace);
}

rootNode.attachChild(groundPlane);

enter image description here

最佳答案

看起来你的法线指向相反的方向。检查您的渲染引擎以查看您是否具有反向法线功能,或者您需要以相反的顺序提供顶点。

或者试试这个方法

Box wall = new Box(new Vector3f(i, 0.0f, 0.0f), 1.0f, 1.0f, 1.0f);

关于java - 立方体渲染 : Textures displaying incorrectly,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10755264/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com