我试图通过创建彼此相邻的 4 个立方体来渲染墙壁,应用纹理时出现问题 - JME3 确实渲染了立方体并应用了纹理,但我看到了立方体的内部。这是我可以改变的某种形式的“视图”吗?如果是这样,怎么做?
下面是我的意思的代码和图像
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);