import processing.opengl.*; int numPoints=10; //number of points in the container int currentSelection=0; // simple arrays to store the properties of the points PVector[] points=new PVector[numPoints];// PVector[] vels=new PVector[numPoints]; HE_Mesh container; // coordinates of the containervertices float[][] containerVertices; // simple face array for the container. Each subarray contains the indices of the vertices. int[][] containerFaces; float bufferMouseX, bufferMouseY; //half-edge mesh, one for each voronoi cell HE_Mesh[] voronoiCells=new HE_Mesh[numPoints]; PVector[] centers=new PVector[numPoints]; //representation of a plane, used to cut the mesh Plane P=new Plane(new PVector(0,0,0),new PVector(0,1,0)); //size of box int S=500; void setup(){ size(800,800,OPENGL); background(255); //smooth(); hint(ENABLE_OPENGL_4X_SMOOTH); initializePoints(); buildContainer(); buildVoronoi(); } void draw(){ background(255); lights(); drawVoronoiBox(); updatePoints(); buildVoronoi(); } void initializePoints(){ for (int i=0;iS){ points[i].x=2*S-points[i].x; vels[i].x*=-1; } if(points[i].y>S){ points[i].y=2*S-points[i].y; vels[i].y*=-1; } if(points[i].z>S){ points[i].z=2*S-points[i].z; vels[i].z*=-1; } } } void mouseClicked(){ initializePoints(); buildVoronoi(); } void keyPressed(){ currentSelection++; if(currentSelection==numPoints) currentSelection=0; }