[Solved]Im looking for an example of using one image that has multiple textures to map cubes

If I have a 256x256 image that contains 16 16x16 images how would I use that to map to a box.

Say I have 2 Box classes

The first I want to be textured with the pixels from 0,0 to 15, 15

The second I want to be texture with pixels from 15,0 to 31,15

Anyone know of an example like that?


The texture coordinates for each vertex are ranging from 0.0 to 1.0 where the values describe the x and y location of the image multiplied by its x / y size. The default box texture coordinates display the texture completely on each side.

I ended up making a new class


public class BlockBox extends Box{

private float x1 = 0.0f;

private float x2 = 1.0f;

private float y1 = 0.0f;

private float y2 = 1.0f;;

public BlockBox(Vector3f center, float x, float y, float z, float sectionsX, float sectionsY, float row, float column) {

this.x1 = (1/sectionsX)column;

this.y1 = (1/sectionsY)row;

this.x2 = (1/sectionsX)

this.y2 = (1/sectionsY)

updateGeometry(center, x, y, z);



protected void duUpdateGeometryTextures() {


x2, y1, x1, y1, x1, y2, x2, y2, // back

x2, y1, x1, y1, x1, y2, x2, y2, // right

x2, y1, x1, y1, x1, y2, x2, y2, // front

x2, y1, x1, y1, x1, y2, x2, y2, // left

x2, y1, x1, y1, x1, y2, x2, y2, // top

x2, y1, x1, y1, x1, y2, x2, y2 // bottom


if (getBuffer(Type.TexCoord) == null){

setBuffer(Type.TexCoord, 2, BufferUtils.createFloatBuffer(SIZED_GEOMETRY_TEXTURE_DATA));



public void setX1(float x1) {

this.x1 = x1;


public void setX2(float x2) {

this.x2 = x2;


public void setY1(float y1) {

this.y1 = y1;


public void setY2(float y2) {

this.y2 = y2;