Login Register






Thread Rating:
  • 0 Vote(s) - 0 Average


3D Terrain Engine with Perlin Noise in Processing filter_list
Author
Message
RE: 3D Terrain Engine with Perlin Noise in Processing #2
(08-19-2016, 12:27 AM)Ao- Wrote: 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.

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]

Download Processing:
https://processing.org/download/?processing


That is really good. I like this!

Reply





Messages In This Thread
RE: 3D Terrain Engine with Perlin Noise in Processing - by Throwiee - 08-19-2016, 12:46 AM



Users browsing this thread: 1 Guest(s)