3D Terrain Engine with Perlin Noise in Processing 08-19-2016, 12:27 AM
#1
First off, I'm going to continue to stress how awesome this environment is. 3D rendering is a piece of cake, graphics in general as easy as hell, and it's the simplest thing on earth to debug when things don't work. Anyway, onto this.
Screencap:
![[Image: vtZ84tI.png]](http://i.imgur.com/vtZ84tI.png)
Download Processing:
https://processing.org/download/?processing
Spoiler: source
Code:
int cols,rows,scl=20;
float[][] terrain;
float fly=0;
int varHeight=70;
void setup(){
size(800,500,P3D);
cols=round(width*3/scl);
rows=round(height*2/scl);
terrain=new float[cols][rows];
}
void updateTopograph(){
float yOff=fly;
for(int y=0;y<rows-1;y++){
float xOff=0;
for(int x=0;x<cols;x++){
terrain[x][y]=map(noise(xOff,yOff),0,1,-varHeight,varHeight);
xOff+=0.1;
}
yOff+=0.1;
}
fly-=0.05;
}
void drawMap(){
fill(0,150,0);
translate(width/2,height/2);
rotateX(PI/2.5);
translate(-width*1.25,-height*1.25);
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();
}
}
void draw(){
background(0,115,255);
lights();
updateTopograph();
drawMap();
}Screencap:
![[Image: vtZ84tI.png]](http://i.imgur.com/vtZ84tI.png)
Download Processing:
https://processing.org/download/?processing
It's often the outcasts, the iconoclasts ... those who have the least to lose because they
don't have much in the first place, who feel the new currents and ride them the farthest.
don't have much in the first place, who feel the new currents and ride them the farthest.















![[+]](https://sinister.ly/images/modern/collapse_collapsed.png)


