We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
flockmovie (Read 407 times)
flockmovie
Jul 12th, 2008, 1:19am
 
Hi

Working on a patch to capture QT movie of this flocking mod.
But keep getting this error -
quicktime.std.StdQTException[QTJava:7.4.5g],-2014=invalidDuration,QT.vers:7458000
at quicktime.std.StdQTException.checkError(StdQTException.java:38)

any ideas please let me know
mark p
Below is the code -

// flock array with movie record
import processing.video.*;

MovieMaker mm;

PImage b;
int birdCount = 20;
Bird[]birds = new Bird[birdCount];
float[]x = new float[birdCount];
float[]y = new float[birdCount];
float[]z = new float[birdCount];
float[]rx = new float[birdCount];
float[]ry = new float[birdCount];
float[]rz = new float[birdCount];
float[]spd = new float[birdCount];
float[]rot = new float[birdCount];

void setup(){
 size(500, 500, P3D);
 noStroke();
 
   // Save uncompressed, at 15 frames per second
 mm = new MovieMaker(this, width, height, "flock.mov");

 //initialize arrays with random values
 for (int i=0; i<birdCount; i++){
   birds[i] = new Bird(random(-100, 300), random(-30, 30),
   random (-500, -250), random(5, 30), random(5, 30));

   birds[i].setColor(color(random(25), random(25), random(255)),
   color(random(255), random(255), random(355)));

   x[i] = random(200, 340);
   y[i] = random(30, 350);
   z[i] = random(100, 4800);
   rx[i] = random(-160, 16);
   ry[i] = random(-55, 55);
   rz[i] = random(-20, 20);
   spd[i] = random(.2, 3.75);
   rot[i] = random(.25, .15);
 }
}

void draw(){
 background(1);
 lights();
 spotLight(20, 302, 226, 80, 20, 40, -5, 0, 0, PI/4, 2);
 translate(10, 10, 0);

ambient(51, 26, 0);
 




 for (int i=0; i<birdCount; i++){
   birds[i].setFlight(x[i], y[i], z[i], rx[i], ry[i], rz[i]);
   birds[i].setWingSpeed(spd[i]);
   birds[i].setRotSpeed(rot[i]);
   birds[i].fly();
 }
}

class Bird{
 // properties
 float offsetX, offsetY, offsetZ;
 float w, h;
 int bodyFill;
 int wingFill;
 float ang = 1, ang2 = 20, ang3 = 20, ang4 = 0;
 float radiusX = 12, radiusY = 12, radiusZ = 120;
 float rotX = 1, rotY = 1, rotZ = 5;
 float flapSpeed = 1;
 float rotSpeed = .1;

 // constructors
 Bird(){
   this(0, 67, 12, 60, 80);
 }

 Bird(float offsetX, float offsetY, float offsetZ,
 float w, float h){
   this.offsetX = offsetX;
   this.offsetY = offsetY;
   this.offsetZ = offsetZ;
   this.h=h;
   this.w=w;
   bodyFill = color(50, 100, 10);
   wingFill = color(10, 200, 20);
 }

 // methods
 void setColor(int bodyFill, int wingFill){
   this.bodyFill=bodyFill;
   this.wingFill=wingFill;
 }

 void setFlight(float radiusX, float radiusY, float radiusZ,
 float rotX, float rotY, float rotZ){
   this.radiusX = radiusX;
   this.radiusY = radiusY;
   this.radiusZ = radiusZ;

   this.rotX = rotX;
   this.rotY = rotY;
   this.rotZ = rotY;
 }

 void setWingSpeed(float flapSpeed){
   this.flapSpeed = flapSpeed;
 }

 void setRotSpeed(float rotSpeed){
   this.rotSpeed = rotSpeed;
 }

 void fly(){
   pushMatrix();
   float px, py, pz;
   fill(bodyFill);
   //flight
   px = sin(radians(ang3))*radiusX;
   py = cos(radians(ang3))*radiusY;
   pz = sin(radians(ang3))*radiusZ;
   //
   translate(width/2+offsetX+px, height/2+offsetY+py,
   -30+offsetZ+pz);

   rotateX(sin(radians(ang2))*rotX);
   rotateY(sin(radians(ang2))*rotY);
   rotateZ(sin(radians(ang3))*rotZ);

   //body
   box(w*2000, h, w*1);

   fill(wingFill);
   //left wing
   pushMatrix();
   rotateY(sin(radians(ang))*200);
   rect(0, -h/2, w, h);
   popMatrix();

   //right wing
   pushMatrix();
   rotateY(sin(radians(ang))*-20);
   rect(-w, -h/2, w, h);
   popMatrix();

   // wing flap
   ang+=flapSpeed;
   if (ang>2){
     flapSpeed*=-1;
   }
   if (ang<-3){
     flapSpeed*=7;
   }

   // ang's run trig functions
   ang2+=.78;
   ang3+=.78;
   ang4+=.78;
   popMatrix();
 }
}

void keyPressed() {
 if (key == ' ') {
   // Finish the movie if space bar is pressed
   mm.finish();
   // Quit running the sketch once the file is written
   exit();
 }
}

Page Index Toggle Pages: 1