【Processing】sphereDetail()とsphere()とrotate()

 

 

 

 openProcessingにあげてみたら色指定が対応していないのか緑で影が変な感じに...

 

 sphereDetail()とsphere()とrotate()をランダムでばばばば

if(a%20 == int(random(10))){}

こういう書き方してみたらこんな挙動になった。

if分の条件を徹底的にネチネチ書いて追求するのもいいかも。

 

int grid = 10;
int a = 0;
float[][] b = new float[grid][grid];
color[][] c = new color[grid][grid];
float[][] d = new float[grid][grid];

void setup(){
  size(500,500,P3D);
  colorMode(HSB,360,100,100,100);    background(0);
     reset();
}


void draw(){
    background(0);
  lights();
  for(int i = 0; i < grid; i++){
    for(int j = 0; j < grid; j++){
  pushMatrix();
  noFill();
  fill(c[i][j]);
  stroke(0);
  translate(25 + 50*i,25 + 50*j);
  rotateY(radians(a));
  rotateX(radians(a*d[i][j]));
  sphereDetail(int(b[i][j]));
  sphere(25);
  popMatrix();
    }
  }
  a++;
  
  if(a%20 == int(random(10))){
  reset();
  }
}


void reset(){
    for(int i = 0; i < grid ;i++){
      for(int j = 0; j < grid; j++){
        b[i][j] = random(2,6);
        c[i][j] = color(random(360),random(0,10),100,100);
        d[i][j] = random(20);        
      }
    }
}