did you use osg::ref_ptr<> for your Manipulators? Otherwise they'll get
destroyed when overwritten.

regards Ralph

Stephane DUGUET schrieb:
> Hello all,
> 
>  
> 
> I’m facing an issue with trackball manipulator.
> 
> I want to toggle successively between a trackball manipulator and a
> tracker on 2 nodes.
> 
> After a complete toggle loop, ie coming back to trackball I have a
> crash.(instance of Tman seem to be corrupted).
> 
>  
> 
> Any idea of what I did wrong?
> 
>  
> 
> Here is my code:
> 
>  
> 
> void CameraInit()
> 
> {
> 
>  
> 
>       double xl,yl;
> 
>       //init tracker to follow mobile 1
> 
>       keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
> 
>       trackerMode1 = osgGA::NodeTrackerManipulator::NODE_CENTER_AND_AZIM;
> 
>       tm1 = new osgGA::NodeTrackerManipulator;
> 
>       tm1->setTrackerMode(trackerMode1);
> 
>       rotationMode1 = osgGA::NodeTrackerManipulator::ELEVATION_AZIM;
> 
>       rotationMode2 = osgGA::NodeTrackerManipulator::TRACKBALL;
> 
>       tm1->setRotationMode(rotationMode1);
> 
> //    scaler1 = new osg::MatrixTransform;
> 
>      
> 
>        //Trackball manager
> 
>         Tman = new osgGA::TrackballManipulator();
> 
>         /* x, y and z are retrieved by converting GPS to local*/
> 
>         latLon2xy(33.2940335740,-117.3636264412,xl,yl);
> 
>         Tman->setHomePosition(osg::Vec3d(xl+ 50.0, yl+50.0, 400.0),
> 
>                                   osg::Vec3d(xl+ 50.0, yl+ 50.0, 0.0),
> 
>                                   osg::Vec3d(0.0, 0.0, 1.0),
> 
>                                  false); // do not auto calculate home
> 
>        
> 
> }
> 
> void toggleView()
> 
> {
> 
>    CurrentCamera++; 
> 
>    switch (CurrentCamera)
> 
>    {
> 
>    case 0:
> 
>          { 
> 
>          viewer.setCameraManipulator(Tman);
> 
>          }
> 
>             break;
> 
>    case 1:
> 
>          {
> 
>             tm1->setTrackNode(copterNode);
> 
>             viewer.setCameraManipulator(tm1);
> 
>          }
> 
>             break;
> 
>   case 2:
> 
>          {
> 
>             tm1->setTrackNode(tankNode);
> 
>             viewer.setCameraManipulator(tm1);
> 
>             CurrentCamera =-1;
> 
>          }
> 
>          break;
> 
>    default:
> 
>          break;
> 
>    }
> 
> }
> 
>  
> 
>  
> 
> Thanks a lot for your support,
> 
>  
> 
> BR,
> 
> 
> Stephane
> 

_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to