Daily Creative Coding

元「30 min. Processing」。毎日、Creative Codingします。

パーリンノイズでブロックを波立たせる

JavaScriptモードとJavaモードで描かれるものが異なる. Javaモードを推奨.

/**
* 3D Perlin Blocks
*
* @author aa_debdeb
* @date 2015/09/28
*/

void setup(){

  size(500, 500, P3D);
  smooth();
  frameRate(24);
  lights();
  
  camera(1500, 500, 1200, 500, 500, 0, 0, 0, -1);
}

void draw(){

  background(0);
  stroke(255); 
  fill(150);
  for(int xi = 0; xi <= 10; xi++){
    for(int yi = 0; yi <= 10; yi++){
      pushMatrix();
      float h = 500 * noise(xi * 0.1, yi * 0.1, frameCount * 0.1);
      translate(xi * 100, yi * 100, h/2);
      box(100, 100, h);
      popMatrix();
    }
  }

}