Changeset 231
- Timestamp:
- Feb 13, 2011, 6:08:42 PM (14 years ago)
- Location:
- osgVisual/trunk
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
osgVisual/trunk/CMakeLists.txt
r199 r231 291 291 src/core/visual_core.cpp 292 292 src/core/osgVisual.cpp 293 src/core/core_manipulator.h 294 src/core/core_manipulator.cpp 293 295 # Memory Leak debugging 294 296 include/core/leakDetection.h -
osgVisual/trunk/include/core/visual_core.h
r228 r231 24 24 #include <osg/Referenced> 25 25 #include <osg/Notify> 26 27 26 #include <osgViewer/Viewer> 28 29 27 #include <osgDB/ReadFile> 30 28 31 // OSGeventhandler32 #include < osgViewer/ViewerEventHandlers>29 // Manipulator and eventhandler 30 #include <core_manipulator.h> 33 31 34 // OSG manipulator35 #include <osgGA/TrackballManipulator>36 #include <osgGA/FlightManipulator>37 #include <osgGA/DriveManipulator>38 #include <osgGA/KeySwitchMatrixManipulator>39 #include <osgGA/StateSetManipulator>40 #include <osgGA/AnimationPathManipulator>41 #include <osgGA/TerrainManipulator>42 #include <osgGA/NodeTrackerManipulator>43 44 // Spacenavigator manipulator45 #ifdef USE_SPACENAVIGATOR46 #include <manip_spaceMouse.h>47 #include <manip_nodeTrackerSpaceMouse.h>48 #include <manip_freeSpaceMouse.h>49 #endif50 51 // Object mounted manipulator52 #include <manip_objectMounted.h>53 32 54 33 #ifdef USE_DISTORTION … … 85 64 #endif 86 65 66 67 87 68 // Test 88 69 #include <dataIO_transportContainer.h> … … 105 86 void shutdown(); 106 87 107 void addManipulators();108 88 void parseScenery(xmlNode * a_node); 109 89 bool loadTerrain(osg::ArgumentParser& arguments_); … … 111 91 112 92 void setupScenery(); 113 void trackNode( osg::Node* node_ );114 void trackNode( int trackingID );115 int getCurrentTrackingID(){return currentTrackingID;};116 93 117 94 protected: 95 /** 96 * \brief Destrcutor 97 * 98 */ 118 99 virtual ~visual_core(void); 119 100 120 121 101 private: 102 /** 103 * \brief This function starts the main rendering loop 104 * 105 */ 122 106 void mainLoop(); 123 107 … … 143 127 144 128 145 #ifdef USE_SPACENAVIGATOR146 /**147 * Spacemouse node tracker manipulator148 */149 osg::ref_ptr<NodeTrackerSpaceMouse> mouseTrackerManip;150 151 /**152 * Space mouse hardware driver instance153 */154 SpaceMouse* mouse;155 #endif156 157 /**158 * This Matrix manipulator is used for controlling Camera by Nodes.159 */160 osg::ref_ptr<objectMountedManipulator> objectMountedCameraManip;161 162 129 163 130 #ifdef USE_SKY_SILVERLINING … … 181 148 osg::ref_ptr<visual_object> testObj; 182 149 183 osg::ref_ptr<osgGA::NodeTrackerManipulator> nt;184 185 150 osg::ref_ptr<visual_debug_hud> hud; 186 151 187 int currentTrackingID;152 osg::ref_ptr<core_manipulator> manipulators; 188 153 }; 189 154 -
osgVisual/trunk/src/core/visual_core.cpp
r228 r231 23 23 { 24 24 OSG_NOTIFY( osg::ALWAYS ) << "visual_core instantiated." << std::endl; 25 26 currentTrackingID = -1;27 25 } 28 26 … … 60 58 // Test memory leak (todo) 61 59 double* test = new double[1000]; 62 63 #ifdef USE_SPACENAVIGATOR64 mouse = NULL;65 #endif66 60 67 61 //osg::DisplaySettings::instance()->setNumOfDatabaseThreadsHint( 8 ); … … 91 85 92 86 // Add manipulators for user interaction - after dataIO to be able to skip it in slaves rendering machines. 93 addManipulators(); 87 manipulators = new core_manipulator(); 88 manipulators->init( viewer, arguments, configFilename, rootNode); 94 89 95 90 // create the windows and run the threads. … … 164 159 visual_dataIO::getInstance()->shutdown(); 165 160 166 167 #ifdef USE_SPACENAVIGATOR 168 //Delete SpaceMouse driver 169 if(mouse) 170 { 171 mouse->shutdown(); 172 delete mouse; 173 } 174 #endif 161 // Shutdown manipulators 162 if(manipulators.valid()) 163 manipulators->shutdown(); 175 164 176 165 // Destroy osgViewer … … 197 186 void visual_core::addManipulators() 198 187 { 199 if(!visual_dataIO::getInstance()->isSlave()) // set up the camera manipulators if not slave. 200 { 201 osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; 202 203 keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() ); 204 keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() ); 205 keyswitchManipulator->addMatrixManipulator( '3', "Terrain", new osgGA::TerrainManipulator() ); 206 nt = new osgGA::NodeTrackerManipulator(); 207 nt->setTrackNode(NULL); 208 keyswitchManipulator->addMatrixManipulator( '4', "NodeTrackerManipulator", nt ); 209 210 #ifdef USE_SPACENAVIGATOR 211 // SpaceNavigator manipulator 212 mouse = new SpaceMouse(); 213 mouse->initialize(); 214 mouseTrackerManip = new NodeTrackerSpaceMouse(mouse); 215 mouseTrackerManip->setTrackerMode(NodeTrackerSpaceMouse::NODE_CENTER); 216 mouseTrackerManip->setRotationMode(NodeTrackerSpaceMouse::ELEVATION_AZIM); 217 mouseTrackerManip->setAutoComputeHomePosition( true ); 218 keyswitchManipulator->addMatrixManipulator( '5', "Spacemouse Node Tracker", mouseTrackerManip ); 219 keyswitchManipulator->addMatrixManipulator( '6', "Spacemouse Free (Airplane)", new FreeManipulator(mouse) ); 220 #endif 221 222 // objectMounted Manipulator for Camera control by Nodes 223 objectMountedCameraManip = new objectMountedManipulator(); 224 keyswitchManipulator->addMatrixManipulator( '7', "Object mounted Camera", objectMountedCameraManip ); 225 226 // Animation path manipulator 227 std::string pathfile = util::getAnimationPathFromXMLConfig(configFilename); 228 char keyForAnimationPath = '8'; 229 if( pathfile != "" ) 230 { 231 osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile); 232 if (apm || !apm->valid()) 233 { 234 unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); 235 keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm ); 236 keyswitchManipulator->selectMatrixManipulator(num); 237 ++keyForAnimationPath; 238 } 239 } 240 241 viewer->setCameraManipulator( keyswitchManipulator.get() ); 242 } // If not Slave END 243 244 // add the state manipulator 245 viewer->addEventHandler( new osgGA::StateSetManipulator(rootNode->getOrCreateStateSet()) ); 246 247 // add the thread model handler 248 viewer->addEventHandler(new osgViewer::ThreadingHandler); 249 250 // add the window size toggle handler 251 viewer->addEventHandler(new osgViewer::WindowSizeHandler); 252 253 // add the stats handler 254 viewer->addEventHandler(new osgViewer::StatsHandler); 255 256 // add the help handler 257 viewer->addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage())); 258 259 // add the record camera path handler 260 viewer->addEventHandler(new osgViewer::RecordCameraPathHandler); 261 262 // add the LOD Scale handler 263 viewer->addEventHandler(new osgViewer::LODScaleHandler); 264 265 // add the screen capture handler 266 viewer->addEventHandler(new osgViewer::ScreenCaptureHandler); 188 267 189 } 268 190 … … 297 219 std::string attr_name=reinterpret_cast<const char*>(attr->name); 298 220 std::string attr_value=reinterpret_cast<const char*>(attr->children->content); 299 if( attr_name == "id" ) trackNode( util::strToInt(attr_value) );221 if( attr_name == "id" ) manipulators->trackNode( util::strToInt(attr_value) ); 300 222 301 223 … … 510 432 511 433 } 512 513 void visual_core::trackNode( osg::Node* node_ )514 {515 if(!node_)516 return;517 518 osg::Node* node = NULL;519 // Check if tracked node is a visual_object520 osgVisual::visual_object* trackedObject = dynamic_cast<osgVisual::visual_object*>(node_);521 if(trackedObject)522 {523 node = trackedObject->getGeometry();524 525 // Object mounted manipulator ( Only working with visual_object, not with osg::Node )526 if (objectMountedCameraManip.valid())527 objectMountedCameraManip->setAttachedObject( trackedObject );528 }529 else530 node = node_;531 532 // Spacemouse Node Tracker533 #ifdef USE_SPACENAVIGATOR534 if (mouseTrackerManip.valid())535 {536 mouseTrackerManip->setTrackNode( node );537 mouseTrackerManip->setMinimumDistance( 100 );538 }539 #endif540 541 // Classical OSG Nodetracker542 if(nt.valid())543 {544 osgGA::NodeTrackerManipulator::TrackerMode trackerMode = osgGA::NodeTrackerManipulator::NODE_CENTER;545 osgGA::NodeTrackerManipulator::RotationMode rotationMode = osgGA::NodeTrackerManipulator::ELEVATION_AZIM;546 nt->setTrackerMode(trackerMode);547 nt->setRotationMode(rotationMode);548 nt->setMinimumDistance( 100 );549 nt->setTrackNode( node );550 nt->setAutoComputeHomePosition( true );551 nt->setDistance( 250 );552 }553 }554 555 void visual_core::trackNode( int trackingID )556 {557 osg::ref_ptr<osg::Node> tmp = visual_object::findNodeByTrackingID(trackingID, rootNode);558 if(tmp.valid())559 {560 currentTrackingID = trackingID;561 trackNode(tmp);562 }563 } -
osgVisual/trunk/src/dataIO/visual_dataIO.cpp
r221 r231 62 62 //// EventCallback at the absolute beginning of the frame 63 63 eventCallback = new dataIO_eventCallback(this); 64 viewer->getCamera()-> setEventCallback( eventCallback );64 viewer->getCamera()->addEventCallback( eventCallback ); 65 65 //// FinalDrawCallback at the end of event and update handling, but BEFORE rendering the frame 66 66 finalDrawCallback = new dataIO_finalDrawCallback(this);
Note: See TracChangeset
for help on using the changeset viewer.