Page 1 of 1
[SOLVED] scene node visibility
Posted: Mon Aug 13, 2007 5:11 pm
by gammaray
If any of You posters stumbled upon a similar problem, I'd appreciate any advice You could give me:
Is there a method to determine if a scene node is 'seen' by the camera? Let's say I have a light node that generates a lens flare effect when the camera looks at the light, but when the light is hidden by an another object, I'd like it to be 'off'. How could I check this?
Here a screenie that better illustrates what I mean:

(I'm struggling to find a way to disable the flare when the light is hidden)
Posted: Tue Aug 14, 2007 7:36 am
by olivehehe_03
Code: Select all
ILightSceneNode* light->isVisible();
That pretty much explains it

Re:
Posted: Tue Aug 14, 2007 8:48 am
by gammaray
I wish it was so easy - I've set the light node as the parent of the lens flare effect node and when I check the the parents visibility status the method isVisible() returns true, even when the light is hidden behind another node.
Posted: Tue Aug 14, 2007 8:52 am
by BMF
Of course it will return true. isVisible() doesn't take into account objects hiding anything. It just means that the node could be seen (if you were at an appropiate location). So, even if a node was behind your camera, it doesn't mean isVisible() would return false. I think you misunderstood isVisible()'s meaning.
On to your problem, you may want to perform some collision test. Say, if the segment that goes from the camera to the light collides with a certain node (the node that hides the light), then you should turn the lens off.
Hope it helps!
Re:
Posted: Wed Aug 15, 2007 3:21 pm
by gammaray
BMF, he method suggested by You seems to do the trick, at least partially.
I cast a ray from the camera to the flare node position using SceneManager->getSceneNodeFromRayBB() and check what node the function returns. As far as I can see this works with BoundingBoxes so its not perfect detection but seems to do the trick. Thanks for the tip!