# help creating a grid

Hi, just wondering how I could creat a 4x4 grid or any size grid in 3d. Thanks

The following method will prob be the most logical way to create a 444 3d grid. (Well from my limited progamming experience)

I will explain what i think and then do some pseudo code

Create a cube using a variable as the length, lets say 5, now create a 3 layered for loop each counting to 4. Draw the first cude at location x,y,z. Each for loop will affect the axis. So in the first for loop affect the z axis so at each rotation the new cube is drawn 0-(zVARIABLE) the second for loop will affect the rows, so each cube should be drawn orig.y + yVARIABLE. The final for loop will affect the columns, so each cube should be drawn at orig.x + (x*VARIABLE).

Understand what i am saying???

Basically the pseudo code is:

VARIABLE = 10;
initial x point = 0;
initial y point = 0;
initial z point = 0;
create a cube using VARIABLE as the length of sides;

loop depth(z)
loop rows(y)
loop columns (x)

draw cube at initial x point + (x * VARIABLE)
draw cube at initial y point + (y * VARIABLE)
draw cube at initial z point + (z * VARIABLE)
end columns loop
end rows loop
end depth loop

If you are looking to do a 2d grid do the above but doint use the z loopper.

Catch what i am saying?

if you were to adapt this in 2d the grid will be set like this

|A||||
|B|
|||
|C||||
|
||D||

A is drawn at 0,0 - initial values
B is drawn at 0,(1VARIABLE) - y loop affected
C is drawn at 0,(2
VARIABLE) - y loop affected
D is drawn at (2VARIABLE) , (3VARIABLE) - x and y loop affected

Hoep that helped explain it visually