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 & HelpSyntax Questions › motion fake method with transparant rect
Page Index Toggle Pages: 1
motion fake method with transparant rect (Read 752 times)
motion fake method with transparant rect
Apr 16th, 2009, 12:34pm
 
In the processing book there are examples where a ball moves and a transparant  rect gets drawn every frame so you get a motion blur effect.
I want to do this in 3d but the rect only has a x and y parameter, no z.
And if I use (not, no transparanty)

 fill(204, 0, 0);
 rect(0, 0, width, height);

then for some reason(s) I still see what is drawn before.
What is a good way to solve this for a 3d space?
Re: motion fake method with transparant rect
Reply #1 - Apr 16th, 2009, 12:58pm
 
You might be able to use a push/translate/pop... or perhaps a box().
Re: motion fake method with transparant rect
Reply #2 - Apr 18th, 2009, 3:24am
 
I don't have the solution, but I can explain what happens now. The 3D object you draw is drawn around a center point, which is on the same z-plane as your rect. Half of it sticking in front, half behind. P3D can't render this very well.

As far as I know, no shape drawing function incorporates the z-axis in it's parameters. Instead, you use translate(x,y,z) to move up and down through the z-axis.

But the "trick" described in the book effectively uses layering of semi-transparant layers to achieve the progressively more opaque look. In 3D-case, this would meen that you'd work on different z-levels, but this works differently. As you'll find out.
Re: motion fake method with transparant rect
Reply #3 - Apr 18th, 2009, 3:26am
 
try this: http://processing.org/discourse/yabb2/?num=1239453634
Re: motion fake method with transparant rect
Reply #4 - Apr 18th, 2009, 4:39am
 
void setup() {
 size(400, 400, P3D);smooth();
}
     

void draw() {

hint(DISABLE_DEPTH_TEST);
fill(0,50);
rect(0,0,width,height);
hint(ENABLE_DEPTH_TEST);
fill(255);


translate(mouseX,mouseY);
sphere(50);
}
Re: motion fake method with transparant rect
Reply #5 - Apr 18th, 2009, 6:06am
 
k thx, that was what I was looking for!
Page Index Toggle Pages: 1