Changeset 212


Ignore:
Timestamp:
Jan 30, 2011, 8:30:23 PM (13 years ago)
Author:
Torben Dannhauer
Message:
 
Location:
osgVisual/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • osgVisual/trunk/bin/osgVisualConfig.xml

    r208 r212  
    4343      <!-- Models can be loaded and placed in the scenery.
    4444        - objectname: Name of the object to identify it in the scenegraph.
     45        - tracking ID: ID to manage which object should be tracked
    4546        - label: text to label the model with.
    4647        - dynamic: "yes" to add an standard updater to the model.
     
    5354        - Geometryscale [optional]: Scale factors for the loaded 3D model in all three dimensions.
    5455      -->
    55       <model objectname="TestObject" label="TestText!" dynamic="yes">
     56      <model objectname="TestObject" trackingid="1" label="TestText!" dynamic="yes">
    5657        <position lat="47.12345" lon="11.234567" alt="1500.0"></position>
    5758        <attitude rot_x="0.0" rot_y="0.0" rot_z="0.0"></attitude>
     
    6566          <rotation rot_x="0.0" rot_y="0.0" rot_z="0.0"></rotation>
    6667        </cameraoffset>
    67         <geometry filename="../models/Boing777-200.ive">
     68        <geometry filename="../models/saenger1.flt">
    6869          <offset rot_x="0.0" rot_y="0.0" rot_z="0.0"></offset>
    6970          <scalefactor scale_x="1.0" scale_y="1.0" scale_z="1.0"></scalefactor>
    7071        </geometry>
    7172      </model>
     73      <trackmodel id="1"></trackmodel>
    7274    </models>
    7375    <datetime day="0" month="0" year="0" hour="12" minute="30"></datetime>
  • osgVisual/trunk/include/core/visual_core.h

    r187 r212  
    111111
    112112        void setupScenery();
     113        void trackNode( osg::Node* node_ );
    113114       
    114115protected:
  • osgVisual/trunk/src/core/visual_core.cpp

    r211 r212  
    404404                        }
    405405                }
     406
     407                // Track Node
     408
    406409#endif
    407410        }// FOR all nodes END
     
    414417        arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName());
    415418        arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the new FSD visualization tool, written by Torben Dannhauer");
    416     arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] Terrain_filename");
     419    arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [OSG options] -c XML-Configurationfile");
    417420        arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information");
     421        arguments.getApplicationUsage()->addCommandLineOption("-c or --config","XML configuration filename");
     422
    418423
    419424    // if user request help write it out to cout.
     
    470475        ////testObj2->addUpdater( new object_updater(testObj2) );       // todo memleak
    471476
    472         osg::ref_ptr<visual_object> testObj3 = new visual_object( rootNode, "SAENGER1" );       // todo memleak
    473         testObj3->setNewPosition( osg::DegreesToRadians(47.8123), osg::DegreesToRadians(12.94088), 600 );
    474         testObj3->loadGeometry( "../models/saenger1.flt" );
    475         testObj3->addUpdater( new object_updater(testObj3) );   // todo memleak
    476        
     477        //osg::ref_ptr<visual_object> testObj3 = new visual_object( rootNode, "SAENGER1" );     // todo memleak
     478        //testObj3->setNewPosition( osg::DegreesToRadians(47.8123), osg::DegreesToRadians(12.94088), 600 );
     479        //testObj3->loadGeometry( "../models/saenger1.flt" );
     480        //testObj3->addUpdater( new object_updater(testObj3) ); // todo memleak
     481        //
    477482
    478483        osg::ref_ptr<visual_object> testObj4 = new visual_object( rootNode, "SAENGER2" );       // todo memleak
     
    482487        testObj4->addLabel("testLabel", "LabelTest!!\nnächste Zeile :)",osg::Vec4(1.0f,0.25f,1.0f,1.0f));
    483488
    484         osg::ref_ptr<visual_object> testObj5 = new visual_object( rootNode, "SAENGER" );        // todo memleak
    485         testObj5->setNewPosition( osg::DegreesToRadians(47.8123), osg::DegreesToRadians(12.94088), 550 );
    486         testObj5->loadGeometry( "../models/saengerCombine.flt" );
    487         //testObj5->setScale( 2 );
    488         testObj5->addUpdater( new object_updater(testObj5) );   // todo memleak
    489 
    490 #ifdef USE_SPACENAVIGATOR
    491         // Manipulatoren auf dieses Objekt binden (Primärobjekt)
    492         if (objectMountedCameraManip.valid())
    493                 objectMountedCameraManip->setAttachedObject( testObj4 );
    494         if (mouseTrackerManip.valid())
    495         {
    496                 mouseTrackerManip->setTrackNode( testObj4->getGeometry() );
    497                 mouseTrackerManip->setMinimumDistance( 100 );
    498         }
    499 #endif
    500 
    501         if(nt.valid())
    502         {
    503                 osgGA::NodeTrackerManipulator::TrackerMode trackerMode = osgGA::NodeTrackerManipulator::NODE_CENTER;
    504                 osgGA::NodeTrackerManipulator::RotationMode rotationMode = osgGA::NodeTrackerManipulator::ELEVATION_AZIM;
    505                 nt->setTrackerMode(trackerMode);
    506                 nt->setRotationMode(rotationMode);
    507                 //nt->setAutoComputeHomePosition( true );
    508                 nt->setMinimumDistance( 100 );
    509                 nt->setTrackNode(testObj4->getGeometry());
    510                 //nt->computeHomePosition();
    511                 nt->setAutoComputeHomePosition( true );
    512                 nt->setDistance( 250 );
    513         }
    514 
     489        //osg::ref_ptr<visual_object> testObj5 = new visual_object( rootNode, "SAENGER" );      // todo memleak
     490        //testObj5->setNewPosition( osg::DegreesToRadians(47.8123), osg::DegreesToRadians(12.94088), 550 );
     491        //testObj5->loadGeometry( "../models/saengerCombine.flt" );
     492        ////testObj5->setScale( 2 );
     493        //testObj5->addUpdater( new object_updater(testObj5) ); // todo memleak
     494
     495        trackNode( testObj4 );
    515496
    516497        // Load EDDF
     
    553534
    554535}
     536
     537void visual_core::trackNode( osg::Node* node_ )
     538{
     539        if(!node_)
     540                return;
     541
     542        osg::Node* node = NULL;
     543        // Check if tracked node is a visual_object
     544        osgVisual::visual_object* trackedObject = dynamic_cast<osgVisual::visual_object*>(node_);
     545        if(trackedObject)
     546        {
     547                if(trackedObject->getGeometry())
     548                        node = trackedObject->getGeometry();
     549                else
     550                        node = trackedObject;
     551        }
     552        else
     553                node = node_;
     554
     555        // Object mounted manipulator
     556        if (objectMountedCameraManip.valid())
     557                objectMountedCameraManip->setAttachedObject( node );
     558       
     559        // Spacemouse Node Tracker
     560#ifdef USE_SPACENAVIGATOR
     561        if (mouseTrackerManip.valid())
     562        {
     563                mouseTrackerManip->setTrackNode( node );
     564                mouseTrackerManip->setMinimumDistance( 100 );
     565        }
     566#endif
     567
     568        // Classical OSG Nodetracker
     569        if(nt.valid())
     570        {
     571                osgGA::NodeTrackerManipulator::TrackerMode trackerMode = osgGA::NodeTrackerManipulator::NODE_CENTER;
     572                osgGA::NodeTrackerManipulator::RotationMode rotationMode = osgGA::NodeTrackerManipulator::ELEVATION_AZIM;
     573                nt->setTrackerMode(trackerMode);
     574                nt->setRotationMode(rotationMode);
     575                nt->setMinimumDistance( 100 );
     576                nt->setTrackNode( node );
     577                nt->setAutoComputeHomePosition( true );
     578                nt->setDistance( 250 );
     579        }
     580}
Note: See TracChangeset for help on using the changeset viewer.