View Full Version : help creating a grid
05-05-2004, 02:53 AM
Hi, just wondering how I could creat a 4x4 grid or any size grid in 3d. Thanks
05-05-2004, 03:30 AM
The following method will prob be the most logical way to create a 4*4*4 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-(z*VARIABLE) the second for loop will affect the rows, so each cube should be drawn orig.y + y*VARIABLE. 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 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 loopIf you are looking to do a 2d grid do the above but doint use the z loopper.
Catch what i am saying?
05-05-2004, 03:36 AM
if you were to adapt this in 2d the grid will be set like this
_ _ _ _
A is drawn at 0,0 - initial values
B is drawn at 0,(1*VARIABLE) - y loop affected
C is drawn at 0,(2*VARIABLE) - y loop affected
D is drawn at (2*VARIABLE) , (3*VARIABLE) - x and y loop affected
Hoep that helped explain it visually
Powered by vBulletin® Version 4.2.2 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.