Topic: How to check object visibility?

I need to detect events - "object appear on screen" and "object dissapear from screen".
Can you advise the best way to do this?

Currently my plan is check object-visible in onSceneUpdate() by next algorythm:
1. Find camera look direction => vec3_A
2. Find vector from cameraPosition to objectPosition (center) => vec3_B
3. Find angles between vec3_A and vec3_B and compare with angles defined by camera fov/screen width and height.
It's a dirty algorythm with "unknow visible state" zone and can be improved by cheking all BBox-vertices (inaccessible yet) instead of center.
P.S. I don't need accurate detection.
P.P.S. Next step is visible level, e.g. 1 - object under cursor +-, 0.8 - object near cursor, 0.4 - object near screen border, 0 - object invisible.

Last edited by Aikon (2013-12-14 20:29:00)

Re: How to check object visibility?

In lua you can use the isVisible(object) function.

Re: How to check object visibility?

com3D, yeah. Thanks.
I thinked that IsVisible return reverse value of "Invisible"-attribute
http://sgeproject.narod.ru/pics/Maratis/invisible.jpg
But it's my mistake smile

P.S. He-he, I look to engine-code. Visible check use described above algorythm with BBox smile

Last edited by Aikon (2013-12-15 08:34:24)