I am trying to render a wall by creating 4 cubes next to each other, the problem comes when applying the texture - JME3 does render the cube and applies the texture but i am seeing the inside of the cube. Is this some form of "View" which i can change? If so, how?
Below is the code and an image of what i mean
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);
Kind Regards
Aiden Strydom
COMPLETED - FINAL CODE
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);
Looks like your normals are pointing in opposite directions. Either check your rendering engine to see if you have reverse normals function, or you need to provide the vertices in reverse order.
Or try this method
Box wall = new Box(new Vector3f(i, 0.0f, 0.0f), 1.0f, 1.0f, 1.0f);