Texture-mapping different images to faces of a cube

Hi fellas.

I'm using jME 3, jMonkeyPlatform, latest SVN version.

I would like to texture-map a cube so that each face of the cube will be textured with a different image.

I tried to do so using the TextureCubeMap object as follows:

Image negx = assetManager.loadTexture("Textures/1.jpg").getImage();
Image posx = assetManager.loadTexture("Textures/2.jpg").getImage();
Image negy = assetManager.loadTexture("Textures/3.jpg").getImage();
Image posy = assetManager.loadTexture("Textures/4.jpg").getImage();
Image negz = assetManager.loadTexture("Textures/5.jpg").getImage();
Image posz = assetManager.loadTexture("Textures/6.jpg").getImage();

Image cube = new Image(negx.getFormat(), negx.getWidth(), negy.getHeight(), null);

Texture envMap = new TextureCubeMap(cube);

But when I try to apply this texture to my cube, I get a rendering of the textual encoding of the image files on the faces of the cube.

Any suggestions?

Thank you,


would be my solution,

just use a model programm, texture it with 6 texures and let the tool create a atlas for you.

Also it saves you from 6 texturestate changes for rendering one object, (in a large scene this can/will reduce the overall performance) not to mention that it works on older graficcards that does not support 6 texture layers

Thank you for your reply, EP.

I forgot to mention that applying the texture must be done dynamically in my case. When the application loads it is given a set of 6 (arbitrary, not pre-defined) images and should map them to a cube.

So if I get your suggestion right, it is not good for me.


I don't think using a cubemap is good for this purpose. Cubemaps are generally used for environment mapping or texturing skies.

For texturing cubes I can recommend creating your own cube (using Quad meshes) and texture each quad separately.

Thank you, I'll do that.

I hope it won't have some bad effect on performance (I'm going to have a few 100-s of such cubes)


it will have effects, question is how bad,

simple calcualtion:

100 boxes->

600 draw calls

600 texture changes

However you might be able to optimize a bit, by making sure that same textureed quads are mostly at same distance (zbufferwise) then a few texture calls are not needed.

But if you don't know the texutres the only other solution I see is to create a textureatlas java native on start of application

Another thing you may want to look at is the SharedMesh class, as it can lower RAM usage very quickly and very easily.

If you have 600 different textures then it might be an issue (depends on the hardware). You may want to use a texture atlas to store them.

Thank you all,

What I'm trying to make is a card game (collector's, like Magic The Gathering).

There can be around 500 cards on the table at the same time.

Potentially, each card will have a different texture on the front face (although some sharing may occur).

All cards will have the same texture on their back face.

All other faces of the cards (sides) will be simple colored, no texture.

So basically I'm going to have 500 boxes, 501 different textures.

At any given time, most of the cards will be arranged in decks, so there may be a place for optimization here (like having one box representing the whole deck, with only the top card's texture shown, and each time you pick a card from the top, create a new box for that card.)

The cards must be created dynamically from jpg files on disk since there are thousands of possible cards and it is close to impossible to create an object in an external modeling software for each card. I would also like to support easy adding of new cards without having to mess with external modelers each time.

So, would you use a texture atlas for that? Is it possible to create atlas of 500 images? Each image's resolution should be about 300x450. If you think it is possible to use an atlas at run time, could you please hint me as to how to do it? I'm new to jME.

Thank you again,


look at the test package,

you could create just one model, and several textures, and set the texture directly.(while using the old texture coordinates,

then you could reduce the amount by using only one texture, continaing all sides, and with correct set texture coords there will be no visible difference, however you would only need one texturestate change and one draw call that way.

(in jme3 you could even share the mesh then without a problem, and just use a different material)


I just one to draw a texture in one side of a rounded-box (box=head, texture = face). Any easy solution?

Additionally, my texture is a png image with transparency, instead of transparency I’m getting a dark gray color. How can I solve this?