Help this hopeless 3D newbie

How can I add a different texture to each of a Box's faces?



(you can explain all you want, but sample code is easier for me to understand :slight_smile:



Thanks in advance!



Son Of Cain

Thanks dude… but let me explain my needs so that you suggest the approach you think is fit:



My game maps are composed of several "blocks" - cubes or boxes - that can be put on top of each other. On the "top" of each block goes the texture representing the ground, or in case this block is under any other block, the texture needs not to be rendered. The visible textures depend on how the blocks are connected to each other. See what I mean? I'll only know about each block's position in the map when I load it.



So, what's the best (performance-wise) solution for this case? I find it very simple in theory, but due to my lack of practice in 3D programming, and JME, I'm a bit lost about what solution to apply. It might even be that I'm going in the wrong way to implement this…

To do so, you would need to create a single texture that contained all 6 textures you wanted to map onto the box faces.  Then you'd change the tex coords to point to the subset rectangle of that texture that contains the texture for the given face.



It's not as bad as it sounds, but if you want to switch out textures on faces often (or much at all) it would be annoying or have to be done dynamically.  You may want to simply use 6 Quads attached to a single node instead.  This is how SkyBox works.  have a look at how those quads are rotated into place to make a cube.



Hope that helps.

If I under stand what you are trying to create, then I think that it would be better to render only the sides of the boxes that are visible using quads. Basically you should imaginary stack the boxes and fined the sides that can be seen. Create a Quad for each side and assign it the texture you want. If not all sides of the boxes will be visible then this may be faster then rendering boxes. 



If you want to speed things up you can use a CompositeMesh but it would reqwaure more advance programming and you will need to combine textures like renanse said.

Ok, I'll try that out, thanks for the tip. That and a clone creator (or shared geometry) may be all that I need.



Son Of Cain

happy to help.