Sinisterly
3D Terrain Engine with Perlin Noise in Processing - Printable Version

+- Sinisterly (https://sinister.ly)
+-- Forum: Coding (https://sinister.ly/Forum-Coding)
+--- Forum: Java, JVM, & JRE (https://sinister.ly/Forum-Java-JVM-JRE)
+--- Thread: 3D Terrain Engine with Perlin Noise in Processing (/Thread-3D-Terrain-Engine-with-Perlin-Noise-in-Processing)



3D Terrain Engine with Perlin Noise in Processing - Inori - 08-19-2016

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


RE: 3D Terrain Engine with Perlin Noise in Processing - Throwiee - 08-19-2016

(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!


RE: 3D Terrain Engine with Perlin Noise in Processing - Wildfire - 08-19-2016

I can't even tell if you're being sarcastic or not Tongue
It is really interesting that you managed 3D in Java though, that kind of stuff has always scared me away.


RE: 3D Terrain Engine with Perlin Noise in Processing - Inori - 08-19-2016

(08-19-2016, 01:33 AM)Axi Wrote: I can't even tell if you're being sarcastic or not Tongue
It is really interesting that you managed 3D in Java though, that kind of stuff has always scared me away.

I normally abhor Java, but I love Processing.