# Generating a grid of cubes in 3D space [closed]

I am trying to generate a grid of cubes in 3D space and It aint workin...

All im doing is for looping YXZ (in that order) (nested for loops) then im doing cubes[x][y][z] = ... (new Location(x,y,z))

But when I render them they are in this weird line that curves every X cubes... What am I doing wrong?

RENDERING:

``````public void render() {
Cube[][][] temp = testchunk.getCubes();
for (int z = 0; z<temp[0].length;z++) {
for (int y = 0; y<temp[0][0].length; y++) {
for (int x = 0; x<temp.length; x++) {
Cube b = temp[x][z][y];
if (b != null) {
GL11.glTranslatef(b.getPosition().x, b.getPosition().y, b.getPosition().z);
GL11.glCallList(cubes.get(b.getCubeId()));
}
}
}
}

}
``````

GENERATING:

``````    for (int z = 0; z<cubes[0].length;z++) {
for (int y = 0; y<cubes[0][0].length; y++) {
for (int x = 0; x<cubes.length; x++) {
cubes[x][z][y] = (Cube.dirt.getInstance()).setPosition(new Vector3f(position.x+(x*Cube.CUBE_SIZE),position.z+(z*Cube.CUBE_SIZE),position.y+(y*Cube.CUBE_SIZE)));
}
}
}
``````
-

## closed as too localized by Byte56♦, msell, bummzack, Trevor Powell, AnkoApr 30 '13 at 15:31

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

Try looping in ZYX order, otherwise we will need to see some more context: How are you rendering your cubes (i.e. code snippets) – Mokosha Apr 29 '13 at 17:55
Doesnt work and im adding snippets now – gopgop Apr 29 '13 at 18:13
I think this is actually a "how to fix my code" question. – Byte56 Apr 30 '13 at 1:14