Page 1 of 1

[SOLVED] Sending multiple pGraphics objects to Madmapper

Posted: Sat Mar 08, 2014 6:26 am
by jazzballg
Hello!

I'm experimenting with a little projection mapping project and using Processing to write code. I'm using Syphon to send frames to Madmapper, the output of which is projected on a 3D surface. To plug Syphon in, I followed these steps, and they work great: https://socram484.wordpress.com/2013/09 ... madmapper/

So far, Syphon with Madmapper works great - but I think I may have run into a limitation of Syphon.

To explain my problem, here's what I'm trying to do:

    I create two PGraphics objects.
    Draw their respective images on the screen.
    Send the two PGraphics objects to Madmapper using Syphon

Code: Select all

PGraphics p1,p2;
void setup(){
        size(400,300);
   
        //Define two layers
        p1 = createGraphics(width,height,P3D);
        p2 = createGraphics(width,height,P3D);
       
        //Define Syphon server
        server = new SyphonServer(this, "Processing Syphon");   
   
    }
   
    void draw(){
      p1.beginDraw();
      p1.fill(255);
      p1.ellipse(30,30,10,10);
      p1.endDraw();
       
      p2.beginDraw();
      p2.fill(0,0,255);
      p2.ellipse(50,50,10,10);
      p2.endDraw();
     
      //Draw two pGraphics layers to screen
      image(p1, 0, 0);
      image(p2, 0, 0);
     
      //Send frames out to server - (Madmapper)
      server.sendImage(p1);
      server.sendImage(p2);
     
    }


Here's the problem. In Processing, only the second `pGraphics` is visible in the output. And in Madmapper, the output randomly flickers between the `p1` and `p2` layers, but never displays both at the same time.

Is there a way to send two `pGraphics` objects from Processing to Madmapper using Syphon? Madmapper has an app called Mad Doubler, but I'm currently using that to display two other layers separately.

I've also tried creating `p2` within `p1`, but I don't see a difference.

Is this something that has been discussed before? Would be very thankful for any suggestions!

Thanks,
Govind.

Re: Sending multiple pGraphics objects to Madmapper using Sy

Posted: Sat Mar 08, 2014 9:48 am
by sigmasix
If in the end you use mad doubler to merge the two syphon sources, why would you need to output to syphon servers from processing? You just have to draw everything in the same pgraphics and have your two contents side by side…

Otherwise, if you need to have two syphon servers in your processing sketch, I assume you just need to have two instances of SyphonServer

Code: Select all

SyphonServer server1, server2;

//setup
server1 = new SyphonServer(this, "Processing Syphon1");
server2 = new SyphonServer(this, "Processing Syphon2");

//draw
server1.sendImage(p1);
server2.sendImage(p2);

Re: Sending multiple pGraphics objects to Madmapper using Sy

Posted: Sat Mar 08, 2014 6:28 pm
by jazzballg
Thanks for the tip!

I tried out using two syphon servers, but I see the same results. In Mad Mapper, I see two syphon input sources now, but I can never get both of them to be displayed at the same time. However, I still see the flickering issue again.

If I only had two layers to draw, Mad Doubler would have been perfect and solved my problem. But my sketch forces me to draw in 3 separate layers, and with Doubler, I can get the first two. But it leads me to believe that through code, you may not be able to send more than one layer per server, to Mad Mapper.

Re: Sending multiple pGraphics objects to Madmapper using Sy

Posted: Sun Mar 09, 2014 11:25 pm
by sigmasix
I don't really see why you want more than a Syphon server if in the end you want everything on the same one…

You can do it like that (I just tweaked a bit the very simple Syphon example):

Code: Select all

import codeanticode.syphon.*;

PGraphics p1, p2, canvas;
SyphonServer server;

void setup() {
  size(800,400, P3D);
  p1 = createGraphics(width/2, height, P3D);
  p2 = createGraphics(width/2, height, P3D);
  canvas = createGraphics(width, height, P3D);

  // Create syhpon server to send frames out.
  server = new SyphonServer(this, "Processing Syphon");
}

void draw() {
  p1.beginDraw();
  p1.background(0);
  p1.fill(255);
  p1.stroke(0);
  p1.translate(width/4, height/2);
  p1.rotateX(frameCount * 0.01);
  p1.rotateY(frameCount * 0.01); 
  p1.box(height/2);
  p1.endDraw();
 
  p2.beginDraw();
  p2.background(255);
  p2.fill(0);
  p2.stroke(255);
  p2.translate(width/4, height/2);
  p2.rotateX(frameCount * -0.01);
  p2.rotateY(frameCount * -0.01); 
  p2.box(height/2);
  p2.endDraw();
 
  canvas.beginDraw();
  canvas.image(p1, 0, 0);
  canvas.image(p2, width/2, 0);
  canvas.endDraw();
  image(canvas, 0, 0);
  server.sendImage(canvas);
}

Re: Sending multiple pGraphics objects to Madmapper using Sy

Posted: Sat Mar 15, 2014 1:50 am
by jazzballg
Hey, sorry I missed your post! Was busy with a few exams, but recently happened to try out your sample code. Works great, thanks so much!

I think with this approach now, I don't need another syphon server. My only concern was to be able to display two separate pg layers and I assumed that one server was required per layer.

Anyways, sorry for the confusion all along - I think I've understood how to proceed from here, appreciate your help! :)