I have the following code:
Texture Tex1 = assetManager.loadTexture(“Textures/wall1.png”);
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setTexture(“ColorMap”, Tex1);
lWall.setMaterial(mat);
But while running the code the Texture is not visible. I get only a white color.
What is wrong?
Can you show us the code cut-and-pasted from your real code instead of shown in two separate parts that were clearly originally mixed together?
What you are trying to do is very simple… like one of the simplest things. So what’s wrong is not directly in what you posted. While you’re at it, post the texture you are using also.
The full code is:
Texture Tex1 = assetManager.loadTexture(“Textures/wall1.png”);
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setTexture(“ColorMap”, Tex1);
Box b = new Box(0.1f, 2, 3);
Geometry lWall = new Geometry(“Box”, b);
lWall.setLocalTranslation(new Vector3f(-3,0,0));
lWall.setMaterial(mat);
rootNode.attachChild(lWall);
The texture is just a jpeg (.jpg) picture.
It is in the Texture folder un der the project’s asset folder
Texture Tex1 = assetManager.loadTexture(“Textures/wall1.png”);
Material mat = new Material(assetManager, “Common/MatDefs/Misc/Unshaded.j3md”);
mat.setTexture(“ColorMap”, Tex1);
Box b = new Box(0.1f, 2, 3);
Geometry lWall = new Geometry(“Box”, b);
lWall.setLocalTranslation(new Vector3f(-3,0,0));
lWall.setMaterial(mat);
rootNode.attachChild(lWall);
The texture is just a jpeg (.jpg) picture.
It is in the Texture folder un der the project’s asset folder