[31] | 1 | /* -*-c++-*- osgVisual - Copyright (C) 2009-2010 Torben Dannhauer |
---|
| 2 | * |
---|
| 3 | * This library is based on OpenSceneGraph, open source and may be redistributed and/or modified under |
---|
| 4 | * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or |
---|
| 5 | * (at your option) any later version. The full license is in LICENSE file |
---|
| 6 | * included with this distribution, and on the openscenegraph.org website. |
---|
| 7 | * |
---|
| 8 | * osgVisual requires for some proprietary modules a license from the correspondig manufacturer. |
---|
| 9 | * You have to aquire licenses for all used proprietary modules. |
---|
| 10 | * |
---|
| 11 | * This library is distributed in the hope that it will be useful, |
---|
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
| 14 | * OpenSceneGraph Public License for more details. |
---|
| 15 | */ |
---|
| 16 | |
---|
[86] | 17 | |
---|
[31] | 18 | #include <visual_core.h> |
---|
| 19 | |
---|
| 20 | using namespace osgVisual; |
---|
| 21 | |
---|
| 22 | visual_core::visual_core(osg::ArgumentParser& arguments_) : arguments(arguments_) |
---|
| 23 | { |
---|
| 24 | OSG_NOTIFY( osg::ALWAYS ) << "visual_core instantiated." << std::endl; |
---|
[86] | 25 | } |
---|
[31] | 26 | |
---|
[86] | 27 | visual_core::~visual_core(void) |
---|
| 28 | { |
---|
| 29 | OSG_NOTIFY( osg::ALWAYS ) << "visual_core destroyed." << std::endl; |
---|
| 30 | } |
---|
| 31 | |
---|
| 32 | void visual_core::initialize() |
---|
| 33 | { |
---|
| 34 | OSG_NOTIFY( osg::ALWAYS ) << "Initialize visual_core..." << std::endl; |
---|
| 35 | |
---|
| 36 | // Configure osg to use KdTrees |
---|
| 37 | osgDB::Registry::instance()->setBuildKdTreesHint(osgDB::ReaderWriter::Options::BUILD_KDTREES); |
---|
| 38 | |
---|
[31] | 39 | // Setup pathes |
---|
| 40 | osgDB::Registry::instance()->getDataFilePathList().push_back( "D:\\DA\\osgVisual\\models" ); |
---|
| 41 | |
---|
| 42 | // Setup viewer |
---|
| 43 | viewer = new osgViewer::Viewer(arguments); |
---|
| 44 | |
---|
| 45 | // Setup coordinate system node |
---|
[87] | 46 | rootNode = new osg::CoordinateSystemNode; // todo memleakf |
---|
[31] | 47 | rootNode->setEllipsoidModel(new osg::EllipsoidModel()); |
---|
| 48 | |
---|
| 49 | // Test memory leak (todo) |
---|
[116] | 50 | double* test = new double[1000]; |
---|
[31] | 51 | |
---|
[55] | 52 | #ifdef USE_SPACENAVIGATOR |
---|
| 53 | mouse = NULL; |
---|
| 54 | #endif |
---|
| 55 | |
---|
| 56 | //osg::DisplaySettings::instance()->setNumOfDatabaseThreadsHint( 8 ); |
---|
[31] | 57 | |
---|
| 58 | // Show model |
---|
| 59 | viewer->setSceneData( rootNode ); |
---|
| 60 | |
---|
[71] | 61 | osg::Group* distortedSceneGraph = NULL; |
---|
[31] | 62 | #ifdef USE_DISTORTION |
---|
| 63 | // Initialize distortion |
---|
[71] | 64 | OSG_NOTIFY( osg::ALWAYS ) << "Using distortion." << std::endl; |
---|
[31] | 65 | distortion = new visual_distortion( viewer, arguments ); |
---|
| 66 | distortion->initialize( rootNode, viewer->getCamera()->getClearColor() ); |
---|
[71] | 67 | distortedSceneGraph = distortion->getDistortedSceneGraph(); |
---|
[31] | 68 | #endif |
---|
| 69 | |
---|
| 70 | #ifdef USE_SKY_SILVERLINING |
---|
| 71 | // Initialize sky |
---|
| 72 | sky = new visual_skySilverLining( viewer ); |
---|
[72] | 73 | sky->init(distortedSceneGraph, rootNode); // Without distortedSceneGraph=NULL |
---|
[31] | 74 | #endif |
---|
| 75 | |
---|
| 76 | // Initialize DataIO interface |
---|
| 77 | visual_dataIO::getInstance()->init(viewer, arguments); |
---|
| 78 | |
---|
[73] | 79 | // Add manipulators for user interaction - after dataIO to be able to skip it in slaves. |
---|
| 80 | addManipulators(); |
---|
| 81 | |
---|
[68] | 82 | loadTerrain(arguments); |
---|
| 83 | |
---|
[31] | 84 | // create the windows and run the threads. |
---|
| 85 | viewer->realize(); |
---|
| 86 | |
---|
| 87 | // setup scenery |
---|
| 88 | setupScenery(); |
---|
| 89 | |
---|
[127] | 90 | // parse Configuration file |
---|
| 91 | parseConfigFile(arguments); |
---|
| 92 | |
---|
| 93 | // All modules are initialized - now check arguments for any unused parameter. |
---|
| 94 | checkCommandlineArgumentsForFinalErrors(); |
---|
| 95 | |
---|
[31] | 96 | // Run visual main loop |
---|
| 97 | mainLoop(); |
---|
| 98 | } |
---|
| 99 | |
---|
| 100 | void visual_core::mainLoop() |
---|
| 101 | { |
---|
| 102 | // run main loop |
---|
| 103 | while( !viewer->done() ) |
---|
| 104 | { |
---|
| 105 | // next frame please.... |
---|
| 106 | viewer->advance(); |
---|
| 107 | |
---|
| 108 | /*double hat, hot, lat, lon, height; |
---|
| 109 | util::getWGS84ofCamera( viewer->getCamera(), rootNode, lat, lon, height); |
---|
| 110 | if (util::queryHeightOfTerrain( hot, rootNode, lat, lon) && util::queryHeightAboveTerrainInWGS84( hat, rootNode, lat, lon, height ) ) |
---|
| 111 | OSG_NOTIFY( osg::ALWAYS ) << "HOT is: " << hot << ", HAT is: " << hat << std::endl;*/ |
---|
| 112 | |
---|
[70] | 113 | // perform all queued events |
---|
| 114 | viewer->eventTraversal(); |
---|
| 115 | |
---|
[31] | 116 | // update the scene by traversing it with the the update visitor which will |
---|
| 117 | // call all node update callbacks and animations. |
---|
| 118 | viewer->updateTraversal(); |
---|
| 119 | |
---|
| 120 | // Render the Frame. |
---|
| 121 | viewer->renderingTraversals(); |
---|
| 122 | |
---|
| 123 | } // END WHILE |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | void visual_core::shutdown() |
---|
| 127 | { |
---|
| 128 | OSG_NOTIFY( osg::ALWAYS ) << "Shutdown visual_core..." << std::endl; |
---|
| 129 | |
---|
[87] | 130 | // Shutdown Dbug HUD |
---|
| 131 | if(hud.valid()) |
---|
| 132 | hud->shutdown(); |
---|
[31] | 133 | // Unset scene data |
---|
| 134 | viewer->setSceneData( NULL ); |
---|
| 135 | |
---|
| 136 | #ifdef USE_SKY_SILVERLINING |
---|
| 137 | // Shutdown sky |
---|
| 138 | if( sky.valid() ) |
---|
| 139 | sky->shutdown(); |
---|
| 140 | #endif |
---|
| 141 | |
---|
| 142 | #ifdef USE_DISTORTION |
---|
| 143 | // Shutdown distortion |
---|
| 144 | if( distortion.valid() ) |
---|
| 145 | distortion->shutdown(); |
---|
| 146 | #endif |
---|
| 147 | |
---|
[87] | 148 | // Shutdown data |
---|
| 149 | rootNode = NULL; |
---|
| 150 | |
---|
[31] | 151 | // Shutdown dataIO |
---|
| 152 | visual_dataIO::getInstance()->shutdown(); |
---|
| 153 | |
---|
| 154 | |
---|
| 155 | #ifdef USE_SPACENAVIGATOR |
---|
| 156 | //Delete SpaceMouse driver |
---|
| 157 | if(mouse) |
---|
| 158 | { |
---|
| 159 | mouse->shutdown(); |
---|
| 160 | delete mouse; |
---|
| 161 | } |
---|
| 162 | #endif |
---|
[86] | 163 | |
---|
| 164 | // Destroy osgViewer |
---|
| 165 | viewer = NULL; |
---|
[31] | 166 | } |
---|
| 167 | |
---|
| 168 | bool visual_core::loadTerrain(osg::ArgumentParser& arguments_) |
---|
| 169 | { |
---|
| 170 | osg::ref_ptr<osg::Node> model = osgDB::readNodeFiles(arguments_); |
---|
| 171 | if( model.valid() ) |
---|
| 172 | { |
---|
| 173 | rootNode->addChild( model.get() ); |
---|
| 174 | return true; |
---|
| 175 | } |
---|
| 176 | else |
---|
| 177 | { |
---|
[58] | 178 | OSG_NOTIFY( osg::FATAL ) << "Load terrain: No data loaded" << std::endl; |
---|
[31] | 179 | return false; |
---|
| 180 | } |
---|
| 181 | |
---|
| 182 | return false; |
---|
| 183 | } |
---|
| 184 | |
---|
| 185 | void visual_core::addManipulators() |
---|
| 186 | { |
---|
[73] | 187 | if(!visual_dataIO::getInstance()->isSlave()) // set up the camera manipulators if not slave. |
---|
[31] | 188 | { |
---|
| 189 | osg::ref_ptr<osgGA::KeySwitchMatrixManipulator> keyswitchManipulator = new osgGA::KeySwitchMatrixManipulator; |
---|
| 190 | |
---|
| 191 | keyswitchManipulator->addMatrixManipulator( '1', "Trackball", new osgGA::TrackballManipulator() ); |
---|
| 192 | keyswitchManipulator->addMatrixManipulator( '2', "Flight", new osgGA::FlightManipulator() ); |
---|
| 193 | keyswitchManipulator->addMatrixManipulator( '3', "Terrain", new osgGA::TerrainManipulator() ); |
---|
| 194 | nt = new osgGA::NodeTrackerManipulator(); |
---|
| 195 | keyswitchManipulator->addMatrixManipulator( '4', "NodeTrackerManipulator", nt ); |
---|
| 196 | |
---|
| 197 | #ifdef USE_SPACENAVIGATOR |
---|
| 198 | // SpaceNavigator manipulator |
---|
| 199 | mouse = new SpaceMouse(); |
---|
| 200 | mouse->initialize(); |
---|
| 201 | mouseTrackerManip = new NodeTrackerSpaceMouse(mouse); |
---|
| 202 | mouseTrackerManip->setTrackerMode(NodeTrackerSpaceMouse::NODE_CENTER); |
---|
| 203 | mouseTrackerManip->setRotationMode(NodeTrackerSpaceMouse::ELEVATION_AZIM); |
---|
| 204 | mouseTrackerManip->setAutoComputeHomePosition( true ); |
---|
| 205 | keyswitchManipulator->addMatrixManipulator( '5', "Spacemouse Node Tracker", mouseTrackerManip ); |
---|
| 206 | keyswitchManipulator->addMatrixManipulator( '6', "Spacemouse Free (Airplane)", new FreeManipulator(mouse) ); |
---|
| 207 | #endif |
---|
| 208 | |
---|
| 209 | // objectMounted Manipulator for Camera control by Nodes |
---|
| 210 | objectMountedCameraManip = new objectMountedManipulator(); |
---|
| 211 | keyswitchManipulator->addMatrixManipulator( '7', "Object mounted Camera", objectMountedCameraManip ); |
---|
| 212 | |
---|
| 213 | // Animation path manipulator |
---|
| 214 | std::string pathfile; |
---|
| 215 | char keyForAnimationPath = '8'; |
---|
| 216 | while (arguments.read("-p",pathfile)) |
---|
| 217 | { |
---|
| 218 | osgGA::AnimationPathManipulator* apm = new osgGA::AnimationPathManipulator(pathfile); |
---|
| 219 | if (apm || !apm->valid()) |
---|
| 220 | { |
---|
| 221 | unsigned int num = keyswitchManipulator->getNumMatrixManipulators(); |
---|
| 222 | keyswitchManipulator->addMatrixManipulator( keyForAnimationPath, "Path", apm ); |
---|
| 223 | keyswitchManipulator->selectMatrixManipulator(num); |
---|
| 224 | ++keyForAnimationPath; |
---|
| 225 | } |
---|
| 226 | } |
---|
| 227 | |
---|
| 228 | viewer->setCameraManipulator( keyswitchManipulator.get() ); |
---|
[73] | 229 | } // If not Slave END |
---|
[31] | 230 | |
---|
| 231 | // add the state manipulator |
---|
| 232 | viewer->addEventHandler( new osgGA::StateSetManipulator(rootNode->getOrCreateStateSet()) ); |
---|
| 233 | |
---|
| 234 | // add the thread model handler |
---|
| 235 | viewer->addEventHandler(new osgViewer::ThreadingHandler); |
---|
| 236 | |
---|
| 237 | // add the window size toggle handler |
---|
| 238 | viewer->addEventHandler(new osgViewer::WindowSizeHandler); |
---|
| 239 | |
---|
| 240 | // add the stats handler |
---|
| 241 | viewer->addEventHandler(new osgViewer::StatsHandler); |
---|
| 242 | |
---|
| 243 | // add the help handler |
---|
| 244 | viewer->addEventHandler(new osgViewer::HelpHandler(arguments.getApplicationUsage())); |
---|
| 245 | |
---|
| 246 | // add the record camera path handler |
---|
| 247 | viewer->addEventHandler(new osgViewer::RecordCameraPathHandler); |
---|
| 248 | |
---|
| 249 | // add the LOD Scale handler |
---|
| 250 | viewer->addEventHandler(new osgViewer::LODScaleHandler); |
---|
| 251 | |
---|
| 252 | // add the screen capture handler |
---|
| 253 | viewer->addEventHandler(new osgViewer::ScreenCaptureHandler); |
---|
| 254 | } |
---|
| 255 | |
---|
[125] | 256 | void visual_core::parseConfigFile(osg::ArgumentParser& arguments_) |
---|
| 257 | { |
---|
[127] | 258 | configFileValid = false; |
---|
| 259 | |
---|
[125] | 260 | std::string filename; |
---|
| 261 | if( arguments.read("-c", filename) || arguments.read("--config", filename) ) |
---|
| 262 | { |
---|
[127] | 263 | OSG_ALWAYS << "Using configuration file.." << std::endl; |
---|
[125] | 264 | if( osgDB::fileExists(filename) ) |
---|
| 265 | { |
---|
| 266 | configFileValid = false; |
---|
| 267 | xmlDoc *doc = NULL; |
---|
| 268 | xmlNode *root_element = NULL; |
---|
| 269 | |
---|
| 270 | doc = xmlReadFile(filename.c_str(), NULL, 0); |
---|
| 271 | if (doc == NULL) |
---|
| 272 | { |
---|
| 273 | configFileValid = false; |
---|
| 274 | OSG_ALWAYS << "visual_core::parseConfigFile() - ERROR: could not parse osgVisual config file" << filename << std::endl; |
---|
| 275 | } |
---|
| 276 | else |
---|
| 277 | { |
---|
| 278 | // Get the root element node |
---|
| 279 | root_element = xmlDocGetRootElement(doc); |
---|
[67] | 280 | |
---|
[125] | 281 | // Parse the XML document. |
---|
[127] | 282 | checkXMLNode(root_element); |
---|
[125] | 283 | |
---|
| 284 | // free the document |
---|
| 285 | xmlFreeDoc(doc);; |
---|
| 286 | } |
---|
| 287 | // Free the global variables that may have been allocated by the parser. |
---|
| 288 | xmlCleanupParser(); |
---|
| 289 | |
---|
| 290 | if(!configFileValid) |
---|
| 291 | OSG_ALWAYS << "visual_core::parseConfigFile() - ERROR: XML file seems not to be a valid osgVisual configuration file!" << std::endl; |
---|
| 292 | |
---|
| 293 | } // IF configfile exists |
---|
| 294 | } // IF -c END |
---|
| 295 | } |
---|
| 296 | |
---|
| 297 | void visual_core::checkXMLNode(xmlNode * a_node) |
---|
| 298 | { |
---|
[127] | 299 | for (xmlNode *cur_node = a_node; cur_node; cur_node = cur_node->next) |
---|
| 300 | { |
---|
| 301 | std::string node_name=reinterpret_cast<const char*>(cur_node->name); |
---|
| 302 | if(cur_node->type == XML_ELEMENT_NODE && node_name == "osgvisualconfiguration") |
---|
| 303 | { |
---|
| 304 | OSG_DEBUG << "XML node osgvisualconfiguration found" << std::endl; |
---|
| 305 | configFileValid = true; |
---|
| 306 | // Iterate to the next nodes to configure modules and scenery. |
---|
| 307 | checkXMLNode(cur_node->children); |
---|
| 308 | } |
---|
[125] | 309 | |
---|
[127] | 310 | if (cur_node->type == XML_ELEMENT_NODE && node_name == "module") |
---|
| 311 | { |
---|
| 312 | OSG_DEBUG << "XML node module found" << std::endl; |
---|
| 313 | |
---|
| 314 | parseModule(cur_node); |
---|
| 315 | |
---|
| 316 | //OSG_DEBUG << "node type=Element, name:" << cur_node->name << std::endl; |
---|
| 317 | //OSG_DEBUG << "Processing children at " << cur_node->children << std::endl; |
---|
| 318 | } // IF(module) END |
---|
| 319 | |
---|
| 320 | if (cur_node->type == XML_ELEMENT_NODE && node_name == "scenery") |
---|
| 321 | { |
---|
| 322 | OSG_DEBUG << "XML node scenery found" << std::endl; |
---|
| 323 | |
---|
| 324 | parseScenery(cur_node); |
---|
| 325 | |
---|
| 326 | //OSG_DEBUG << "node type=Element, name:" << cur_node->name << std::endl; |
---|
| 327 | //OSG_DEBUG << "Processing children at " << cur_node->children << std::endl; |
---|
| 328 | } // IF(scenery) END |
---|
| 329 | } // FOR END |
---|
[125] | 330 | } |
---|
| 331 | |
---|
[127] | 332 | void visual_core::parseModule(xmlNode * a_node) |
---|
| 333 | { |
---|
[128] | 334 | OSG_ALWAYS << "parseModule()" << std::endl; |
---|
| 335 | |
---|
| 336 | // Extract infos |
---|
| 337 | std::string name = ""; |
---|
| 338 | bool enabled = false; |
---|
| 339 | |
---|
| 340 | xmlAttr *attr = a_node->properties; |
---|
| 341 | while ( attr ) |
---|
| 342 | { |
---|
| 343 | std::string attr_name=reinterpret_cast<const char*>(attr->name); |
---|
| 344 | std::string attr_value=reinterpret_cast<const char*>(attr->children->content); |
---|
| 345 | if( attr_name == "name" ) |
---|
| 346 | name = reinterpret_cast<const char*>(attr->children->content); |
---|
| 347 | if( attr_name == "enabled" && attr_value== "yes" ) |
---|
| 348 | enabled = true; |
---|
| 349 | if( attr_name == "enabled" && attr_value== "no" ) |
---|
| 350 | enabled = false; |
---|
| 351 | |
---|
[129] | 352 | OSG_ALWAYS << "Module '" << name << "' found. Enabled = " << enabled << std::endl; |
---|
[128] | 353 | |
---|
| 354 | attr = attr->next; |
---|
| 355 | } |
---|
| 356 | |
---|
[129] | 357 | // Pass the nodes to the corresponding modules... |
---|
| 358 | if(name == "core") this->config(a_node); |
---|
[128] | 359 | |
---|
[127] | 360 | } |
---|
| 361 | |
---|
[125] | 362 | void visual_core::parseScenery(xmlNode * a_node) |
---|
| 363 | { |
---|
[128] | 364 | OSG_ALWAYS << "parseScenery()" << std::endl; |
---|
[125] | 365 | } |
---|
| 366 | |
---|
[129] | 367 | void visual_core::config(xmlNode * a_node) |
---|
| 368 | { |
---|
| 369 | // Currently no configuration options fpr the core module are available. |
---|
| 370 | } |
---|
| 371 | |
---|
[67] | 372 | bool visual_core::checkCommandlineArgumentsForFinalErrors() |
---|
[31] | 373 | { |
---|
| 374 | // Setup Application Usage |
---|
| 375 | arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName()); |
---|
| 376 | arguments.getApplicationUsage()->setDescription(arguments.getApplicationName()+" is the new FSD visualization tool, written by Torben Dannhauer"); |
---|
| 377 | arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] Terrain_filename"); |
---|
| 378 | arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display this information"); |
---|
| 379 | |
---|
| 380 | // if user request help write it out to cout. |
---|
| 381 | if (arguments.read("-h") || arguments.read("--help")) |
---|
| 382 | { |
---|
| 383 | arguments.getApplicationUsage()->write(std::cout); |
---|
| 384 | //cause the viewer to exit and shut down clean. |
---|
| 385 | viewer->setDone(true); |
---|
| 386 | } |
---|
| 387 | |
---|
| 388 | // report any errors if they have occurred when parsing the program arguments. |
---|
| 389 | if (arguments.errors()) |
---|
| 390 | { |
---|
| 391 | arguments.writeErrorMessages(std::cout); |
---|
| 392 | //cause the viewer to exit and shut down clean. |
---|
| 393 | viewer->setDone(true); |
---|
| 394 | } |
---|
| 395 | |
---|
| 396 | // any option left unread are converted into errors to write out later. |
---|
| 397 | arguments.reportRemainingOptionsAsUnrecognized(); |
---|
| 398 | |
---|
| 399 | // report any errors if they have occurred when parsing the program arguments. |
---|
| 400 | if (arguments.errors()) |
---|
| 401 | { |
---|
| 402 | arguments.writeErrorMessages(std::cout); |
---|
| 403 | return false; |
---|
| 404 | } |
---|
| 405 | return true; |
---|
| 406 | } |
---|
| 407 | |
---|
| 408 | void visual_core::setupScenery() |
---|
| 409 | { |
---|
[130] | 410 | // iterate manually through one frame to allow some modules like Sky_Silverlining to initialize properly before we configure it according to the scenery data. |
---|
[122] | 411 | viewer->advance(); |
---|
| 412 | viewer->eventTraversal(); |
---|
| 413 | viewer->updateTraversal(); |
---|
| 414 | viewer->renderingTraversals(); |
---|
| 415 | |
---|
| 416 | // Sky settings: |
---|
| 417 | sky->setTime(12,00,23); |
---|
| 418 | sky->setVisibility(50000); |
---|
| 419 | //addWindVolume( 0.0, 15000.0, 300.0, 90.0 ); |
---|
| 420 | |
---|
[130] | 421 | //sky->addCloudLayer( 0, 20000, 20000, 600.0, 0.0, 0.5, CUMULONIMBUS_CAPPILATUS ); |
---|
| 422 | //sky->addCloudLayer( 1, 5000000, 5000000, 600.0, 7351.0, 0.2, CIRRUS_FIBRATUS ); |
---|
| 423 | sky->addCloudLayer( 2, 50000, 50000, 600.0, 7351.0, 0.2, CIRROCUMULUS ); |
---|
| 424 | sky->addCloudLayer( 3, 100000, 100000, 1300.0, 100.0, 0.07, CUMULUS_CONGESTUS ); |
---|
| 425 | sky->addCloudLayer( 0, 10000, 10000, 1300.0, 4000.0, 0.90, STRATOCUMULUS ); |
---|
[122] | 426 | //cloudLayerSlots[1].cloudLayerPointer->SetPrecipitation(SilverLining::CloudLayer::SLEET, 25.0 ); |
---|
| 427 | |
---|
[31] | 428 | //testObj = new visual_object( rootNode, "testStab", objectMountedCameraManip ); |
---|
| 429 | //testObj->setNewPosition( osg::DegreesToRadians(47.7123), osg::DegreesToRadians(12.84088), 600 ); |
---|
| 430 | ///* using a huge cylinder to test position & orientation */ |
---|
| 431 | //testObj->setGeometry( util::getDemoCylinder(5000.0, 20.0 ) ); |
---|
| 432 | //testObj->addUpdater( new object_updater(testObj) ); |
---|
| 433 | |
---|
[115] | 434 | //osg::ref_ptr<visual_object> testObj2 = new visual_object( rootNode, "neuschwanstein" ); // todo memleak |
---|
| 435 | ////testObj2->setNewPosition( osg::DegreesToRadians(47.8123), osg::DegreesToRadians(12.94088), 600 ); |
---|
| 436 | //testObj2->setNewPosition( osg::DegreesToRadians(47.557523564234), osg::DegreesToRadians(10.749646398595), 950 ); |
---|
| 437 | //testObj2->loadGeometry( "../models/neuschwanstein.osgb" ); |
---|
| 438 | ////testObj2->addUpdater( new object_updater(testObj2) ); // todo memleak |
---|
[31] | 439 | |
---|
[87] | 440 | osg::ref_ptr<visual_object> testObj3 = new visual_object( rootNode, "SAENGER1" ); // todo memleak |
---|
[31] | 441 | testObj3->setNewPosition( osg::DegreesToRadians(47.8123), osg::DegreesToRadians(12.94088), 600 ); |
---|
| 442 | testObj3->loadGeometry( "../models/saenger1.flt" ); |
---|
[87] | 443 | testObj3->addUpdater( new object_updater(testObj3) ); // todo memleak |
---|
[31] | 444 | |
---|
| 445 | |
---|
[87] | 446 | osg::ref_ptr<visual_object> testObj4 = new visual_object( rootNode, "SAENGER2" ); // todo memleak |
---|
[31] | 447 | testObj4->setNewPosition( osg::DegreesToRadians(47.8123), osg::DegreesToRadians(12.94088), 650 ); |
---|
| 448 | testObj4->loadGeometry( "../models/saenger2.flt" ); |
---|
[87] | 449 | testObj4->addUpdater( new object_updater(testObj4) ); // todo memleak |
---|
[31] | 450 | testObj4->addLabel("testLabel", "LabelTest!!\nnächste Zeile :)",osg::Vec4(1.0f,0.25f,1.0f,1.0f)); |
---|
| 451 | |
---|
[87] | 452 | osg::ref_ptr<visual_object> testObj5 = new visual_object( rootNode, "SAENGER" ); // todo memleak |
---|
[31] | 453 | testObj5->setNewPosition( osg::DegreesToRadians(47.8123), osg::DegreesToRadians(12.94088), 550 ); |
---|
| 454 | testObj5->loadGeometry( "../models/saengerCombine.flt" ); |
---|
| 455 | //testObj5->setScale( 2 ); |
---|
[87] | 456 | testObj5->addUpdater( new object_updater(testObj5) ); // todo memleak |
---|
[31] | 457 | |
---|
| 458 | #ifdef USE_SPACENAVIGATOR |
---|
| 459 | // Manipulatoren auf dieses Objekt binden (Primärobjekt) |
---|
| 460 | if (objectMountedCameraManip.valid()) |
---|
[115] | 461 | objectMountedCameraManip->setAttachedObject( testObj4 ); |
---|
[31] | 462 | if (mouseTrackerManip.valid()) |
---|
| 463 | { |
---|
[115] | 464 | mouseTrackerManip->setTrackNode( testObj4->getGeometry() ); |
---|
[31] | 465 | mouseTrackerManip->setMinimumDistance( 100 ); |
---|
| 466 | } |
---|
| 467 | #endif |
---|
| 468 | |
---|
[73] | 469 | if(nt.valid()) |
---|
| 470 | { |
---|
| 471 | osgGA::NodeTrackerManipulator::TrackerMode trackerMode = osgGA::NodeTrackerManipulator::NODE_CENTER; |
---|
| 472 | osgGA::NodeTrackerManipulator::RotationMode rotationMode = osgGA::NodeTrackerManipulator::ELEVATION_AZIM; |
---|
| 473 | nt->setTrackerMode(trackerMode); |
---|
| 474 | nt->setRotationMode(rotationMode); |
---|
| 475 | //nt->setAutoComputeHomePosition( true ); |
---|
| 476 | nt->setMinimumDistance( 100 ); |
---|
| 477 | nt->setTrackNode(testObj4->getGeometry()); |
---|
| 478 | //nt->computeHomePosition(); |
---|
| 479 | nt->setAutoComputeHomePosition( true ); |
---|
| 480 | nt->setDistance( 250 ); |
---|
| 481 | } |
---|
[31] | 482 | |
---|
| 483 | |
---|
| 484 | // Load EDDF |
---|
| 485 | //std::string filename = "D:\\DA\\EDDF_test\\eddf.ive"; |
---|
| 486 | //if( !osgDB::fileExists(filename) ) |
---|
| 487 | //{ |
---|
| 488 | // OSG_NOTIFY(osg::ALWAYS) << "Warning: EDDF Model not loaded. File '" << filename << "' does not exist. Skipping."; |
---|
| 489 | //} |
---|
| 490 | //// read model |
---|
| 491 | //osg::ref_ptr<osg::Node> tmpModel = osgDB::readNodeFile( filename ); |
---|
| 492 | //if (tmpModel.valid()) |
---|
| 493 | // rootNode->addChild( tmpModel ); |
---|
| 494 | |
---|
| 495 | |
---|
| 496 | visual_draw2D::getInstance()->init( rootNode, viewer ); |
---|
| 497 | //osg::ref_ptr<visual_hud> hud = new visual_hud(); |
---|
[87] | 498 | hud = new visual_debug_hud(); |
---|
[31] | 499 | hud->init( viewer, rootNode ); |
---|
| 500 | |
---|
[122] | 501 | |
---|
[31] | 502 | |
---|
| 503 | //osg::ref_ptr<visual_draw3D> test = new visual_draw3D(); |
---|
| 504 | //test->init( rootNode, viewer ); |
---|
| 505 | |
---|
[69] | 506 | //// Creating Testclasses |
---|
| 507 | //osg::ref_ptr<osgVisual::dataIO_transportContainer> test = new osgVisual::dataIO_transportContainer(); |
---|
| 508 | //osg::ref_ptr<osgVisual::dataIO_executer> testEx = new osgVisual::dataIO_executer(); |
---|
| 509 | //osg::ref_ptr<osgVisual::dataIO_slot> testSlot = new osgVisual::dataIO_slot(); |
---|
| 510 | //test->setFrameID( 22 ); |
---|
| 511 | //test->setName("ugamoep"); |
---|
| 512 | //testEx->setexecuterID( osgVisual::dataIO_executer::IS_COLLISION ); |
---|
| 513 | //testSlot->setVariableName(std::string("HalloName")); |
---|
| 514 | //testSlot->setdataDirection( osgVisual::dataIO_slot::TO_OBJ ); |
---|
| 515 | //testSlot->setvarType( osgVisual::dataIO_slot::DOUBLE ); |
---|
| 516 | //testSlot->setValue( 0.12345 ); |
---|
| 517 | //test->addExecuter( testEx ); |
---|
| 518 | //test->addSlot( testSlot ); |
---|
[31] | 519 | |
---|
[69] | 520 | visual_dataIO::getInstance()->setSlotData("TestSlot1", osgVisual::dataIO_slot::TO_OBJ, 0.12345); |
---|
[31] | 521 | } |
---|