Multiple video's with SurfaceMapper
in
Contributed Library Questions
•
17 days ago
i am very new to Processing so i'm probably taking on more than i can handle.
starting out with the provided examples in the library i tried to understand what everything does and i've been messing around for some time.
then with an new sketch and only using GSMovie i managed to play 2 video clips next to each other. so i tried to do that in the SurfaceMapper example. i succeeded in adding a movie, i could get both to play (but they were both in the same QuadSurface. so i decided to set up 2 surfaces and link the different clips to the different surfaces.
there are 2 surfaces now but only the second one renders. the first one appears black in render mode. in calibration mode everything works but the whole image flickers.
here's the code i have so far:
import codeanticode.gsvideo.*;
import ixagon.SurfaceMapper.*;
import processing.opengl.*;
import codeanticode.glgraphics.*;
/***********************************************************
* EXAMPLE PROVIDED WITH SURFACEMAPPER LIBRARY DEVELOPED BY *
* IXAGON AB. *
* This example shows you how to setup the library and *
* and display a movie to multiple surfaces. *
* Check the keyPressed method to see how to access *
* different settings *
***********************************************************/
GLTexture tex, tex2;
GLTexture img;
GLGraphicsOffScreen glos;
SurfaceMapper sm;
GSMovie movie, movie2;
void setup(){
size(1600,1050, GLConstants.GLGRAPHICS);
glos = new GLGraphicsOffScreen(this, width, height, false);
tex = new GLTexture(this);
tex2 = new GLTexture(this);
//Create new instance of SurfaceMapper
sm = new SurfaceMapper(this, width, height);
//Creates one surface with subdivision 3, at center of screen
sm.createQuadSurface(3,width/2,height/2);
//set the name of the surface
sm.getSurfaces().get(0).setSurfaceName("name1");
//Creates one surface with subdivision 5
sm.createQuadSurface(5,width/3,height/3);
//set the name of the surface
sm.getSurfaces().get(0).setSurfaceName("name2");
movie = new GSMovie(this, "streets.mp4");
movie2 = new GSMovie(this, "montypythonlg.mov");
movie.setPixelDest(tex);
movie2.setPixelDest(tex2);
movie.loop();
movie2.loop();
}
void draw(){
background(0);
glos.beginDraw();
glos.clear(0);
glos.hint(ENABLE_DEPTH_TEST);
glos.endDraw();
//get movie frame
if(tex.putPixelsIntoTexture())
if(tex2.putPixelsIntoTexture())
//render all surfaces in calibration mode
if(sm.getMode() == sm.MODE_CALIBRATE)sm.render(glos);
//render all surfaces in render mode
if(sm.getMode() == sm.MODE_RENDER){
for(SuperSurface ss : sm.getSurfaces()){
if(ss.getSurfaceName().equals("name1")){
ss.render(glos, tex);
}if(ss.getSurfaceName().equals("name2")){
ss.render(glos, tex2);
}
}
}
//display the GLOS to screen
image(glos.getTexture(),0,0,width,height);
}
void movieEvent(GSMovie movie)
{
movie.read();
movie2.read();
}
void keyPressed(){
//create a new QUAD surface at mouse pos
if(key == 'a')sm.createQuadSurface(3,mouseX,mouseY);
//create new BEZIER surface at mouse pos
if(key == 'z')sm.createBezierSurface(3,mouseX,mouseY);
//switch between calibration and render mode
if(key == 'c')sm.toggleCalibration();
//increase subdivision of surface
if(key == 'p'){
for(SuperSurface ss : sm.getSelectedSurfaces()){
ss.increaseResolution();
}
}
//decrease subdivision of surface
if(key == 'o'){
for(SuperSurface ss : sm.getSelectedSurfaces()){
ss.decreaseResolution();
}
}
//save layout to xml
if(key == 's')sm.save("bla.xml");
//load layout from xml
if(key == 'l')sm.load("bla.xml");
//rotate how the texture is mapped in to the QUAD (clockwise)
if(key == 'j'){
for(SuperSurface ss : sm.getSelectedSurfaces()){
ss.rotateCornerPoints(0);
}
}
//rotate how the texture is mapped in to the QUAD (counter clockwise)
if(key == 'k'){
for(SuperSurface ss : sm.getSelectedSurfaces()){
ss.rotateCornerPoints(1);
}
}
//increase the horizontal force on a BEZIER surface
if(key == 't'){
for(SuperSurface ss : sm.getSelectedSurfaces()){
ss.increaseHorizontalForce();
}
}
//decrease the horizontal force on a BEZIER surface
if(key == 'y'){
for(SuperSurface ss : sm.getSelectedSurfaces()){
ss.decreaseHorizontalForce();
}
}
//increase the vertical force on a BEZIER surface
if(key == 'g'){
for(SuperSurface ss : sm.getSelectedSurfaces()){
ss.increaseVerticalForce();
}
}
//decrease the vertical force on a BEZIER surface
if(key == 'h'){
for(SuperSurface ss : sm.getSelectedSurfaces()){
ss.decreaseVerticalForce();
}
}
}
1