我试图通过创建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);

发布于 2012-05-26 08:21:32
看起来你的法线指向相反的方向。要么检查您的呈现引擎,看看是否有反向法线函数,要么您需要以相反的顺序提供顶点。
或者尝试这种方法
Box wall = new Box(new Vector3f(i, 0.0f, 0.0f), 1.0f, 1.0f, 1.0f);发布于 2012-05-25 14:06:49
Box类是您自己的,还是由j猴子提供的?
如果是你自己的,你的三角卷绕顺序就会被翻转。
https://stackoverflow.com/questions/10755264
复制相似问题