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 › Layering Objects / moving to front ?
Page Index Toggle Pages: 1
Layering Objects / moving to front ?? (Read 1050 times)
Layering Objects / moving to front ??
Apr 11th, 2009, 5:40am
 
Hi Guys

I tried to find some topics on placing an elipse on top of a circle but i find that my elipse dissappears when i try and code it.

Are there any reserved words to help with this issue?

thanks
Re: Layering Objects / moving to front ??
Reply #1 - Apr 11th, 2009, 5:46am
 
which ever shape you draw last is the one on top.  If you want the ellipse to appear on the circle, change the order in which you draw them, or increase the ellipses size so it "sticks out".
Re: Layering Objects / moving to front ??
Reply #2 - Apr 11th, 2009, 6:01am
 
Lasrin wrote on Apr 11th, 2009, 5:46am:
which ever shape you draw last is the one on top.  If you want the ellipse to appear on the circle, change the order in which you draw them, or increase the ellipses size so it "sticks out".


Thats what should be happening but it is not happening, the last elipse is being placed behind the others infront of it.

Re: Layering Objects / moving to front ??
Reply #3 - Apr 11th, 2009, 6:13am
 
I am trying to place a Ellipse on top of a sphere. Is this why it is being displayed behind the sphere ??


size(400, 400, P3D);
noStroke();
sphereDetail(12);
lights();
background(0);

translate(200, 220, 200);
sphere(30);

translate(0, -40, 0);
sphere(20);

translate(0, -25, 0);
sphere(10);

fill(150);
ellipse(8,-5,10,10);
Re: Layering Objects / moving to front ??
Reply #4 - Apr 11th, 2009, 7:16am
 
the problem is that all your objects are created at the same Z coordinate. That means, your ellipse is always created inside your spheres... one way would be to move the spheres into the background... Dont forget to use pushMatrix(); popMatrix(), so it doesnt affect your ellipse...

size(400, 400, P3D);
noStroke();
sphereDetail(12);
lights();
background(0);

pushMatrix();
translate(200, 220, -100);
sphere(30);

translate(0, -40, 0);
sphere(20);

translate(0, -25, 0);
sphere(10);
popMatrix();

fill(150);
ellipse(width/2,height/2,40,40);
Re: Layering Objects / moving to front ??
Reply #5 - Apr 12th, 2009, 5:15am
 
or disable depth testing.

hint(DISABLE_DEPTH_TEST);
Re: Layering Objects / moving to front ??
Reply #6 - Apr 17th, 2009, 2:27pm
 
V wrote on Apr 12th, 2009, 5:15am:
or disable depth testing.

hint(DISABLE_DEPTH_TEST);


Hi

I tried to find information on this but i cannot find anything in the online refrence manual.
Re: Layering Objects / moving to front ??
Reply #7 - Apr 17th, 2009, 2:34pm
 
using the search field at the top of the page i got this:

http://processing.org/reference/hint_.html
Re: Layering Objects / moving to front ??
Reply #8 - Apr 17th, 2009, 5:30pm
 
Cedric wrote on Apr 11th, 2009, 7:16am:
the problem is that all your objects are created at the same Z coordinate. That means, your ellipse is always created inside your spheres... one way would be to move the spheres into the background... Dont forget to use pushMatrix(); popMatrix(), so it doesnt affect your ellipse...

size(400, 400, P3D);
noStroke();
sphereDetail(12);
lights();
background(0);

pushMatrix();
translate(200, 220, -100);
sphere(30);

translate(0, -40, 0);
sphere(20);

translate(0, -25, 0);
sphere(10);
popMatrix();

fill(150);
ellipse(width/2,height/2,40,40);


Hi

I have been trying to find some sort of understanding of push and pop but i cant find anything that explains why i need to use them at all.  Cry

A google search yields nothing that explains it properly, and the online reference manual here says you should have knowledge of matrix stacks.

Re: Layering Objects / moving to front ??
Reply #9 - Apr 17th, 2009, 5:36pm
 
V wrote on Apr 17th, 2009, 2:34pm:
using the search field at the top of the page i got this:

http://processing.org/reference/hint_.html


I must seem really silly but i did look earlier and didnt see that on the reference. I even sorted it a-z aswell how embarrasing  Grin

Thank you though, it makes me wonder what the point is in using pus and pop matrix if u can use this instead. Much easier.

Re: Layering Objects / moving to front ??
Reply #10 - Apr 17th, 2009, 5:42pm
 
Quote:
Thank you though, it makes me wonder what the point is in using pus and pop matrix if u can use this instead. Much easier.



it is Smiley
Re: Layering Objects / moving to front ??
Reply #11 - Apr 17th, 2009, 6:26pm
 
disabling the depth test means that it rejects no pixel, so it depends on the order you render. u can draw an object that is at a longer distance than another and still have it rendered on top. because it wasnt discarded by the z-testing.

as for push/pop. yes you should read about matrix stacks.
basically it saves a copy of your current matrix (push) so you can do other transformations and get back to the point you were (pop).

just do some tests rendering with push/pop and without it. you will get to it.
Page Index Toggle Pages: 1