1

I created a box and applied a texture to it. Is it possible to apply (and how) a different texture to each face of the cube? I have read some solutions but have not fully understood them.

I'm using JavaFX 11.0.2 and openJDK 11

This is the code of the box:

private Box prepareBox() {
        PhongMaterial material = new PhongMaterial();
        material.setDiffuseMap(new Image(getClass().getResourceAsStream("/res/wood.jpg")));
}
Nico
  • 37
  • 8

1 Answers1

0

Read the following presentation slides 25 to 30 (UV mapping on a cube).

https://www.slideshare.net/jpt1122/con2221-weaver-exploringjavafx3d

An alternate solution is to use this TextureAtlas implementation: Create a cube using different textures in JavaFX

noah1400
  • 1,282
  • 1
  • 4
  • 15
  • Alternatively you can either change the cube mesh or the texture coordinates, as in [here](https://stackoverflow.com/a/34007952/3956070) or [here](https://stackoverflow.com/a/26834319/3956070) – José Pereda Mar 24 '21 at 16:43