We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
3d grid of boxes (Read 762 times)
3d grid of boxes
Feb 15th, 2010, 1:20pm
 
hello
i want to draw a 3d grid of boxes.
Any ideas how i could do that?

thanks!
Re: 3d grid of boxes
Reply #1 - Feb 15th, 2010, 4:12pm
 
Quote:
float r = 0;
void setup(){
  size(200,200,P3D);
  noStroke();
}
void draw(){
  background(0);
  lights();
  translate(width/2.0, height/2.0,30);
  rotateY(r);
  r=(r+0.01)%TWO_PI;
  for(int x=-1;x<2;x++){
    for(int y=-1;y<2;y++){
      for(int z=-1;z<2;z++){
        pushMatrix();
        scale(30);
        translate(x,y,z);
        fill(66*(x+2), 66*(y+2), 66*(z+2));
        box(1);
        popMatrix();
      }
    }
  }
}

Page Index Toggle Pages: 1