Simulation of Movement Across Terrain
// Modified from Original
// Based on: https://youtu.be/IKB1hWWedMk
int cols, rows;
int scl = 30;
int w = 1000;
int h = 1000;
float flying = 0;
float[][] terrain;
void setup() {
size(800, 800, P3D);
cols = w / scl;
rows = h/ scl;
terrain = new float[cols][rows];
}
void draw() {
flying -= 0.2;
float yoff = flying;
for (int y = 0; y < rows; y++) {
float xoff = 0;
for (int x = 0; x < cols; x++) {
terrain[x][y] = map(noise(xoff, yoff), 0, 1, -300, 300);
xoff += 0.3;
}
yoff += 0.3;
}
background(0);
stroke(255);
noStroke();
fill(255,0,0,150);
translate(width/2, height/2+50);
rotateX(PI/3);
translate(-w/2, -h/2);
for (int y = 0; y < rows-1; y++) {
beginShape(TRIANGLE_STRIP);
for (int x = 0; x < cols; x++) {
vertex(x*scl, y*scl, terrain[x][y]);
vertex(x*scl, (y+1)*scl, terrain[x][y+1]);
}
endShape();
//frameRate(1);
}
}