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 › directly set coordinates of object on canvas
Page Index Toggle Pages: 1
directly set coordinates of object on canvas? (Read 430 times)
directly set coordinates of object on canvas?
Jun 11th, 2008, 3:27pm
 
hello!

i re-paint some objects that are stored in an arrayList every time the draw() method is called. since my objects are in 3-dimensional space, where it is possible to adjust the viewing position, i can't just paint a rectangle over the whole canvas to 'fade out' previous drawn objects.

is it possible to set coordinates for an object (the 'fade out' rectangle in my case) directly on the canvas?

by canvas i mean the window, i hope it's understandable.
Re: directly set coordinates of object on canvas?
Reply #1 - Jun 11th, 2008, 5:19pm
 
You can do both.  screenX() screenY() and screenZ() will give you the screen coordinates of the 3D objects.

To blot out something regardless of depth (paint over things), simply do hint(DISABLE_DEPTH_TEST).
Re: directly set coordinates of object on canvas?
Reply #2 - Jun 11th, 2008, 7:28pm
 
hm, still it doesn't work.
here's my code (first part of the draw()-method):

  //'fading away'-effect
   fill(73, 75, 255, 100);
   hint(DISABLE_DEPTH_TEST);
   rect(screenX(0, 0, 0), screenY(0, 0, 0), 1000, 600); // x, y, width, height

and here is a screen. the blue rectangle should be drawn all over the window. instead it's small and still messing with 3d:(

http://img139.imageshack.us/img139/1850/processingve3.png
Re: directly set coordinates of object on canvas?
Reply #3 - Jun 11th, 2008, 8:13pm
 
Try removing z value from your rect() call.  It should draw over it.  I use this for my HUD display and it works.

Also, screenX and screenY shouldn't be used there.  That was only to get the x, y coord from whatever 3D objects you drew before.  


In fact, all you need to do there is rect(0,0, width, height);

If you actually used translate(), then make sure you reset the coordinates using pushMatrix() and popMatrix().  For example, if you used camera in your prgam, then take a look at my modification of the example code:
size(500, 500, P3D);
noFill();

pushMatrix();
beginCamera();
camera();
rotateX(-PI/6);
endCamera();

translate(50, 50, 0);
rotateY(PI/3);
box(45);
popMatrix();

fill(50, 100);
rect(0,0,width, height);


//====end

It doesn't look like much, but the last line is doing what you are trying to do (I think).
Page Index Toggle Pages: 1