Advertisement
xeromino

3dbox

Apr 28th, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.75 KB | None | 0 0
  1. PGraphics cube;
  2. float theta;
  3. int frames = 300;
  4.  
  5. void setup() {
  6.   size(500, 500, P3D);
  7.   cube = createGraphics(100, 100, P3D);
  8. }
  9.  
  10. void draw() {
  11.   background(0);
  12.   drawCube();
  13.   for (int x=0; x<width; x+=cube.width) {
  14.     for (int y=0; y<height; y+=cube.height) {
  15.       image(cube, x, y);
  16.     }
  17.   }
  18.   if (frameCount<=frames) saveFrame("image-###.gif");
  19. }
  20.  
  21. void drawCube() {
  22.   cube.beginDraw();
  23.   cube.lights();
  24.   cube.background(0);
  25.   cube.noStroke();
  26.   cube.pushMatrix();
  27.   cube.translate(cube.width/2, cube.height/2);
  28.   //cube.rotateX(frameCount/100.0);
  29.   //cube.rotateY(frameCount/200.0);
  30.   cube.rotateX(theta*2);
  31.   cube.rotateY(theta*1);
  32.   cube.box(cube.width/2);
  33.   cube.popMatrix();
  34.   cube.endDraw();
  35.   theta += TWO_PI/frames;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement