PDA

View Full Version : worldToScreen??


malte
07-20-2010, 05:59 AM
Hi,
I do have a couple of questions regarding the worldToScreen and the worldtoscreen functions.

1. What exactly is the difference between these two? I assume they are essentially doing the same thing?

2. More importantly, I need to know the exact screen coordinates of objects in the world. worldtoscreen seems to work fine, at least until the object is not on the screen anymore but somewhere to the side or even behind the virtual camera. What exactly does the worldtoscreen function in these situations?

Thanks for any feedback,
malte

farshizzo
07-20-2010, 05:54 PM
1) There is no difference in functionality. The worldtoscreen version will be removed in future versions, so you should use the viz.MainWindow.worldToScreen method.

2) The function returns a list of 3 values, [x,y,distance]. If distance is negative, then the point is behind the camera. If either of the x or y values is outside the normalized 0 to 1 range, then the point is not within the current view frustum.

malte
07-21-2010, 12:58 AM
Thanks for the quick reply.

That is pretty much what I expected.

I was confused because I did in some cases get negative values for distance (when object is behind the virtual camera) but values between 0 and 1 for both screen coordinates as if the object was within the viewing frustum.

Should I just ignore all situations in which either the distance is negative or any of the two screen-coordinates is not within the range of 0-1?

Thanks again,
malte

farshizzo
07-21-2010, 09:32 AM
If you only care about whether the object is on screen, then you should ignore all cases where the distance is negative.