Ignore:
Timestamp:
Jul 20, 2010, 10:44:13 AM (14 years ago)
Author:
Torben Dannhauer
Message:

Network sync:
now works:

  • serialization of transport container
  • transport via ENet UDP
  • de-serialization of the transport container.
  • transport of viewmatrix and framenumber to the slave.

ToDo?: apply viewmatrix on slave still do not work.

File:
1 edited

Legend:

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

    r68 r69  
    362362        //test->init( rootNode, viewer );
    363363
    364         // Creating Testclasses
    365         osg::ref_ptr<osgVisual::dataIO_transportContainer> test = new osgVisual::dataIO_transportContainer();
    366         osg::ref_ptr<osgVisual::dataIO_executer> testEx = new osgVisual::dataIO_executer();
    367         osg::ref_ptr<osgVisual::dataIO_slot> testSlot = new osgVisual::dataIO_slot();
    368         test->setFrameID( 22 );
    369         test->setName("ugamoep");
    370         testEx->setexecuterID( osgVisual::dataIO_executer::IS_COLLISION );
    371         testSlot->setVariableName(std::string("HalloName"));
    372         testSlot->setdataDirection( osgVisual::dataIO_slot::TO_OBJ );
    373         testSlot->setvarType( osgVisual::dataIO_slot::DOUBLE );
    374         testSlot->setValue( 0.12345 );
    375         test->addExecuter( testEx );
    376         test->addSlot( testSlot );
    377 
    378         // Writing object to stream
    379         //std::ofstream myOstream("test.txt" );
    380         std::stringstream myOstream;
    381         std::string extension = "osgb";
    382         bool compressed = false;
    383         osgDB::ReaderWriter* rw = osgDB::Registry::instance()->getReaderWriterForExtension(extension.c_str());
    384         if ( rw )
    385         {
    386                 osgDB::ReaderWriter::WriteResult wr;
    387 
    388                 if (extension == "osgb")
    389                 {
    390                         if (compressed)
    391                                 wr = rw->writeObject( *test, myOstream, new osgDB::Options("Compressor=zlib") );
    392                         else
    393                                 wr = rw->writeObject( *test, myOstream );
    394                 }
    395 
    396                 if (extension == "osgt")
    397                 {
    398                         if (compressed)
    399                                 wr = rw->writeObject( *test, myOstream, new osgDB::Options("Ascii Compressor=zlib") );
    400                         else
    401                                 wr = rw->writeObject( *test, myOstream, new osgDB::Options("Ascii") );
    402                 }
    403 
    404                 if (extension == "osgx")
    405                 {
    406                         if (compressed)
    407                                 wr = rw->writeObject( *test, myOstream, new osgDB::Options("XML Compressor=zlib") );
    408                         else
    409                                 wr = rw->writeObject( *test, myOstream, new osgDB::Options("XML") );
    410                 }
    411 
    412 
    413                 if (!wr.success() )     OSG_NOTIFY( osg::WARN ) << "ERROR: Save failed: " << wr.message() << std::endl;
    414         }
    415         else
    416                 OSG_NOTIFY( osg::WARN ) << "error getting readerWriter for osgt" << std::endl;
    417 
    418         // Size ermitteln.
    419         std::stringbuf *pbuf;
    420         pbuf = myOstream.rdbuf();
    421         OSG_NOTIFY( osg::WARN ) << "PBUF Bytes available: " << pbuf->in_avail() << std::endl;
    422         OSG_NOTIFY( osg::ALWAYS ) << "STRING Bytes available: " << myOstream.str().length() << std::endl;
    423         OSG_NOTIFY( osg::ALWAYS ) << "STRING content: " << myOstream.str() << std::endl;
    424 
    425         //Reading Stream to node
    426         if ( rw )
    427         {
    428                 osgDB::ReaderWriter::ReadResult rr = rw->readObject( myOstream );
    429                 osg::ref_ptr<osgVisual::dataIO_transportContainer> test2 = dynamic_cast<osgVisual::dataIO_transportContainer*>(rr.takeObject());
    430                 if (test2)
    431                 {
    432                         OSG_NOTIFY( osg::WARN ) << "TEST::FrameID is: " << test->getFrameID() << std::endl;
    433                 }
    434                 else
    435                         OSG_NOTIFY( osg::WARN ) << "Error converting stream to Node" << std::endl;
    436         }
    437 }
     364        //// Creating Testclasses
     365        //osg::ref_ptr<osgVisual::dataIO_transportContainer> test = new osgVisual::dataIO_transportContainer();
     366        //osg::ref_ptr<osgVisual::dataIO_executer> testEx = new osgVisual::dataIO_executer();
     367        //osg::ref_ptr<osgVisual::dataIO_slot> testSlot = new osgVisual::dataIO_slot();
     368        //test->setFrameID( 22 );
     369        //test->setName("ugamoep");
     370        //testEx->setexecuterID( osgVisual::dataIO_executer::IS_COLLISION );
     371        //testSlot->setVariableName(std::string("HalloName"));
     372        //testSlot->setdataDirection( osgVisual::dataIO_slot::TO_OBJ );
     373        //testSlot->setvarType( osgVisual::dataIO_slot::DOUBLE );
     374        //testSlot->setValue( 0.12345 );
     375        //test->addExecuter( testEx );
     376        //test->addSlot( testSlot );
     377
     378        visual_dataIO::getInstance()->setSlotData("TestSlot1", osgVisual::dataIO_slot::TO_OBJ, 0.12345);
     379
     380
     381        //// Writing object to stream
     382        ////std::ofstream myOstream("test.txt" );
     383        //std::stringstream myOstream;
     384        //std::string extension = "osgb";
     385        //bool compressed = false;
     386        //osgDB::ReaderWriter* rw = osgDB::Registry::instance()->getReaderWriterForExtension(extension.c_str());
     387        //if ( rw )
     388        //{
     389        //      osgDB::ReaderWriter::WriteResult wr;
     390
     391        //      if (extension == "osgb")
     392        //      {
     393        //              if (compressed)
     394        //                      wr = rw->writeObject( *test, myOstream, new osgDB::Options("Compressor=zlib") );
     395        //              else
     396        //                      wr = rw->writeObject( *test, myOstream );
     397        //      }
     398
     399        //      if (extension == "osgt")
     400        //      {
     401        //              if (compressed)
     402        //                      wr = rw->writeObject( *test, myOstream, new osgDB::Options("Ascii Compressor=zlib") );
     403        //              else
     404        //                      wr = rw->writeObject( *test, myOstream, new osgDB::Options("Ascii") );
     405        //      }
     406
     407        //      if (extension == "osgx")
     408        //      {
     409        //              if (compressed)
     410        //                      wr = rw->writeObject( *test, myOstream, new osgDB::Options("XML Compressor=zlib") );
     411        //              else
     412        //                      wr = rw->writeObject( *test, myOstream, new osgDB::Options("XML") );
     413        //      }
     414
     415
     416        //      if (!wr.success() )     OSG_NOTIFY( osg::WARN ) << "ERROR: Save failed: " << wr.message() << std::endl;
     417        //}
     418        //else
     419        //      OSG_NOTIFY( osg::WARN ) << "error getting readerWriter for osgt" << std::endl;
     420
     421        //// Size ermitteln.
     422        //std::stringbuf *pbuf;
     423        //pbuf = myOstream.rdbuf();
     424        //OSG_NOTIFY( osg::WARN ) << "PBUF Bytes available: " << pbuf->in_avail() << std::endl;
     425        //OSG_NOTIFY( osg::ALWAYS ) << "STRING Bytes available: " << myOstream.str().length() << std::endl;
     426        //OSG_NOTIFY( osg::ALWAYS ) << "STRING content: " << myOstream.str() << std::endl;
     427
     428        ////Reading Stream to node
     429        //if ( rw )
     430        //{
     431        //      osgDB::ReaderWriter::ReadResult rr = rw->readObject( myOstream );
     432        //      osg::ref_ptr<osgVisual::dataIO_transportContainer> test2 = dynamic_cast<osgVisual::dataIO_transportContainer*>(rr.takeObject());
     433        //      if (test2)
     434        //      {
     435        //              OSG_NOTIFY( osg::WARN ) << "TEST::FrameID is: " << test->getFrameID() << std::endl;
     436        //      }
     437        //      else
     438        //              OSG_NOTIFY( osg::WARN ) << "Error converting stream to Node" << std::endl;
     439        //}
     440}
Note: See TracChangeset for help on using the changeset viewer.