Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import wblut.processing.*;
- import wblut.geom.*;
- import java.util.List;
- List<WB_Point> points;
- WB_Polygon boundary0,boundary1,boundary2,boundary3;
- List<WB_VoronoiCell2D> voronoiXY0,voronoiXY1,voronoiXY2,voronoiXY3;
- List<WB_Mesh> columns0,columns1,columns2,columns3;
- WB_Render3D render;
- WB_GeometryFactory gf=WB_GeometryFactory.instance();
- float t=1;
- void setup() {
- size(800, 600, P3D);
- smooth(8);
- render= new WB_Render3D(this);
- points=new ArrayList<WB_Point>();
- // add points to collection
- for (int i=0; i<100; i++) {
- for (int j=0; j<100; j++) {
- points.add(new WB_Point(-1000+i*40, -1000+j*40, 0));
- }
- }
- createBoundaryPolygon0();
- voronoiXY0= WB_Voronoi.getClippedVoronoi2D(points, boundary0, 4);
- columns0=new ArrayList<WB_Mesh>();
- for (WB_VoronoiCell2D vor : voronoiXY0) {
- columns0.add(gf.createPrism(vor.getPolygon(),random(500,700)));
- }
- createBoundaryPolygon1();
- voronoiXY1= WB_Voronoi.getClippedVoronoi2D(points, boundary1, 4);
- columns1=new ArrayList<WB_Mesh>();
- for (WB_VoronoiCell2D vor : voronoiXY1) {
- columns1.add(gf.createPrism(vor.getPolygon(),random(50,500)));
- }
- createBoundaryPolygon2();
- voronoiXY2= WB_Voronoi.getClippedVoronoi2D(points, boundary2, 4);
- columns2=new ArrayList<WB_Mesh>();
- for (WB_VoronoiCell2D vor : voronoiXY2) {
- columns2.add(gf.createPrism(vor.getPolygon(),random(30,250)));
- }
- createBoundaryPolygon3();
- voronoiXY3= WB_Voronoi.getClippedVoronoi2D(points, boundary3, 4);
- columns3=new ArrayList<WB_Mesh>();
- for (WB_VoronoiCell2D vor : voronoiXY3) {
- columns3.add(gf.createPrism(vor.getPolygon(),random(10,120)));
- }
- }
- void draw() {
- background(20);
- directionalLight(255, 255, 255, 1, 1, -1);
- directionalLight(127, 127, 127, 1, -1, 1);
- translate(400, 400, -1000);
- fill(0);
- rotateY(t);
- t = t+0.005;
- scale(t);
- rotateX(PI/2);
- translate(0, 0, -200);
- noFill();
- stroke(0);
- strokeWeight(1);
- /* for (WB_Mesh mesh : columns) {
- render.drawMeshEdges(mesh);
- */
- noStroke();
- fill(255);
- for (WB_Mesh mesh : columns0) {
- render.drawMeshFaces(mesh);
- }
- for (WB_Mesh mesh : columns1) {
- render.drawMeshFaces(mesh);
- }
- for (WB_Mesh mesh : columns2) {
- render.drawMeshFaces(mesh);
- }
- for (WB_Mesh mesh : columns3) {
- render.drawMeshFaces(mesh);
- }
- saveFrame("frames/####.tif");
- }
- void createBoundaryPolygon0(){
- ArrayList<WB_Point> shell0;
- shell0= new ArrayList<WB_Point>();
- for (int i=0; i<6; i++) {
- shell0.add(gf.createPointFromPolar(50, TWO_PI/6*i));
- }
- //holes and points cannot overlap
- ArrayList<WB_Point> hole0=new ArrayList<WB_Point>();
- for (int i=0; i<6; i++) {
- hole0.add(gf.createPointFromPolar(3, TWO_PI/6*i).addSelf(0, 0, 0));
- }
- boundary0=gf.createPolygonWithHole(shell0, hole0);
- }
- void createBoundaryPolygon1(){
- ArrayList<WB_Point> shell;
- shell= new ArrayList<WB_Point>();
- for (int i=0; i<6; i++) {
- shell.add(gf.createPointFromPolar(200, TWO_PI/6*i));
- }
- //holes and points cannot overlap
- ArrayList<WB_Point> hole=new ArrayList<WB_Point>();
- for (int i=0; i<6; i++) {
- hole.add(gf.createPointFromPolar(50, TWO_PI/6*i).addSelf(0, 0, 0));
- }
- boundary1=gf.createPolygonWithHole(shell, hole);
- }
- void createBoundaryPolygon2(){
- ArrayList<WB_Point> shell2;
- shell2= new ArrayList<WB_Point>();
- for (int i=0; i<8; i++) {
- shell2.add(gf.createPointFromPolar(400, TWO_PI/8*i));
- }
- //holes and points cannot overlap
- ArrayList<WB_Point> hole2=new ArrayList<WB_Point>();
- for (int i=0; i<6; i++) {
- hole2.add(gf.createPointFromPolar(200, TWO_PI/6*i).addSelf(0, 0, 0));
- }
- boundary2=gf.createPolygonWithHole(shell2, hole2);
- }
- void createBoundaryPolygon3(){
- ArrayList<WB_Point> shell3;
- shell3= new ArrayList<WB_Point>();
- for (int i=0; i<18; i++) {
- shell3.add(gf.createPointFromPolar(800, TWO_PI/18*i));
- }
- //holes and points cannot overlap
- ArrayList<WB_Point> hole3=new ArrayList<WB_Point>();
- for (int i=0; i<6; i++) {
- hole3.add(gf.createPointFromPolar(400, TWO_PI/6*i).addSelf(0, 0, 0));
- }
- boundary3=gf.createPolygonWithHole(shell3, hole3);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement