Multiple render to two projectors using processing (for Polarization based 3D)

468 views Asked by At

I want to setup a 3D installation in our college, for that, I want to know that, whether I can setup two eye distance separated cameras in processing, and render each one to two different projectors, so that, I can blend those outputs by polarizing them and implement 3d effect.

2

There are 2 answers

0
Nikolaus Gradwohl On BEST ANSWER

You can open a second Window in processing by creating an instance of a PApplet and adding it to a new JFrame window. The following example creates a simple sketch that opens two windows and draws a circle slightly shifted to the left in one of them and to the right in the second one. These windows can be placed on the different projectors

import javax.swing.JFrame;

PFrame f;

void setup () {
  size(300,300);
  PFrame f = new PFrame();
}

void draw() {
  background(0);
  ellipse(140,150,100,100);
}

public class Second extends PApplet {
  public void setup() {
    size(300,300);
  }

  public void draw() {
    background(0);
    ellipse(160,150,100,100);
  }
}

public class PFrame extends JFrame {
  public PFrame() {
    setBounds(0,0,300,300);
    Second s = new Second();
    add(s);
    s.init();
    show();
  }
}
5
George Profenza On

I've got a few ideas from the simpler to the more complex:

  1. Simply isolating drawing commands/coordinate spaces
  2. Using different render layers

Method 1: Simple use pushMatrix()/popMatrix() calls to isolate the left from the right viewpoints, maybe using different values for the perspective() projection

Here's a very rough example to illustrate the idea:

void setup(){
  size(200,100,P3D);
  noFill();
}
void draw(){
  background(255);
  stroke(255,0,0);
  //view 1
  pushMatrix();
    camera(70.0, 0.0, 200.0, 50.0, 50.0, 0.0, 0.0, 1.0, 0.0);
    drawBox();
  popMatrix();

  stroke(0,0,255);
  //view 2
  pushMatrix();
    camera(90.0, 0.0, 200.0, 50.0, 50.0, 0.0, 0.0, 1.0, 0.0);
    translate(100,0,0);//move everything to the right
    drawBox();
  popMatrix();
}
void drawBox(){
  pushMatrix();
  rotateY(map(mouseX,0,width,-PI,PI));
  box(50);
  popMatrix();
}

Method 2: You can separate the values/number updates from your drawing code and draw twice in the same frame, but into separate 'layers', perhaps using PGraphics instances

If you want to separate windows you can see a code example in this answer