We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpOpenGL and 3D Libraries › Anaglyph stereo vision perspective
Page Index Toggle Pages: 1
Anaglyph stereo vision perspective (Read 969 times)
Anaglyph stereo vision perspective
Feb 24th, 2010, 9:59am
 
I'm trying to create an anaglyph.  I've been playing with glColorMask, but I can't figure out the perspective stuff with the camera.  I can separate the colors, I don't know how to shift it the images for each eye.  Could someone help me out. Smiley

Code:
import peasy.*;
import processing.opengl.*;  
import javax.media.opengl.GL;

PeasyCam cam;
PGraphicsOpenGL pgl;
GL gl;
float fov;
float cameraZ;

void setup() {
 size(500,500, OPENGL);
 cam = new PeasyCam(this, 100);
 cam.setMinimumDistance(50);
 cam.setMaximumDistance(500);
 pgl = (PGraphicsOpenGL) g;
 gl = pgl.gl;
 fov = PI/3.0;
 cameraZ = (height/2.0) / tan(fov/2.0);
}
void draw() {

 background(0);
 for(int x3d = 0; x3d < 2; x3d++) {

   if(x3d == 0) {
println(fov);
    // translate(1,1,1);
perspective(fov, float(width)/float(height),
cameraZ/10.0, cameraZ*10.0);
gl.glColorMask(true, false, false, true);
   }
   else {
//translate(-1,-1,-1);
perspective(fov-.03, float(width)/float(height),
cameraZ/10.0, cameraZ*10.0);
gl.glColorMask(false, true, true, true);
   }

   pushMatrix();
   fill(255,0,0);
   box(30);

   translate(0,0,20);
   fill(0,0,255);
   box(5);

   translate(0,20,-20);
   fill(0,255,0);
   box(5);
   translate(20,-20,0);
   fill(255,255,0);
   box(5);
   translate(-40,0,0);
   fill(255,128,0);
   box(5);
   translate(20,-20,0);
   fill(128,0,255);
   box(5);
   translate(0,20,-20);
   fill(128,128,128);
   box(5);
   popMatrix();
 }
  gl.glColorMask(true, true, true, true);

}
Re: Anaglyph stereo vision perspective
Reply #1 - Feb 24th, 2010, 10:58am
 
camera.pan()?

you just need to move the camera for the second frame to the other eye, as it were.
Re: Anaglyph stereo vision perspective
Reply #2 - Feb 24th, 2010, 11:34am
 
Sounds good... how far do you pan it. haha  Is there a particular direction for each eye.
Left eye
camera.pan(-1.0,-1.0)

Right eye
camera.pan(1.0,1.0)

Something like that?
Page Index Toggle Pages: 1