|
本帖最后由 panhao1 于 2011-3-4 15:32 编辑
如果一种工具能简单到这种地步 那么它就是这个hull工具了
案例也在里面 我稍稍改了下 貌似确实很好用
PeasyCam cam;
QuickHull3D hull;
Random rnd=new Random();
public void setup(){
size(600,400,OPENGL);
cam = new PeasyCam(this, 200);
cam.setMinimumDistance(50);
cam.setMaximumDistance(5000);
}
public void draw(){
background(100);
stroke(0,0,200);
fill(255, 102);
Point3d[] points = new Point3d[]
{ new Point3d (0.0, 0.0, 0.0),
new Point3d (1.0, 0.5, 0.0),
new Point3d (2.0, 0.0, 0.0),
new Point3d (0.5, 0.5, 0.5),
new Point3d (0.0, 0.0, 2.0),
new Point3d (0.1, 0.2, 0.3),
new Point3d (0.0, 2.0, 0.0),
};
hull = new QuickHull3D();
hull.build (points);
scale(100);
Point3d[] vertices = hull.getVertices();
int[][] faceIndices = hull.getFaces();
for (int i = 0; i < vertices.length; i++)
{
beginShape();
for (int k = 0; k < faceIndices.length; k++){
vertex((float)vertices[faceIndices[k]].x, (float)vertices[faceIndices[k]].y,(float)vertices[faceIndices[k]].z);
}
endShape(CLOSE);
}
}
//////////////////////////////////////////////////// |
|