Salut,

On Fri, Jul 6, 2012 at 10:13 AM, Christian Schulte
<christian.schu...@onera.fr> 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
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to