Author Topic: is visible object on screen  (Read 3084 times)

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
is visible object on screen
« on: June 02, 2011, 09:47:13 pm »
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 :)
« Last Edit: June 02, 2011, 09:51:17 pm by Thomas. »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: is visible object on screen
« Reply #1 on: June 02, 2011, 09:58:43 pm »
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....
« Last Edit: June 02, 2011, 10:04:29 pm by EgonOlsen »

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: is visible object on screen
« Reply #2 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?

Offline Thomas.

  • double
  • *****
  • Posts: 833
    • View Profile
Re: is visible object on screen
« Reply #3 on: June 02, 2011, 10:22:32 pm »
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...
« Last Edit: June 02, 2011, 10:50:14 pm by Thomas. »

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: is visible object on screen
« Reply #4 on: June 02, 2011, 11:06:13 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.