Hi Sajjad,

There are asType functions is osg::Node,
this has better performance then dynamic_cast ...

for example you can do:

osg::ref_ptr<osg::Switch> switch = group->asSwitch();

Now you are using a virtual table to get the right type:

if the object is a Switch you will get the this-pointer of the Switch
if it is not you will get 0.

Usually there are always better ways then dynamic_cast, especially
if you are the owner of the code.

Good Luck,

Rene



2009/4/9 ami guru <dosto.wa...@gmail.com>

> Hello Forum,
>
>
> I have a LightManager class that tracks the number of lights(OpenGL Lights)
> that have been created.
>
> Inside the class the have the following member
>
>
>   osg::ref_ptr<osg::Group>  groupOfLights;
>   vector<osg::ref_ptr<osg::LightSource> >   lights;
>
> the member groupOfLights contain the LightSource as child.
>
>
> In the application i want to select different light (spot,point or diffuse)
> with key press event and only one light is enabled during an instant OR i
> may enable several lights.
>
>
> In that case i believe that i have to do dynamic casting to cast Group to
> Switch.
>
> In other better way to do that ?
>
>
>
> Regards
> Sajjad
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
>
>
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to