Advertisement
xeromino

circleCubes

Sep 8th, 2017
248
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import com.hamoid.*;
  2.  
  3. import peasy.*;
  4. import peasy.org.apache.commons.math.*;
  5. import peasy.org.apache.commons.math.geometry.*;
  6.  
  7. int frms = 180;
  8. float sz = 20;
  9. float theta = 0, ns, nx, ny, nz;
  10. color bg, f;
  11.  
  12. PeasyCam cam;
  13. VideoExport videoExport;
  14.  
  15. void setup() {
  16.   size(1080, 720, P3D);
  17.   smooth(8);
  18.   background(0);
  19.   colorMode(HSB, 360, 100, 100);
  20.   f = #222222;
  21.   bg = #eeeeee;
  22.  
  23.   cam = new PeasyCam(this, width/2, height/2, 0, 1300);
  24.   cam.setMinimumDistance(50);
  25.   cam.setMaximumDistance(1500);
  26.   ///*
  27.   videoExport = new VideoExport(this, "internetVideo.mp4");
  28.   videoExport.setFrameRate(45);
  29.   videoExport.setQuality(85, 128);
  30.   videoExport.startMovie();
  31.   //*/
  32.   frameRate(45);
  33. }
  34.  
  35. void draw() {
  36.   background(bg);
  37.   randomSeed(1234);
  38.   lights();
  39.   translate(width/2, height/2);
  40.  
  41.   cubeCircle(50, width/2, 1, 3);
  42.   cubeCircle(30, width/4, -1, 2);
  43.  
  44.   videoExport.saveFrame();
  45.   //if (frameCount<=frms) saveFrame("image-####.gif");
  46.  
  47.   theta += TWO_PI/frms;
  48. }
  49.  
  50. void cubeCircle(int num, int d, int dir, int r) {
  51.   if (dir == 1) {
  52.     rotateY(frameCount/100.0);
  53.   } else {
  54.     rotateX(frameCount/100.0);
  55.   }
  56.   for (int i=0; i<num; i++) {
  57.     float angle = TWO_PI/num*i;
  58.     float x = cos(angle)*d;
  59.     float y = sin(angle)*d;
  60.     sz = map(sin(angle*r+theta), -1, 1, 25, 75);
  61.     pushMatrix();
  62.     translate(x, y, 0);
  63.     //rotate(theta+angle*dir);
  64.     rotateX(frameCount/100.0+angle*dir);
  65.     rotateY(frameCount/100.0-angle*dir);
  66.     fill(f);
  67.     if (random(1)>.8) fill(#E14C45);
  68.     stroke(bg);
  69.     box(sz);
  70.     popMatrix();
  71.   }
  72. }
  73.  
  74. void keyPressed() {
  75.   if (key == 'q') {
  76.     videoExport.endMovie();
  77.     exit();
  78.   }
  79. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement