Cube Wave
Here's my take on... Daniel Shiffman's take on... Beesandbomb's take on the cube wave.
1
2import peasy.*;
3import peasy.org.apache.commons.math.*;
4import peasy.org.apache.commons.math.geometry.*;
5
6PeasyCam cam;
7
8float angle = 0;
9int w = 16;
10float magicAngle;
11float maxD;
12int orthoBound = 2048;
13
14void setup() {
15 //fullScreen(P3D);
16 size(900, 900, P3D);
17 magicAngle = atan(1 / sqrt(2));
18 maxD = dist(0, 0, height, height);
19 cam = new PeasyCam(this, 2048);
20 cam.setMinimumDistance(0);
21 cam.setMaximumDistance(4096);
22}
23
24void draw() {
25 background(0);
26 ortho(-orthoBound, orthoBound, orthoBound, -orthoBound, 0, orthoBound);
27 ambientLight(127, 127, 127);
28 //Red
29 pointLight(255, 127, 127, 0, 0, 0);
30 //Green
31 pointLight(127, 255, 127, width / 2, 0, height / 2);
32 //Blue
33 pointLight(127, 127, 255, 0, 0, height);
34 rotateX(-magicAngle);
35 rotateY(-QUARTER_PI);
36
37 for (int z = 0; z < height; z += w) {
38 for (int x = 0; x < width; x += w) {
39 pushMatrix();
40 float d = dist(x, z, width / 2, height / 2);
41 float offset = map(d, 0, maxD, -PI, PI);
42 float a = angle + offset;
43 float howHigh = map(sin(a), -1, 1, w, height);
44 translate(x, 0, z);
45 shininess(15.0);
46 //ambientMaterial(255);
47 //specularMaterial(255);
48 //normalMaterial();
49 //texture(img);
50 box(w, howHigh, w);
51 popMatrix();
52 }
53 }
54 angle -= 0.01;
55}```
56
57<h2>Sources</h2>
58
59- <a href="https://twitter.com/beesandbombs/status/940639806522085376">https://twitter.com/beesandbombs/status/940639806522085376</a>
60
61- <a href="https://www.youtube.com/watch?v=H81Tdrmz2LA">https://www.youtube.com/watch?v=H81Tdrmz2LA</a>