Issue when using Box2D and video libraries together


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 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() {
  //Load the movie
  mouth = new Movie(this,"");;
  // Initialize box2d physics and create the world
  box2d = new Box2DProcessing(this);
  //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) {;

void draw() {
  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

  // Display all the boxes
  for (Box b: boxes) {

  //display the boundries


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(
    [3]: com.jogamp.opengl.util.FPSAnimator.stop(
    [4]: processing.opengl.PSurfaceJOGL.stopThread(
    [5]: processing.core.PApplet.dispose(
    [6]: processing.core.PApplet.die(
    [7]: processing.core.PApplet.die(
    [8]: Source)
    [9]: Source)
    [10]: Rotating_mouth_boxes_100620.setup(
    [11]: processing.core.PApplet.handleDraw(
    [12]: processing.opengl.PSurfaceJOGL$DrawListener.display(
    [13]: jogamp.opengl.GLDrawableHelper.displayImpl(
    [14]: jogamp.opengl.GLDrawableHelper.display(
    [15]: jogamp.opengl.GLAutoDrawableBase$
    [16]: jogamp.opengl.GLDrawableHelper.invokeGLImpl(
    [17]: jogamp.opengl.GLDrawableHelper.invokeGL(
    [18]: com.jogamp.newt.opengl.GLWindow.display(
    [19]: com.jogamp.opengl.util.AWTAnimatorImpl.display(
    [20]: com.jogamp.opengl.util.AnimatorBase.display(
    [21]: com.jogamp.opengl.util.FPSAnimator$
    [22]: java.util.TimerThread.mainLoop(

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.

1 Like

Perhaps one of these past issues will be relevant?