Exporting 3D interactive sketch

jsrjsr
edited April 2016 in Questions about Code

Hi guys,

Im trying to (I know, ongoing question here..) export this sketch Im doing as movie. I did a bit of research and it seems the best way is to use the internal tool Processing has called MovieMaker, which just means rendering some pngs and have MovieMaker do the rest. Unfortunately when I write "saveFrame("frames/####.png");" my sketch just freezes and doesnt run properly.

I dont know if its an issue of too much data.. but I've seen many processing sketches online that look more robust than what Im doing, so Im a bit confused. Is it because Im using 3D? If anyone has any help I would really appreciate it.

Screen Shot 2016-04-07 at 5.19.10 PM

Uploaded an image, because every time I paste in the code it starts quoting some of it...

Tagged:

Answers

  • Code as an image is even worse than code formatted improperly.

    Post your code. As text. Select the code. Press Ctrl + o.

  • Thanks TfGuy44. Actually what would be worse, would be to post nothing at all, but thank you, your opinion is duly noted.

    float x, y;
    float a=0;
    
    
    PGraphics line;
    
    void setup() {
      size(2070, 1230, P3D);
    
      line = createGraphics(width, height, P3D);
    
      x=width;
      y=height;
    
    
    }
    
    
    
    void draw() {
    
    
      smooth(8);
      image(line, 0, 0);
    
      background(0);
      println (mouseX +"," + mouseY); 
      for (int i = 0; i < 120; i++) {
        for (int j = 0; j < 64; j++) {
    
          float lx = i*20;
          float ly = j*20;
    
          float dx = mouseX - lx; 
          float dy = mouseY - ly;
    
          a = atan2(dy, dx);
    
          lines(lx, ly, a);
    
          //saveFrame("frames/####.png");
    
        }
      }
    }
    
    
    
    
    void lines(float x, float y, float ang) {
    
      pushMatrix();
      translate(x, y, 500); 
      rotate(ang);
      stroke(255);
      strokeWeight(3);
    
      line(0, 0, 10, 10);
      popMatrix();
    
    
      noCursor();
    }
    
  • edited April 2016

    You have a bunch of extra variables that you don't use. You have a lot of code inside your for loops that need not be inside the for loops. This also includes your call to saveFrame(). Maybe you wanted it at the end of draw(), instead of inside your for loops?

    Here is the same code cleaned up a bit:

    void setup() {
      size(2070, 1230, P3D);
      noCursor();
      stroke(255);
      strokeWeight(3);
    }
    
    void draw() {
      background(0);
      //println (mouseX +"," + mouseY); 
      for (int i = 0; i < 120; i++) {
        for (int j = 0; j < 64; j++) {
    
          float lx = i*20;
          float ly = j*20;
    
          pushMatrix();
          translate(lx, ly, 500); 
          rotate( atan2(mouseY - ly, mouseX - lx) );
          line(0, 0, 10, 10);
          popMatrix();
        }
      }
      //saveFrame("frames/####.png");
    }
    
  • Thanks TfGuy44. Yes I had some leftover code from trying to troubleshoot the problem. But thank you that seemed to have fixed it! :)

Sign In or Register to comment.