Terrains, where to start?

edited April 2014 in How To...

Hello guys, i would like to dig into terrains. I need to start with something simple, using noise, low resolution terrains.

Where do you recommend me to start from?

Tagged:

Answers

  • Searching OpenProcessing.org

  • edited April 2014

    Here's a start. There's so many ways to improve on this. So. Many. Ways. So customize it towards what you want. Because what you're asking right now is pretty vague.

    void setup() {
      size(400, 400, P3D);
    }
    
    void draw() {
      background(0);
      translate(width/2, height/2);
      rotateY(map(mouseX, 0, width, -PI, PI));
      rotateX(map(mouseY, 0, height, -PI, PI));
      scale(150);
      noFill();
      stroke(255);
      box(1);
      for (float x = -.5; x < .5; x+=.1) {
        for (float y = -.5; y < .5; y+=.1) {
          pushMatrix();
          translate(0, 0, -.5);
          translate(x, y, noise(x+.5, y+.5));
          scale(.1);
          fill(255*noise(x+.5, y+.5));
          noStroke();
          box(1);
          popMatrix();
        }
      }
    }
    
  • this works better for me

    without line 13

    void setup() {
      size(400, 400, P3D);
    }
    
    void draw() {
      background(0);
      translate(width/2, height/2);
      rotateY(map(mouseX, 0, width, -PI, PI));
      rotateX(map(mouseY, 0, height, -PI, PI));
      scale(150);
      noFill();
      stroke(255);
      // box(1);
      for (float x = -.5; x < .5; x+=.1) {
        for (float y = -.5; y < .5; y+=.1) {
          pushMatrix();
          translate(0, 0, -.5);
          translate(x, y, noise(x+.5, y+.5));
          scale(.1);
          fill(255*noise(x+.5, y+.5));
          noStroke();
          box(1);
          popMatrix();
        }
      }
    }
    
  • edited April 2014

    thanks!! I looked at openprocessing.org, however since Java was updated it never worked as well as before (changing Secury level also).

    I've never thought about using boxes, that's looks good. I was also wondering about the classic terrain grid. This articule talks about the concepts.

    image alt text

  • A grid is just drawing lines from the centers of one box to the centers of the boxes next to it. That's one of the many improvements you could make.

    Of course, you could go with a surface too. That could be rendered with lots of triangles.

  • So should I use Delaunay triangulation for that purpose? I don't know where to start :/...

  • edited April 2014

    you could use the terrain class in the toxiclibs lib: http://toxiclibs.org/tag/terrain/ http://toxiclibs.org/docs/core/toxi/geom/mesh/Terrain.html

    this makes it pretty easy. all that is left is calculating height values. perlin noise is perfect for that.

    othr option: check out this demo code out of the generative design book: http://www.generative-gestaltung.de/M_1_4_01

  • @redraw, a few years ago I used that same article to make mountains in Processing. The results can be quite nice, especially with lights.

    I was going to send a link to it running in the browser but it seems like my browsers are not allowing Java… there are images of some results here, I was not going for realistic colors in most of them: http://alexsimes.com/index.php?foo=visual programming&amp;bar=fractal mountains

  • edited April 2014

    // deleted

  • @Chrisir, maybe make a new thread, otherwise I'd be happy to respond by email

  • Thanks a lot guys!

Sign In or Register to comment.