Hello,
I trying to create a sketch with both the Box2D for Processing and Video libraries.
I have some boxes moving around and colliding with each other, and I want to texture these boxes with some video. However, I get a very long error message as soon as I put in the line of code to tell processing which video file I want to use.
import processing.video.*;
import shiffman.box2d.*;
import org.jbox2d.collision.shapes.*;
import org.jbox2d.common.*;
import org.jbox2d.dynamics.*;
Box2DProcessing box2d;
int no_boxes = 7;
//All of our boxes
Box[] boxes = new Box[no_boxes];
//Boundry sides
Boundry[] boundry = new Boundry[4];
float angle = -PI/2;
float grav_rad = 30;
float boundr = 260;
float boundw = 30;
PVector direction = new PVector();
Movie mouth;
void setup() {
size(800,800,P3D);
frameRate(60);
colorMode(HSB,360,100,100);
noStroke();
//Load the movie
mouth = new Movie(this,"mouth1.mov");
mouth.play();
// Initialize box2d physics and create the world
box2d = new Box2DProcessing(this);
box2d.createWorld();
//Create the boxes
for (int n=0;n<no_boxes; n++) {
boxes[n] = new Box(random(200,600), random (200,600));
}
//Create the boundries
boundry[0] = new Boundry(400+boundr,400,boundw,2*boundr+boundw);
boundry[1] = new Boundry(400-boundr,400,boundw,2*boundr+boundw);
boundry[2] = new Boundry(400,400+boundr,2*boundr+boundw, boundw);
boundry[3] = new Boundry(400,400-boundr,2*boundr+boundw, boundw);
}
void movieEvent (Movie m) {
m.read();
}
void draw() {
background(200,50,80);
image(mouth,0,0);
angle+= radians(0.3);
direction.x = grav_rad*cos(angle);
direction.y = grav_rad*sin(angle);
box2d.setGravity(-direction.x, direction.y);
camera(width/2.0, height/2.0, (height/2.0) / tan(PI*30.0 / 180.0), width/2.0, height/2.0, 0, 0-map(direction.x,-10,10,-1,1), 0-map(direction.y,-10,10,-1,1), 0); //x, y, z -> need to change between x and y
box2d.step();
// Display all the boxes
for (Box b: boxes) {
b.display();
}
//display the boundries
boundry[0].display();
boundry[1].display();
boundry[2].display();
boundry[3].display();
}
Here is the error message I get:
finishLifecycleAction(com.jogamp.opengl.util.FPSAnimator$3): ++++++ timeout reached ++++++ main-FPSAWTAnimator#00-Timer0
finishLifecycleAction(com.jogamp.opengl.util.FPSAnimator$3): OK false- pollPeriod 6, blocking true -> res false, waited 1002/1000 - main-FPSAWTAnimator#00-Timer0
- com.jogamp.opengl.util.FPSAnimator[started true, animating true, paused false, drawable 1, totals[dt 0, frames 0, fps 0.0], modeBits 1, init’ed true, animThread Thread[main-FPSAWTAnimator#00-Timer0-FPSAWTAnimator#00-Timer1,5,main], exclCtxThread false(null)]
[2]: com.jogamp.opengl.util.AnimatorBase.finishLifecycleAction(AnimatorBase.java:634)
[3]: com.jogamp.opengl.util.FPSAnimator.stop(FPSAnimator.java:326)
[4]: processing.opengl.PSurfaceJOGL.stopThread(PSurfaceJOGL.java:722)
[5]: processing.core.PApplet.dispose(PApplet.java:3830)
[6]: processing.core.PApplet.die(PApplet.java:3741)
[7]: processing.core.PApplet.die(PApplet.java:3751)
[8]: processing.video.Movie.initGStreamer(Unknown Source)
[9]: processing.video.Movie.(Unknown Source)
[10]: Rotating_mouth_boxes_100620.setup(Rotating_mouth_boxes_100620.java:58)
[11]: processing.core.PApplet.handleDraw(PApplet.java:2432)
[12]: processing.opengl.PSurfaceJOGL$DrawListener.display(PSurfaceJOGL.java:866)
[13]: jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692)
[14]: jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674)
[15]: jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:443)
[16]: jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
[17]: jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
[18]: com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:782)
[19]: com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81)
[20]: com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:453)
[21]: com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178)
[22]: java.util.TimerThread.mainLoop(Timer.java:555)
[23]: java.util.TimerThread.run(Timer.java:505)
Any ideas? I have successfully used both Box2D and video separately, but something about having them in the same sketch seems to be an issue.