import processing.opengl.*; import processing.pdf.*; import toxi.geom.*; import unwrap.*; // unwrap Unwrap u; UTriangle[] t; // cameravector Vec3D cam = new Vec3D(0,0,0); //PDF PGraphicsPDF pdf; void setup() { size(screen.width, screen.height, OPENGL); // initialise PDF pdf = (PGraphicsPDF) createGraphics(width, height, PDF, "unwrapping.pdf"); // do first draw update(); } void update() { // initialise Unwrap u = new Unwrap(this); //////////////////// calculate Cylinder float degree, num, cosval, sinval, xr, yr; xr = 200; yr = 200; num = random(4,20); degree = radians(360 / num); //begin triangleStrip u.beginStrip(); for (int i = 0; i < num ; i++) { cosval = cos(degree * i); sinval = sin(degree * i); // add Points to Strip u.addPoint(cosval * xr, -yr, sinval * xr*random(2)); u.addPoint(cosval * xr, yr, sinval * xr*random(2)); } // end and close Strip u.endStrip(CLOSE); } void draw() { background(200); stroke(255); fill(200); lights(); // camera float d=frameCount; cam.x=sin(radians(d))*mouseX*4; cam.y=mouseY*4-height; cam.z=cos(radians(d))*mouseX*4; camera(cam.x,cam.y,cam.z,0,0,0,0,1,0); //////////////////// draw 3d u.draw3d(); u.drawNormals(); //////////////////// draw 2d camera(); noFill(); // get 2d Triangles t = u.t; //... and draw them twodimensional for(int i=0; i