Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int cols;
- int rows;
- int scale;
- int h = 3000;
- int w = 2000;
- float[][] terrain;
- float flying= -7; //Determines move speed (use positive values to move backwards)
- float roughness = 150; //Determines gradient of randomness
- float peak = -1; //Determines height of terrain peaks (use values 0<peak<1 to lower)
- void setup(){
- size(1000, 1000, P3D);
- translate(width/2, height/2);
- scale = 20;
- cols = w/scale;
- rows = h/scale;
- }
- void draw(){
- if (flying > 0){
- flying += .05;
- }
- else if (flying < 0){
- flying -= .05;
- }
- lights();
- terrain = new float [cols][rows];
- 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, -roughness, roughness)*peak;
- xOff += .1;
- }
- yOff += .1;
- }
- background(0);
- translate(width/2, height/2);
- rotateX(PI/3);
- translate(-width/2 - 300, -height/2);
- for(int y=0; y<rows - 1; y++){
- beginShape(TRIANGLE_STRIP);
- for(int x=0; x<cols; x++){
- //noFill();
- //stroke(255);
- fill(55);
- noStroke();
- vertex(x*scale, y*scale, terrain[x][y]);
- vertex(x*scale, (y+1)*scale, terrain[x][y+1]);
- }
- endShape();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement