Changeset 73 for osgVisual/src/core


Ignore:
Timestamp:
Jul 24, 2010, 10:48:02 AM (14 years ago)
Author:
Torben Dannhauer
Message:
 
File:
1 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/src/core/visual_core.cpp

    r72 r73  
    5656        OSG_NOTIFY( osg::ALWAYS ) << "Initialize visual_core..." << std::endl;
    5757
    58         // Add manipulators for user interaction
    59         addManipulators();
    60 
    6158        // Load terrain
    6259        //loadTerrain(arguments);
     
    8481        visual_dataIO::getInstance()->init(viewer, arguments);
    8582
     83        // Add manipulators for user interaction - after dataIO to be able to skip it in slaves.
     84        addManipulators();
     85
    8686        loadTerrain(arguments);
    8787
     
    118118                // update the scene by traversing it with the the update visitor which will
    119119        // call all node update callbacks and animations.
    120        
    121120        viewer->updateTraversal();
    122121               
     
    179178void visual_core::addManipulators()
    180179{
    181         // set up the camera manipulators.
     180        if(!visual_dataIO::getInstance()->isSlave()) // set up the camera manipulators if not slave.
    182181    {
    183182        osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator;
     
    221220
    222221        viewer->setCameraManipulator( keyswitchManipulator.get() );
    223     }
     222    }   // If not Slave END
    224223
    225224    // add the state manipulator
     
    328327#endif
    329328
    330         osgGA::NodeTrackerManipulator::TrackerMode trackerMode = osgGA::NodeTrackerManipulator::NODE_CENTER;
    331         osgGA::NodeTrackerManipulator::RotationMode rotationMode = osgGA::NodeTrackerManipulator::ELEVATION_AZIM;
    332         nt->setTrackerMode(trackerMode);
    333     nt->setRotationMode(rotationMode);
    334         //nt->setAutoComputeHomePosition( true );
    335         nt->setMinimumDistance( 100 );
    336         nt->setTrackNode(testObj4->getGeometry());
    337         //nt->computeHomePosition();
    338         nt->setAutoComputeHomePosition( true );
    339         nt->setDistance( 250 );
     329        if(nt.valid())
     330        {
     331                osgGA::NodeTrackerManipulator::TrackerMode trackerMode = osgGA::NodeTrackerManipulator::NODE_CENTER;
     332                osgGA::NodeTrackerManipulator::RotationMode rotationMode = osgGA::NodeTrackerManipulator::ELEVATION_AZIM;
     333                nt->setTrackerMode(trackerMode);
     334                nt->setRotationMode(rotationMode);
     335                //nt->setAutoComputeHomePosition( true );
     336                nt->setMinimumDistance( 100 );
     337                nt->setTrackNode(testObj4->getGeometry());
     338                //nt->computeHomePosition();
     339                nt->setAutoComputeHomePosition( true );
     340                nt->setDistance( 250 );
     341        }
    340342
    341343
     
    376378
    377379        visual_dataIO::getInstance()->setSlotData("TestSlot1", osgVisual::dataIO_slot::TO_OBJ, 0.12345);
    378 
    379 
    380         //// Writing object to stream
    381         ////std::ofstream myOstream("test.txt" );
    382         //std::stringstream myOstream;
    383         //std::string extension = "osgb";
    384         //bool compressed = false;
    385         //osgDB::ReaderWriter* rw = osgDB::Registry::instance()->getReaderWriterForExtension(extension.c_str());
    386         //if ( rw )
    387         //{
    388         //      osgDB::ReaderWriter::WriteResult wr;
    389 
    390         //      if (extension == "osgb")
    391         //      {
    392         //              if (compressed)
    393         //                      wr = rw->writeObject( *test, myOstream, new osgDB::Options("Compressor=zlib") );
    394         //              else
    395         //                      wr = rw->writeObject( *test, myOstream );
    396         //      }
    397 
    398         //      if (extension == "osgt")
    399         //      {
    400         //              if (compressed)
    401         //                      wr = rw->writeObject( *test, myOstream, new osgDB::Options("Ascii Compressor=zlib") );
    402         //              else
    403         //                      wr = rw->writeObject( *test, myOstream, new osgDB::Options("Ascii") );
    404         //      }
    405 
    406         //      if (extension == "osgx")
    407         //      {
    408         //              if (compressed)
    409         //                      wr = rw->writeObject( *test, myOstream, new osgDB::Options("XML Compressor=zlib") );
    410         //              else
    411         //                      wr = rw->writeObject( *test, myOstream, new osgDB::Options("XML") );
    412         //      }
    413 
    414 
    415         //      if (!wr.success() )     OSG_NOTIFY( osg::WARN ) << "ERROR: Save failed: " << wr.message() << std::endl;
    416         //}
    417         //else
    418         //      OSG_NOTIFY( osg::WARN ) << "error getting readerWriter for osgt" << std::endl;
    419 
    420         //// Size ermitteln.
    421         //std::stringbuf *pbuf;
    422         //pbuf = myOstream.rdbuf();
    423         //OSG_NOTIFY( osg::WARN ) << "PBUF Bytes available: " << pbuf->in_avail() << std::endl;
    424         //OSG_NOTIFY( osg::ALWAYS ) << "STRING Bytes available: " << myOstream.str().length() << std::endl;
    425         //OSG_NOTIFY( osg::ALWAYS ) << "STRING content: " << myOstream.str() << std::endl;
    426 
    427         ////Reading Stream to node
    428         //if ( rw )
    429         //{
    430         //      osgDB::ReaderWriter::ReadResult rr = rw->readObject( myOstream );
    431         //      osg::ref_ptr<osgVisual::dataIO_transportContainer> test2 = dynamic_cast<osgVisual::dataIO_transportContainer*>(rr.takeObject());
    432         //      if (test2)
    433         //      {
    434         //              OSG_NOTIFY( osg::WARN ) << "TEST::FrameID is: " << test->getFrameID() << std::endl;
    435         //      }
    436         //      else
    437         //              OSG_NOTIFY( osg::WARN ) << "Error converting stream to Node" << std::endl;
    438         //}
    439 }
     380}
Note: See TracChangeset for help on using the changeset viewer.