[SOLVED] Sending multiple pGraphics objects to Madmapper
  • jazzballg
    junior Member
    Posts: 3
    Joined: Sat Mar 08, 2014 6:23 am

    [SOLVED] Sending multiple pGraphics objects to Madmapper

    by jazzballg » Sat Mar 08, 2014 6:26 am

    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.
    Last edited by jazzballg on Sat Mar 15, 2014 1:52 am, edited 1 time in total.
  • User avatar
    sigmasix
    master
    Posts: 1224
    Joined: Thu Dec 02, 2004 2:12 pm
    Location: gva | switzerland
    Contact:

    Re: Sending multiple pGraphics objects to Madmapper using Sy

    by sigmasix » Sat Mar 08, 2014 9:48 am

    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);
  • jazzballg
    junior Member
    Posts: 3
    Joined: Sat Mar 08, 2014 6:23 am

    Re: Sending multiple pGraphics objects to Madmapper using Sy

    by jazzballg » Sat Mar 08, 2014 6:28 pm

    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.
  • User avatar
    sigmasix
    master
    Posts: 1224
    Joined: Thu Dec 02, 2004 2:12 pm
    Location: gva | switzerland
    Contact:

    Re: Sending multiple pGraphics objects to Madmapper using Sy

    by sigmasix » Sun Mar 09, 2014 11:25 pm

    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);
    }
  • jazzballg
    junior Member
    Posts: 3
    Joined: Sat Mar 08, 2014 6:23 am

    Re: Sending multiple pGraphics objects to Madmapper using Sy

    by jazzballg » Sat Mar 15, 2014 1:50 am

    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! :)

Who is online

Users browsing this forum: No registered users and 51 guests