2

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.

jubin
  • 35
  • 3

2 Answers2

1

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();
  }
}
Nikolaus Gradwohl
  • 19,708
  • 3
  • 45
  • 61
0

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

Community
  • 1
  • 1
George Profenza
  • 50,687
  • 19
  • 144
  • 218
  • I like the way you implemented that, but I need to display them on two separate projectors. – jubin Oct 30 '14 at 06:56
  • What do you mean by two projectors ? (two different projection matrices, two windows, something else) ? – George Profenza Oct 30 '14 at 11:18
  • Its the LCD Projector, or two separate displays. – jubin Nov 01 '14 at 18:21
  • so you want to display a window on one display and another window with a different view of the same 3d scene on a second display/LCD Projector, correct ? – George Profenza Nov 01 '14 at 22:55
  • well that's what Nikolaus' answer above does and [this one](http://stackoverflow.com/questions/17590527/what-processing-library-to-use-to-create-simultaneously-running-renders/17935749#17935749) I've linked to above last Xmas eve. Have you tried any o those ? – George Profenza Nov 03 '14 at 17:44