Felipe Lemus wrote on Tuesday, October 27, 2009 1:57 PM:
> tankDataType::tankDataType(osg::Node* n)
>   {
>      rotation    =  0;
>   tank =  dynamic_cast< osgSim::DOFTransform*> (n);
> }
> 
> void tankDataType::updateTurretRotation()
> {
>  rotation -= 0.01;
>  tank->setCurrentHPR( osg::Vec3(rotation,0,0) );
> }

This code assumes that tanks is never null (i.e. that the top node of
the loaded file is a DOFTransform), but this is not guaranteed; the
dynamic_cast could return null, then updateTurretRotation() would
segfault.

You should use a NodeVisitor to find the DOFTransform in the loaded
model and pass that to the tankDataType constructor.

HTH,
-- 
Bryan Thrall
FlightSafety International
bryan.thr...@flightsafety.com
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to