There is a library to create 2D iso contour meshes
http://www.thecloudlab.org/processing/library.html I took the IsoContour class and modified to draw the mesh using GLModel so I can render with a higher resolution grid, I got it all working but I get some extra vertices always on the right side

The extra vertices dont appear randomly, they stay there after the originals were draw in that location, and them they dissapear when the mesh grows, is like residual vertices, not sure is hard to explain, but note that If I draw the mesh using begin/endShape works fine no residual vertices at all.

**Here is the relevant code**

In the setup:

- // Setup fluid mesh
- final int NUM_VERTICES = 20000;
- fluid = new GLModel( this, NUM_VERTICES, GLGraphics.TRIANGLES , GLModel.STREAM );
- fluid.initColors();
- fluid.beginUpdateColors();
- for (int i = 0; i < NUM_VERTICES; i++) fluid.updateColor(i, 50, 170, 190, 255);
- fluid.endUpdateColors();

In the draw:

- // Update fluid vertices
- fluid.beginUpdateVertices();
- for ( int i = 0; i < iso.numVertices; i++) {
- PVector pos = (PVector)iso.vertexPositions.get(i);
- fluid.updateVertex( i, pos.x, pos.y, 0 );
- }
- fluid.endUpdateVertices();

In side a push/pop matrix block this:

- if ( isDrawingGLModel ) {
- GLGraphics renderer = (GLGraphics)g;
- renderer.beginGL();
- //renderer.model( fluid );
- fluid.render( 0, iso.numVertices );
- renderer.endGL();
- }
- else {
- stroke( 50, 170, 190 );
- beginShape( TRIANGLES );
- for ( int i = 0; i < iso.numVertices; i++) {
- PVector pos = (PVector)iso.vertexPositions.get(i);
- vertex( pos.x, pos.y );
- }
- endShape();
- }

Thanks

1