Advertisement
xeromino

3dthing

Apr 21st, 2017
468
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. VideoExport videoExport;
  8. PeasyCam cam;
  9. PGraphics pg;
  10. int counter;
  11. float r;
  12.  
  13. void setup() {
  14.   size(600, 600, P3D);
  15.  
  16.   pg = createGraphics(width, height);
  17.   pg.beginDraw();
  18.   pg.noStroke();
  19.   float maxW = width*2.0;
  20.   for (float w = maxW; w > 0; w -= 2) {
  21.     float f = map(w, maxW, 0, 0, 255);
  22.     pg.fill(f);
  23.     pg.ellipse(width/2, height/2, w, w);
  24.   }
  25.   pg.endDraw();
  26.  
  27.   videoExport = new VideoExport(this, "internetVideo.mp4");
  28.   videoExport.setFrameRate(30);
  29.   videoExport.setQuality(85, 128);
  30.   //videoExport.startMovie();
  31.  
  32.   cam = new PeasyCam(this, width/2, height/2, 0, 800);
  33.   cam.setMinimumDistance(50);
  34.   cam.setMaximumDistance(1000);
  35.  
  36.   frameRate(30);
  37. }
  38.  
  39. void draw() {
  40.   background(pg);
  41.   //lights();
  42.   //background(0);
  43.   strokeWeight(2);
  44.   stroke(0, 150);
  45.   colorMode(HSB, 360, 100, 100);
  46.   r = 150;
  47.   counter = 0;
  48.  
  49.   pushMatrix();
  50.   translate(width/2, height/2, 200);
  51.   rotateY(frameCount/50.0);
  52.   rotateX(frameCount/75.0);
  53.   rotateZ(frameCount/200.0);
  54.  
  55.   latitudes();
  56.  
  57.   colorMode(RGB, 255);
  58.   //videoExport.saveFrame();
  59. }
  60.  
  61. void keyPressed() {
  62.   if (key == 'q') {
  63.     videoExport.endMovie();
  64.     exit();
  65.   }
  66. }
  67.  
  68. void latitudes() {
  69.   float pR = map(sin(frameCount/50.0), -1, 1, 5, 10);
  70.   for (float p = -PI/2; p< PI/2; p += radians(pR)) {
  71.     if (counter%2==0) {
  72.       fill(255);
  73.     } else {
  74.       fill(255, 0, 0);
  75.     }
  76.     float h = map(p, -PI/2, PI/2, 80, 300);
  77.     fill(h, 100, 100, 150);
  78.     beginShape();
  79.     for (float t = 0; t < TWO_PI; t += radians(3)) {
  80.       float x = r * cos(p)*cos(t)*sin(2*p+t);
  81.       //float x = r * cos(p)*cos(t);
  82.       float y = r * cos(p)*sin(t);
  83.       float z = r*sin(p);
  84.       vertex(x, y, z);
  85.     }
  86.     endShape(CLOSE);
  87.     counter++;
  88.   }
  89.   popMatrix();
  90. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement