HE_Mesh Voronoi Example from share & tell Null Pointer Exception
HEMC_VoronoiCells: creating cell 1 of 50.
HEMC_VoronoiCells: creating cell 2 of 50.
Exception in thread "Animation Thread" java.lang.NullPointerException
at wblut.geom.triangulate.Triangulation.splitEdge(Triangulation.java:942)
at wblut.geom.triangulate.Triangulation.addInteriorPoint(Triangulation.java:653)
at wblut.hemesh.modifiers.HEM_Slice.apply(HEM_Slice.java:239)
at wblut.hemesh.modifiers.HEM_MultiSlice.apply(HEM_MultiSlice.java:234)
at wblut.hemesh.core.HE_Mesh.modify(HE_Mesh.java:114)
at wblut.hemesh.creators.HEC_VoronoiCell.createBase(HEC_VoronoiCell.java:278)
at wblut.hemesh.creators.HEMC_VoronoiCells.create(HEMC_VoronoiCells.java:294)
at vronoi1.Vronoi1.setup(Vronoi1.java:74)
at processing.core.PApplet.handleDraw(PApplet.java:1608)
at processing.core.PApplet.run(PApplet.java:1530)
at java.lang.Thread.run(Thread.java:680)
- package vronoi1;
- import java.util.ArrayList;
- import processing.core.PApplet;
- import wblut.core.processing.WB_Render;
- import wblut.geom.core.WB_Point3d;
- import wblut.hemesh.core.HE_Mesh;
- import wblut.hemesh.creators.HEC_Grid;
- import wblut.hemesh.creators.HEC_SuperDuper;
- import wblut.hemesh.creators.HEC_Tube;
- import wblut.hemesh.creators.HEMC_VoronoiCells;
- import wblut.hemesh.modifiers.HEM_Lattice;
- import wblut.hemesh.subdividors.HES_CatmullClark;
- public class Vronoi1 extends PApplet {
- WB_Render myRender;
- ArrayList<HE_Mesh> meshes;
- HE_Mesh[] cells;
- HE_Mesh[] tmpMesh;
- WB_Point3d points[];
- int numX;
- int numY;
- HE_Mesh myMesh;
- HEMC_VoronoiCells myVoronoi;
- public void setup() {
- size(1024, 768, OPENGL);
- myMesh=new HE_Mesh(new HEC_Grid().setU(1).setV(1).setUSize(900).setVSize(400).setCenter(250,0,0));
- numX=10;
- numY=5;
- points=new WB_Point3d[numX*numY];
- int index = 0;
- for(int i=0;i<numX;i++) {
- for(int j=0;j<numY;j++) {
- double delta=(j%2==0) ? 0 : 25;
- points[i+numX*j]=new WB_Point3d(-237.5+delta+i*50, -195+j*50*Math.cos(Math.PI/6), 0);
- index ++;
- }
- }
- println(points);
- myVoronoi = new HEMC_VoronoiCells().setContainer(myMesh).setPoints(points);
- meshes =new ArrayList<HE_Mesh>();
- HE_Mesh[] tempMesh = myVoronoi.create();
- // int nom=myVoronoi.numberOfMeshes();
- // for(int i=0;i<nom;i++) {
- // tmpMesh[i].resetCenter();
- // meshes.add(tmpMesh[i]);
- // }
- myRender = new WB_Render(this);
- }
- public void update() {
- }
- public void predraw() {
- }
- public void clean() {
- points=null;
- meshes=null;
- myMesh=null;
- }
- public void draw() {
- background(255);
- translate(width/2, height/2, -300);
- //view Rotate
- rotateY(mouseX*1.0f/width*TWO_PI);
- rotateX(mouseY*1.0f/height*TWO_PI);
- // for (int i = 0; i < tmpMesh.length; i++) {
- // myRender.drawEdges(tmpMesh[i]);
- // }
- // myRender.drawFaces(meshes);
- // myRender.drawFaces(myMesh);
- // myRender.drawFaces(myMesh);
- }
- }