Login Register






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


3D Terrain Engine with Perlin Noise in Processing filter_list
Author
Message
3D Terrain Engine with Perlin Noise in Processing #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.

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
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.

[+] 1 user Likes Inori's post
Reply

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

RE: 3D Terrain Engine with Perlin Noise in Processing #3
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.

Reply

RE: 3D Terrain Engine with Perlin Noise in Processing #4
(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.
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.

Reply







Users browsing this thread: 1 Guest(s)