Hi Christian,

I have just checked the Viewer::updateTraversal() and associated
UpdateVisitor::handle_callbacks() code and it looks to me like a
StateSet with callbacks attached to a Viewer camera should have it's
callbacks called.  I haven't tested the code though, too many other
tasks to get through I'm afraid.  Perhaps the issue is related to
using an older version of the OSG than the svn/trunk I've just looked
at.

Robert.

On 6 July 2012 14:30, Christian Schulte <[email protected]> wrote:
> Thanks Tim for your response,
>
> I will try your solution with an empty UpdateCallBack for the camera.
> Concerning multiples views in my application, I didn't post my whole code,
> but we are in a class derived from osgViewer::CompositeViewer.
> I understand that Fog and Light are not SceneGraphNodes, but in my case I
> associated my osg::Light to an osg::LightSource whihc is a node, and it is
> this lightSource that I tried to cull, in order to have a view without any
> light.
>
> Thanks,
>
> Christian
>
> Le 06/07/2012 11:46, Tim Moore a écrit :
>
>> Salut,
>>
>> On Fri, Jul 6, 2012 at 10:13 AM, Christian Schulte
>> <[email protected]> wrote:
>>>
>>> Hi everyone,
>>>
>>> I'm facing a problem in our flight simulation environment, where we want
>>> to
>>> make the fog camera dependent ( in order to have cameras without fog for
>>> simulation control). I tried to follow the 2009 thread "[osg-users] Set
>>> fog
>>> in the canera StateSet" and succeded to implement a non variyng fog. But
>>> in
>>> our case we have a statesetcallback for changing the parameter of the fog
>>> and one for activating disactivating the fog.
>>>
>> ...
>>>
>>> But, adding the fog to our different views, neither the
>>> vesaFogUpdateCallback nor the vesaFogEnableUpdateCallback are accessed
>>> anymore... This is the code I tryed to implement :
>>>
>>>          BOOST_FOREACH(propTreeNode & v,
>>> arbreUtile->getOptionalChildProperties("graphic.windows.views"))
>>>          {
>>>              propTreeHolder pView(&v.second);
>>>              if(pView.empty() || v.first.compare("msgFile")==0 ||
>>> v.first.compare("activeView")==0)
>>>                  continue;
>>>
>>>              std::string name = v.first;
>>>              osgViewer::View* view = new osgViewer::View;
>>
>> I don't know if this is pseudo-code or not, but generally you don't
>> create more than one Viewer per application; instead you use
>> CompositeViewer or slave cameras in one Viewer. However, if this is
>> working for you, who am I to say different :)
>>>
>>>              view->setName(name);
>>>              addView(view);
>>>              view->setSceneData(root);
>>>              view->getCamera()->setName(name);
>>>              view->getCamera()->setClearColor(fog->getColor());
>>
>> ...
>>>
>>> view->getCamera()->getOrCreateStateSet()->setAttributeAndModes(fog,
>>> osg::StateAttribute::ON);
>>>                  fog->setUpdateCallback(new vesaFogUpdateCallback);
>>>
>>> view->getCamera()->getOrCreateStateSet()->setUpdateCallback(new
>>> vesaFogEnableUpdateCallback);
>>>              }
>>>          }
>>>
>>> The solution I found is to create an UpdateCallback for each camera which
>>> implements the code present in both my old Fog callbacks.
>>>
>>> Does anyone have an idea of why the UpdateCallBack of the stateset does
>>> not
>>> work when associated to a camera ? What am I doing wrong ?
>>
>> Viewer only runs an UpdateVisitor on a camera if it has an update
>> callback. This may be a small bug, as you have discovered, as it
>> ignores the possibility that the camera's state set could have update
>> callbacks. I believe you will find that your state set update callback
>> will get run even if you install an empty callback on the camera node.
>>
>> Tim
>>>
>>> Moreover, I initially tried to activate desactivate the osf::Fog, the
>>> osg::Light and the osgParticle::PrecipitationEffect using a
>>> NodeMask/CullMask logic for each camera. It works for the
>>> PrecipitationEffect, but doesn't for the Fog and the Light. Is it a
>>> normal
>>> behaviour or is there something wrong in my code (in which case I would
>>> show
>>> you the code).
>>
>> I'm not sure what you mean, as Fog and Light aren't scene graph nodes.
>> Be sure that any StateAttribute objects have their data variance set
>> to DYNAMIC.
>>
>> Tim
>>>
>>> Thankyou for your help,
>>>
>>> SCHULTE Christian
>>> Research  Engineer
>>> in charge of the Simulation Laboratory
>>> System Control and Flight Dynamics Department
>>> Simulation and Flight Testing Unit
>>> ONERA - The French Aerospace Lab
>>> Ecole de l'Air - BA 701
>>> 13661 SALON cedex AIR
>>> FRANCE
>>
>> _______________________________________________
>> osg-users mailing list
>> [email protected]
>> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>>
>
>
> _______________________________________________
> osg-users mailing list
> [email protected]
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to