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 › Depth and Overpaint
Page Index Toggle Pages: 1
Depth and Overpaint (Read 525 times)
Depth and Overpaint
Apr 24th, 2006, 2:46pm
 
hi all,

i don't get how i could work with depths oder virtual depths
in processing.

for example, i have a rectangle and a ellipse one to the next in
the center of the screen. when i increase the size of the
rectangle trough a keyInput thats linked to the variable size,
one time my rectangle will overlay my ellipse and fill the screen.

is there a way to let the rectangle fall apart after some time or
to inform the ellipse that it is always on the front ?

here an example:

___________________________________________________________
import processing.opengl.*;
/*
Taste x = Bigger
Taste y = Smaller
*/
   float boxsize = 0;
   float moveX = 0;
   float moveY = 0;

void setup() {
    size(680, 480, OPENGL);
    smooth();
    lights();
    colorMode(RGB);
    }  
   
   
void draw() {
 
   noStroke();
   fill(102, 32, 0, 100);
   rect(0, 0, 40, 480);
   redraw();
   
   translate(pmouseX + moveX, pmouseY +moveY);

    fill(50, 0, 0, 100);
    box(boxsize);

/* ---------------- SIZE Control ---------------- */
   
       if(keyPressed) { if (key == 'y') {    
         if (boxsize <= 500) { boxsize++; } else { boxsize = 500; } } }  
   
       if(keyPressed) { if (key == 'x') {    
          if (boxsize >= 2) { boxsize--; } else { boxsize = 2; } } }

}
___________________________________________________________

thanx for help on that.
greetz
stefan
Re: Depth and Overpaint
Reply #1 - Apr 25th, 2006, 7:39pm
 
it's the order of things run in draw that determines the depth. i.e

void draw()
{
rect(10,10,50,50); // rect drawn first
ellipse(40,40,50,50); // then ellipse
}

but you can write a script that reads what order they're in from an array, but you should look into oop for that..
Re: Depth and Overpaint
Reply #2 - Apr 25th, 2006, 7:47pm
 
to make things draw such that they're sorted based on their position in the z-axis, use hint(ENABLE_DEPTH_SORT), as noted in the FAQ.

to make things ignore their z order altogether, so that they always overwrite each other, use hint(DISABLE_DEPTH_TEST).
Page Index Toggle Pages: 1