Can I set a video as my background();

Hello,

Here is what I;m trying to do. I would like to set a looping video as my background() image in my processing sketch. Then I want to import an OBJ and be able to rotate it in 3D space with my mouse. What I have so far is the video and the OBJ in the sketch but both acting as one piece. Here is my code so far. Any ideas?

import peasy.*; import processing.video.*;

PShape s;

String PATH = "/Users/brendanwilson/Desktop/Vidoe_Processing/video/data/comp.mov"; Movie mov;

PeasyCam cam;

void setup() { size(800, 800, P3D); smooth(); s = loadShape("rise.obj"); frameRate(30); mov = new Movie(this, PATH); mov.loop();

//CAMERA Click & Drag for rotation - Command & Drag for panning cam = new PeasyCam(this, 0, 0, 0, 50); cam.setMinimumDistance(0); cam.setMaximumDistance(1800);

}

void movieEvent(Movie m) { m.read();

}

void draw() {

directionalLight(126, 126, 126, 0, 0, -1); ambientLight(102, 102, 102); background(0); pushMatrix(); shape(s, 10, 10, 80, 80); popMatrix(); image(mov, 0, 0, width, height); }

Answers

  • Hi, just put image(mov, 0, 0, width, height) at the beginning of the draw function (instead of background()) and you will have your video as the background

  • Thanks Kesson,

    It didn't quite work. Now it seams to be repeating the background image as I move around the space. If I'm not mistaken the background() function is preventing that from happening. The video is also stuck to the same point as my obj.

  • Answer ✓

    Try this modified version of draw:

    void draw() {
      image(mov, 0, 0, width, height);
      directionalLight(126, 126, 126, 0, 0, -1); 
      ambientLight(102, 102, 102);  
      pushMatrix(); 
      shape(s, 10, 10, 80, 80); 
      popMatrix();     
    }
    

    Now, I do not think you need push or pop matrix here as you are not modifying the translation and rotation matrix of the sketch. I would remove them but it really depends of what you want to do. The think that you need to keep in mind is that if you call image as your last statement, the image will be laid out on top of everything.

    Kf

  • Please edit your post, highlight the code, press Ctrl-o. It's a unusable mess as it is.

  • Ok I see now. I was using a camera rig that I think was messing with it.

This discussion has been closed.