Terrain to Mesh3D with Toxiclibs

Hi all,

I extracted a part of this code: http://www.openprocessing.org/sketch/8880 I just want to get the terrain with peasycam. Somehow, I get the following error: "cannot convert from Mesh3D to TriangleMesh". I checked the toxiclibs references and everything seems ok. I don't know what I did wrong.

Thank you for your help,

Roger

import toxi.geom.*;
import toxi.geom.mesh.*;
import toxi.math.*;
import toxi.processing.*;
//ControlP5
import java.awt.Frame;
import java.awt.BorderLayout;
import controlP5.*;
//PeasyCam
import peasy.org.apache.commons.math.*;
import peasy.*;
import peasy.org.apache.commons.math.geometry.*;
PeasyCam cam;
float NOISE_SCALE = 0.08f;
int DIM=80;

Terrain terrain;
ToxiclibsSupport gfx;
TriangleMesh mesh;


void setup() {
  size(680,382, P3D);
  cam = new PeasyCam(this, 700);
  // create terrain & generate elevation data
  terrain = new Terrain(DIM,DIM, 50);
  float[] el = new float[DIM*DIM];
  noiseSeed(23);
  for (int z = 0, i = 0; z < DIM; z++) {
    for (int x = 0; x < DIM; x++) {
      el[i++] = noise(x * NOISE_SCALE, z * NOISE_SCALE) * 400;
    }
  }
  terrain.setElevation(el);

  mesh = terrain.toMesh(0);
  gfx = new ToxiclibsSupport(this);
}

void draw() {


  directionalLight(192, 160, 128, 0, -1000, -0.5f);
  directionalLight(255, 64, 0, 0.5f, -0.1f, 0.5f);
  fill(255);
  noStroke();
  // draw mesh & car
  gfx.mesh(mesh, false);

}
Tagged:

Answers

Sign In or Register to comment.