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 & HelpPrograms › P3D simple example: what's wrong
Page Index Toggle Pages: 1
P3D simple example: what's wrong? (Read 2469 times)
P3D simple example: what's wrong?
Apr 29th, 2005, 8:42am
 
Hello all

I was testing the v.85 P3D, and I got a flickering geometry; am I doing something wrong?

Code:

float rot;
void setup()
{
size(500,500, P3D);
}
void draw()
{
rot+=PI/64;
beginCamera();
resetMatrix();
lookat(0,2*height-4*height*mouseY/height, 2*width*mouseX/width, 0,0, 0, 0, 1, 0);
endCamera();
background(255);

rotateX(rot);
rotateY(rot);
translate(-100,0,0);
sphere(100);
translate(200,0,0);
box(200);
}

Re: P3D simple example: what's wrong?
Reply #1 - Apr 29th, 2005, 5:19pm
 
I'm not sure what it looks like for you, but it was flickering for me for a few reasons:

Spheres don't look good with stroke(), they are too dense and it's not possible to draw all the lines to the coarse pixel grid on the screen.

The geometry is getting clipped when it comes too close to the front of the window (this is the clipping plane). You need to be aware of it's location and control it from getting this close.

Try this:

Code:

float rot;
void setup()
{
size(500,500, P3D);
}
void draw()
{
rot+=0.01;

lights();

beginCamera();
resetMatrix();
lookat(0,2*height-4*height*mouseY/height, 2*width*mouseX/width, 0,0, 0, 0, 1, 0);
endCamera();
background(255);

if(!mousePressed) {
rotateX(rot);
rotateY(rot);
}
translate(-100,0,0);
noStroke();
fill(102);
sphere(100);
translate(200,0,0);
stroke(0);
box(200);
}
Re: P3D simple example: what's wrong?
Reply #2 - Apr 29th, 2005, 5:47pm
 
When I say noFill() and stroke(0) in place of noStroke() and fill(102), it blows up.  I am a bit sleepy, but is this a bug?

Re: P3D simple example: what's wrong?
Reply #3 - Apr 29th, 2005, 11:36pm
 
hmmmm... strange... it wasn't a clipping plane issue, neither a sphere...

I've simplified it even more, does anyone see it flickering or it might be a local issue here at my machine?

Code:

float rot;
void setup()
{
size(500,500, P3D);
}
void draw()
{
background(255);
translate(width/2, height/2);
rot+=0.01;
if(!mousePressed) {
rotateX(rot);
rotateY(rot);
}

box(100);
}
Re: P3D simple example: what's wrong?
Reply #4 - Apr 30th, 2005, 2:29am
 
With a white background and the default fill (white) and stroke (black) you'll get "jagged" lines due to the lack of anti-aliasing, which would explain what you call "flickering". Other than that, animation's pretty smooth.
Re: P3D simple example: what's wrong?
Reply #5 - Apr 30th, 2005, 2:53am
 
uh oh. It seems that I have a local problem.
The jagged edges are ok; what do I get is a real flicker, the lines constantly appear-disappear. I guess no one else is having this... I'll make a movie out of it later.

Thanks for checking...
Re: P3D simple example: what's wrong?
Reply #6 - Apr 30th, 2005, 2:54am
 
btw, I'm running the new java, this might explain it... I'll downgrade.
Re: P3D simple example: what's wrong?
Reply #7 - May 2nd, 2005, 5:26am
 
I actually think that fred nailed this one. Change your framerate to 6 or so (low enought that persistence of vision dissapears) and you'll see that the "flicker" is caused by odd aliasing.

Change your background to 204 and you'll see that what's happening is that the white fill is painting over some of the edges. When you have a white background it seems that the edges disappear.

If you drop a noFill() in right before the call to box(), you'll see that the effect goes away since the fill is no longer painting over the edges. I have a feeling that edges are painted first in the P3D renderer and that's what's causing this effect (makes sense from a rendering stand-point).
Page Index Toggle Pages: 1