Recently I've been looking at Povray, pyprocessing, and cfdg (version 3.0) as tools for creating digital images. I have branched two separate blogs where I mainly explore jruby + processing and processing.py

Thursday, 25 April 2013

Updating My MeshToVBO library (for hemesh-1.8.1 and processing-2.0b8)

I have recently updated my MeshToVBO library here. Since githubs change of policy (to not support binary downloads) it is only available as source (so when building you will need to include dependent jars from processing and hemesh, this is best done in an ide eg Eclipse or Netbeans, I will endeavour to write an ant build file). Here is an example displaying library usage (based on a hemesh example sketch).
   1 import mshape.util.*;
   2 import mshape.*;
   3 import wblut.math.*;
   4 import wblut.processing.*;
   5 import wblut.core.*;
   6 import wblut.hemesh.*;
   7 import wblut.geom.*;
   8 
   9 PShape retainedMesh;
  10 ArcBall arcball;   
  11 MeshToVBO mshape;
  12 HE_Mesh mesh;
  13 HEC_IsoSurface creator;
  14 
  15 void setup() {
  16   size(800, 800, P3D);
  17   arcball = new ArcBall(this);
  18   mshape = new MeshToVBO(this);  
  19   smooth(16);
  20 
  21   // Create an isosurface from an explicit grid of values.
  22   // Potentially uses a lot of memory.
  23 
  24   float[][][] values=new float[51][51][51];
  25   for (int i = 0; i < 51; i++) {
  26     for (int j = 0; j < 51; j++) {
  27       for (int k = 0; k < 51; k++) {
  28         values[i][j][k]=2.1*noise(0.07*i, 0.07*j, 0.07*k);
  29       }
  30     }
  31   }
  32 
  33   creator = new HEC_IsoSurface();
  34   creator.setResolution(50, 50, 50);// number of cells in x,y,z direction
  35   creator.setSize(8, 8, 8);// cell size
  36   creator.setValues(values);// values corresponding to the grid points
  37   // values can also be double[][][]
  38   creator.setIsolevel(1);// isolevel to mesh
  39   creator.setInvert(false);// invert mesh
  40   //creator.setBoundary(100);// value of isoFunction outside grid
  41   // use creator.clearBoundary() to rest boundary values to "no value".
  42   // A boundary value of "no value" results in an open mesh
  43 
  44   mesh = new HE_Mesh(creator);
  45   noStroke();
  46   // stainless steel
  47   retainedMesh = mshape.meshToRetained(mesh, color(224, 223, 219));
  48 }
  49 
  50 
  51 void draw() {
  52   background(100);
  53   lights();
  54   lightSpecular(80, 80, 80);
  55   directionalLight(80, 80, 80, 0, 0, -1);
  56   ambientLight(50, 50, 50);
  57   translate(400, 400, 0);
  58   arcball.update();
  59   shape(retainedMesh);
  60 }

No comments:

Post a Comment

Followers

Blog Archive

About Me

My photo
Pembrokeshire, United Kingdom
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2