is visible object on screen

Started by Thomas., June 02, 2011, 09:47:13 PM

Previous topic - Next topic

Thomas.

How can I find if is visible object on screen? I will try implement portals when I have some free time ... I do not know if is possible, but I will try it :)

EgonOlsen

#1
You could take on objects bounding box, transform it's coordinates into camera space and see if it's completely behind one of the view frustum's planes. Or, maybe simpler to calculate, transform the bb into world space and use project3D2D to project it into screen space. Then, you can detect if it's completely outside the screen.

But doing this for the screen alone is 100% pointless, because jPCT does this anyway....

Thomas.

I want to set "boxs" for rooms, when camera will be inside box, for every object inside box sets visible(true), and if will be visible portal on screen, "box" and everything inside will be visible, rest invisible... any problem with this?

Thomas.

#3
but I need if is just part of portal visible on screen... so I every vertex of portal project to screen :)
edit: it will not work... I need surface of polygon...

EgonOlsen

Quote from: Thomas. on June 02, 2011, 10:12:24 PM
I want to set "boxs" for rooms, when camera will be inside box, for every object inside box sets visible(true), and if will be visible portal on screen, "box" and everything inside will be visible, rest invisible... any problem with this?
No problem, that's basically what desktop jPCT does too...it's just not worth it unless you have plenty of high polygon objects hidden by the walls. Just keep in mind that you might stand into a portal making it clipped at the screen plane. I dealt with that pretty simple: I marked the rooms on each side of the portal as visible.