我试图通过创建彼此相邻的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);
亲切的问候
Aiden Strydom
已完成 - 最终代码
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);
答案 0 :(得分:3)
看起来你的法线指向相反的方向。检查渲染引擎以查看是否具有反向法线功能,或者需要以相反的顺序提供顶点。
或尝试此方法
Box wall = new Box(new Vector3f(i, 0.0f, 0.0f), 1.0f, 1.0f, 1.0f);
答案 1 :(得分:0)
Box
类是您自己的,还是由jmonkey提供的?
如果是你自己的,你的三角形缠绕顺序似乎会被翻转。