mesh from a grid of vertices?

I'm taking in an image via Syphon and simply using the brightness of the image/frame as the Z value for that pixel. So you end up with a bunch of points in 3d space from the 2d image. However, I'd like to make this into a mesh so that it's one contiguous shape, with each vertex colored correctly.

beginShape(TRIANGLE_STRIP);

  for (int y = 0; y < img.height; y+=skip) {
    for (int x = 0; x < img.width; x+=skip) {
      int index = y * img.width + x;

      color c = img.pixels[index];
      float b = brightness(c);

      // smoothing
      pZ[index] = (b * .05) + (lastPZ[index] * .95);
      lastPZ[index] = pZ[index];

      stroke(c);
      fill(c);
      vertex(x, y, -100 + pZ[index]);

    }
  }

  endShape();

Something like that, except of course TRIANGLE_STRIP isn't going to work here. I need something that will figure out which vertices ought to be connected.

Answers

Sign In or Register to comment.