void Module2300::createScene(int sceneNum, int which) { debug(1, "Module2300::createScene(%d, %d)", sceneNum, which); _sceneNum = sceneNum; switch (_sceneNum) { case 0: _vm->gameState().sceneNum = 0; createNavigationScene(0x004B67B8, which); break; case 1: _vm->gameState().sceneNum = 1; createNavigationScene(0x004B67E8, which); if (_isWallBroken) { _soundVolume = 15; _vm->_soundMan->setSoundVolume(0x90F0D1C3, 15); } break; case 2: _vm->gameState().sceneNum = 2; createNavigationScene(0x004B6878, which); break; case 3: _vm->gameState().sceneNum = 3; if (getGlobalVar(V_WALL_BROKEN)) createNavigationScene(0x004B68F0, which); else { _vm->_soundMan->setSoundVolume(0x90F0D1C3, _soundVolume); createNavigationScene(0x004B68A8, which); if (_isWallBroken) { _soundVolume = 87; _vm->_soundMan->setSoundVolume(0x90F0D1C3, 87); } } break; case 4: _vm->gameState().sceneNum = 4; _vm->_soundMan->setTwoSoundsPlayFlag(true); createSmackerScene(0x20080A0B, true, true, false); break; case 9999: createDemoScene(); break; } SetUpdateHandler(&Module2300::updateScene); _childObject->handleUpdate(); }
int main( int argc, char **argv ) { // use an ArgumentParser object to manage the program arguments. osg::ArgumentParser arguments(&argc,argv); // set up the usage document, in case we need to print out how to use this program. arguments.getApplicationUsage()->setApplicationName(arguments.getApplicationName()); arguments.getApplicationUsage()->setCommandLineUsage(arguments.getApplicationName()+" [options] filename ..."); arguments.getApplicationUsage()->addCommandLineOption("--image <filename>","Load an image and render it on a quad"); arguments.getApplicationUsage()->addCommandLineOption("--dem <filename>","Load an image/DEM and render it on a HeightField"); arguments.getApplicationUsage()->addCommandLineOption("-h or --help","Display command line parameters"); arguments.getApplicationUsage()->addCommandLineOption("--help-env","Display environmental variables available"); arguments.getApplicationUsage()->addCommandLineOption("--help-keys","Display keyboard & mouse bindings available"); arguments.getApplicationUsage()->addCommandLineOption("--help-all","Display all command line, env vars and keyboard & mouse bindings."); arguments.getApplicationUsage()->addCommandLineOption("--dragger <draggername>","Use the specified dragger for manipulation [TabPlaneDragger, TabPlaneTrackballDragger, TrackballDragger, Translate1DDragger, Translate2DDragger, TranslateAxisDragger, TabBoxDragger, TranslatePlaneDragger, Scale1DDragger, Scale2DDragger, RotateCylinderDragger, RotateSphereDragger]"); arguments.getApplicationUsage()->addCommandLineOption("--fixedDraggerSize","Fix the size of the dragger geometry in the screen space"); bool fixedSizeInScreen = false; while (arguments.read("--fixedDraggerSize")) { fixedSizeInScreen = true; } // construct the viewer. osgViewer::Viewer viewer(arguments); // add the window size toggle handler viewer.addEventHandler(new osgViewer::WindowSizeHandler); // get details on keyboard and mouse bindings used by the viewer. viewer.getUsage(*arguments.getApplicationUsage()); if (arguments.read("--test-NodeMask")) { const osg::ref_ptr<osg::Group> group = new osg::Group(); group->setNodeMask(0); const osg::ref_ptr<osgManipulator::AntiSquish> antiSquish = new osgManipulator::AntiSquish(); group->addChild(antiSquish.get()); const osg::ref_ptr<osg::Node> node = new osg::Node(); node->setInitialBound(osg::BoundingSphere(osg::Vec3(0.0, 0.0, 0.0), 1.0)); antiSquish->addChild(node.get()); group->getBound(); return 1; } // if user request help write it out to cout. bool helpAll = arguments.read("--help-all"); unsigned int helpType = ((helpAll || arguments.read("-h") || arguments.read("--help"))? osg::ApplicationUsage::COMMAND_LINE_OPTION : 0 ) | ((helpAll || arguments.read("--help-env"))? osg::ApplicationUsage::ENVIRONMENTAL_VARIABLE : 0 ) | ((helpAll || arguments.read("--help-keys"))? osg::ApplicationUsage::KEYBOARD_MOUSE_BINDING : 0 ); if (helpType) { arguments.getApplicationUsage()->write(std::cout, helpType); return 1; } // report any errors if they have occurred when parsing the program arguments. if (arguments.errors()) { arguments.writeErrorMessages(std::cout); return 1; } std::string dragger_name = "TabBoxDragger"; arguments.read("--dragger", dragger_name); osg::Timer_t start_tick = osg::Timer::instance()->tick(); // read the scene from the list of file specified command line args. osg::ref_ptr<osg::Node> loadedModel = osgDB::readRefNodeFiles(arguments); // if no model has been successfully loaded report failure. bool tragger2Scene(true); if (!loadedModel) { //std::cout << arguments.getApplicationName() <<": No data loaded" << std::endl; //return 1; loadedModel = createDemoScene(fixedSizeInScreen); tragger2Scene=false; } // any option left unread are converted into errors to write out later. arguments.reportRemainingOptionsAsUnrecognized(); // report any errors if they have occurred when parsing the program arguments. if (arguments.errors()) { arguments.writeErrorMessages(std::cout); } osg::Timer_t end_tick = osg::Timer::instance()->tick(); std::cout << "Time to load = "<<osg::Timer::instance()->delta_s(start_tick,end_tick)<<std::endl; // optimize the scene graph, remove redundant nodes and state etc. osgUtil::Optimizer optimizer; optimizer.optimize(loadedModel); // pass the loaded scene graph to the viewer. if ( tragger2Scene ) { viewer.setSceneData(addDraggerToScene(loadedModel.get(), dragger_name, fixedSizeInScreen)); } else { viewer.setSceneData(loadedModel); } return viewer.run(); }
void Module2600::createScene(int sceneNum, int which) { debug("Module2600::createScene(%d, %d)", sceneNum, which); _sceneNum = sceneNum; switch (_sceneNum) { case 0: _vm->gameState().sceneNum = 0; createNavigationScene(0x004B8608, which); break; case 1: _vm->gameState().sceneNum = 1; createNavigationScene(0x004B8638, which); break; case 2: _vm->gameState().sceneNum = 2; createNavigationScene(0x004B86C8, which); break; case 3: _vm->gameState().sceneNum = 3; if (getGlobalVar(V_CREATURE_ANGRY)) createNavigationScene(0x004B8758, which); else createNavigationScene(0x004B86F8, which); break; case 4: _vm->gameState().sceneNum = 4; createNavigationScene(0x004B87B8, which); break; case 6: _vm->gameState().sceneNum = 6; createNavigationScene(0x004B8698, which); break; case 7: _vm->gameState().sceneNum = 7; _vm->_soundMan->deleteGroup(0x40271018); createSmackerScene(0x30090001, true, true, false); break; case 8: _vm->gameState().sceneNum = 8; _childObject = new Scene2609(_vm, this, which); break; case 1002: _vm->gameState().sceneNum = 2; if (getGlobalVar(V_FRUIT_COUNTING_INDEX) == 1) createSmackerScene(0x018C0404, true, true, false); else if (getGlobalVar(V_FRUIT_COUNTING_INDEX) == 2) createSmackerScene(0x018C0407, true, true, false); else createSmackerScene(0x818C0405, true, true, false); if (getGlobalVar(V_FRUIT_COUNTING_INDEX) >= 2) setGlobalVar(V_FRUIT_COUNTING_INDEX, 0); else incGlobalVar(V_FRUIT_COUNTING_INDEX, +1); break; case 1003: _vm->gameState().sceneNum = 3; createSmackerScene(0x001C0007, true, true, false); break; case 1006: _vm->gameState().sceneNum = 6; if (getGlobalVar(V_WATER_RUNNING)) createSmackerScene(0x049A1181, true, true, false); else createSmackerScene(0x04981181, true, true, false); break; case 1008: _vm->gameState().sceneNum = 8; if (getGlobalVar(V_WATER_RUNNING)) createSmackerScene(0x42B80941, true, true, false); else createSmackerScene(0x42980941, true, true, false); break; case 9999: createDemoScene(); break; } SetUpdateHandler(&Module2600::updateScene); _childObject->handleUpdate(); }