HELP! Textures

How do i use more than one texture. I want to put a different texture on each side of a cube. Any elp is greatly appreciated

I don’t know about this for certain but I think you need to either break your cube up into six faces ( just creating a basic “face” class that extends Shape3D ) and give each one it’s own texture or to create a texture that wraps around the different faces of the cube so it looks different on each one. You may even be able to do something really clever with texture-co-ordinates setting them for each face so that an image that is just a strip of textures can be mapped to different faces using it’s co-ordinates. I’m rather thinking on my feet here, though and I wouldn’t like to try and think through the code for that one…

Hello,

If you are using a com.sun.j3d.utils.geometry.Box you can do the following:

//----------------------------------------------------------------------- Create the Box
Box myBox = new Box(1.0f, 1.0f, 1.0f, Primitive.GENERATE_TEXTURE_COORDS,
new Appearance());

Appearance frontAppearance = new Appearance();
TextureLoader loader = new TextureLoader(this.getClass().getResource("…/images/C006BASZOM.jpg"), canvas);

//----------------------------------------------------------------------- For each texture
Appearance frontAppearance = new Appearance();
frontAppearance.setTexture(loader.getTexture());

//----------------------------------------------------------------------- Place the textures
myBox.getShape(Box.FRONT).setAppearance(frontAppearance);
myBox.getShape(Box.BACK).setAppearance(backAppearance);
myBox.getShape(Box.BOTTOM)…

Hope this help,