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 › Left eye / right eye output: lighting query
Page Index Toggle Pages: 1
Left eye / right eye output: lighting query (Read 617 times)
Left eye / right eye output: lighting query
Jan 17th, 2006, 5:24pm
 
We're trying to play around with some real 3D, outputing to two adjacent viewports, and wondered if anyone had any ideas how to light the scene.  The source below will light the right eye but not the left eye:

--
import processing.opengl.*;
import net.java.games.jogl.*;
void setup()
{
  size(600,300,OPENGL);
}
void draw()
{
 lights();
 background(128);
 GL gl = ((PGraphicsGL)g).gl;
 gl.glViewport(0,0,300,300);    // Left eye
 camera(50, 150, 150 / tan(PI*60.0 / 360.0), 150, 150,0,0,1,0);
 drawscene();
 gl.glViewport(300,0,300,300);  // Right eye
 camera(250, 150, 150 / tan(PI*60.0 / 360.0), 150, 150,0,0,1,0);
 drawscene();
}
void drawscene()
{
 pushMatrix();
 translate(150,150);
 box(50,50,50);
 popMatrix();
}
Re: Left eye / right eye output: lighting query
Reply #1 - Jan 17th, 2006, 10:48pm
 
The lighting does work. I think you've unluckily managed to pick the exact position where the two sides of the box are lit the same for the left eye.

If you add a variable rotation, you can see it being lit properly. (I've also added a perspective() command to sort out the stretching for you)

Code:
import processing.opengl.*;
import net.java.games.jogl.*;

float a;

void setup()
{
size(600,300,OPENGL);
perspective(PI/3.0,1,0.1,1000);
a=0;
}
void draw()
{
a+=0.01;
lights();
background(128);
GL gl = ((PGraphicsGL)g).gl;
gl.glViewport(0,0,300,300); // Left eye
camera(50, 150, 150 / tan(PI*60.0 / 360.0), 150, 150,0,0,1,0);
drawscene();
gl.glViewport(300,0,300,300); // Right eye
camera(250, 150, 150 / tan(PI*60.0 / 360.0), 150, 150,0,0,1,0);
drawscene();
}
void drawscene()
{
pushMatrix();
translate(150,150);
rotateY(a);
box(50,50,50);
popMatrix();
}
Page Index Toggle Pages: 1