bool URE::init(Path& pathToGlobalConfigFile) { resetEngine(); Log::getInstance()<<INFO_LOG_LEVEL<<"initializing URE ...\n"; Log::getInstance()<<DEBUG_LOG_LEVEL<<"The Config Path is"<< pathToGlobalConfigFile.string() <<"\n"; mConfig = new Config(); mLoader= new Loader(); mLoader->loadGlobalConfig(*mConfig,pathToGlobalConfigFile); #ifdef FLEWNIT_USE_GLFW mWindowManager = new GLFWWindowManager(); #else # ifdef FLEWNIT_USE_XCB assert(0 && "Sorry, XCB Windowmanager not implemented"); # else # ifdef FLEWNIT_USE_SDL assert(0 && "Sorry, SDL Windowmanager not implemented"); # else assert(0 && "You have to specifiy window manager with cmake!"); # endif # endif #endif mInputManager = new InputManager(); mFPSCounter = new FPSCounter(); mParallelComputeManager = new ParallelComputeManager(); mSimulationResourceManager = new SimulationResourceManager(); mCLProgramManager = new CLProgramManager( ConfigCaster::cast<bool>( mConfig->root().get("generalSettings",0). get("useCacheUsingOpenCLImplementation",0) ) ); if(mConfig->root().childExists("generalSettings",0)) { mDoValidateSimulationStepResults = ConfigCaster::cast<bool> (mConfig->root().get("generalSettings",0).get("doValidateSimulationStepResults",0) ); mDoProfileAndOptimizeSettings = ConfigCaster::cast<bool> (mConfig->root().get("generalSettings",0).get("doProfileAndOptimizeSettings",0) ); mDoProfilePerformance = ConfigCaster::cast<bool> (mConfig->root().get("generalSettings",0).get("doProfilePerformance",0) ); mDoDebugDraw = ConfigCaster::cast<bool> (mConfig->root().get("generalSettings",0).get("doDebugDraw",0) ); } if(mConfig->root().childExists("simulators",0)) { ConfigStructNode& simulatorsConfigNode = mConfig->root().get("simulators",0); //BOOST_FOREACH( ConfigMap::value_type & singleSimulatorConfigNode, simulatorsConfigNode.getChildren() ) for(unsigned int i = 0 ; i < simulatorsConfigNode.get("Simulator").size() ;i++) { mSimulators.push_back( SimulatorInterface::create( simulatorsConfigNode.get("Simulator")[i] ) ); // assert("no double definition of a simulator allowed" && singleSimulatorConfigNode.second.size()== 1 ); // mSimulators[singleSimulatorConfigNode.first] = // SimulatorInterface::create(singleSimulatorConfigNode.second[0]); } } else { assert("no simulators defined in config" && 0); } //DEBUG: getSimulator(VISUAL_SIM_DOMAIN)->toLightingSimulator()->testStuff(); //load the scene before the pipeline are initialized so that the pipelines have some //world objects/materials/geometry to grab for shader/kernel generation mLoader->loadScene(); BOOST_FOREACH(SimulatorInterface* simulator, mSimulators) { simulator->initPipeLine(); } BOOST_FOREACH(SimulatorInterface* simulator, mSimulators) { simulator->validatePipeLine(); } // BOOST_FOREACH( SimulatorMap::value_type & simPair, mSimulators) // { // simPair.second -> initPipeLine(); // } // // BOOST_FOREACH( SimulatorMap::value_type & simPair, mSimulators) // { // simPair.second -> validatePipeLine(); // } mCLProgramManager->getInstance().buildProgramsAndCreateKernels(); #if (FLEWNIT_TRACK_MEMORY || FLEWNIT_DO_PROFILING) Profiler::getInstance().updateMemoryTrackingInfo(); #endif Log::getInstance()<<INFO_LOG_LEVEL<<"initializing done!\n"; //hack mCorrectlyInitializedGuard = true; return mCorrectlyInitializedGuard; }
Environment *SimulatorResult::getEnvironment() { return getSimulator()->getEnvironment(); }
Visualizer *SimulatorResult::getVisualizer() { return getSimulator()->getDisplay(); }
void MyApplication::createScene() { setUpdateMode(SimulationEngine::SIMULATE_REAL_TIME_MULTIPLE, 1); //// Set to capture frames at 29.97 fps. //engine.setUpdateMode(SIMULATE_CONSTANT_CHUNK, 0.0333667); // Use feet for this simulation. getSimulator()->setGravity(opal::Vec3r(0, -30, 0)); getSimulator()->setStepSize(gPhysicsStepSize); // Make sure we get notified at the end of each step. getSimulator()->addPostStepEventHandler(&gPostStepEventHandler); Ogre::OverlayManager::getSingleton().getByName("Verve/Debug")->hide(); Ogre::OverlayManager::getSingleton().getByName("Core/DebugOverlay")->hide(); // Setup camera. getCamera()->setPosition(opal::Point3r(0, 25, 25)); getCamera()->lookAt(opal::Point3r(0, (opal::real)0.1, 0)); setCameraMoveSpeed(1); // Main static arena. opal::Blueprint arenaBlueprint; opal::loadFile(arenaBlueprint, "../data/blueprints/arena1.xml"); opal::BlueprintInstance arenaBPInstance; getSimulator()->instantiateBlueprint(arenaBPInstance, arenaBlueprint, opal::Matrix44r(), 1); createPhysicalEntity("staticEnvironment", "Plastic/Gray", arenaBPInstance.getSolid("staticEnvironment")); createPhysicalEntity("toy1", "Plastic/Green", arenaBPInstance.getSolid("toy1")); createPhysicalEntity("toy2", "Plastic/Green", arenaBPInstance.getSolid("toy2")); createPhysicalEntity("toy3", "Plastic/Green", arenaBPInstance.getSolid("toy3")); // Seesaw. opal::Blueprint seesawBP; opal::loadFile(seesawBP, "../data/blueprints/seesaw.xml"); opal::BlueprintInstance seesawBPInstance; opal::Matrix44r seesawTransform; seesawTransform.translate(8, 0, 0); getSimulator()->instantiateBlueprint(seesawBPInstance, seesawBP, seesawTransform, 1); createPhysicalEntity("seesawSupport", "Plastic/Black", seesawBPInstance.getSolid("seesawSupport")); createPhysicalEntity("seesawPanel", "Plastic/Orange", seesawBPInstance.getSolid("seesawPanel")); // Add an initial torque to bring one end of the seesaw to the // ground. seesawBPInstance.getJoint("seesawHinge")->addTorque(0, 100, 0, true); // Merry-go-round. createPhysicalEntity("merryGoRound", "Plastic/Yellow", arenaBPInstance.getSolid("merryGoRound")); // Curtains. opal::Blueprint curtainsBP; opal::loadFile(curtainsBP, "../data/blueprints/blockCurtain.xml"); opal::BlueprintInstance curtainsBPInstance; opal::Matrix44r curtainsTransform; curtainsTransform.rotate(45, 0, 1, 0); curtainsTransform.translate(-10, 0, 0); getSimulator()->instantiateBlueprint(curtainsBPInstance, curtainsBP, curtainsTransform, 1); createPhysicalEntity("curtainBase", "Plastic/Red", curtainsBPInstance.getSolid("curtainBase")); createPhysicalEntity("curtainPiece0", "Plastic/Black", curtainsBPInstance.getSolid("curtainPiece0")); createPhysicalEntity("curtainPiece1", "Plastic/Black", curtainsBPInstance.getSolid("curtainPiece1")); createPhysicalEntity("curtainPiece2", "Plastic/Black", curtainsBPInstance.getSolid("curtainPiece2")); createPhysicalEntity("curtainPiece3", "Plastic/Black", curtainsBPInstance.getSolid("curtainPiece3")); createPhysicalEntity("curtainPiece4", "Plastic/Black", curtainsBPInstance.getSolid("curtainPiece4")); createPhysicalEntity("curtainPiece5", "Plastic/Black", curtainsBPInstance.getSolid("curtainPiece5")); //// Ragdoll. //opal::Blueprint ragdollBP; //opal::loadFile(ragdollBP, "../data/blueprints/ragdoll.xml"); //opal::BlueprintInstance ragdollBPInstance; //opal::Matrix44r ragdollTransform; //ragdollTransform.translate(10, 5, 0); //getSimulator()->instantiateBlueprint(ragdollBPInstance, // ragdollBP, ragdollTransform, 2); //for (unsigned int i = 0; i < ragdollBPInstance.getNumSolids(); ++i) //{ // opal::Solid* s = ragdollBPInstance.getSolid(i); // createPhysicalEntity(s->getName(), "Plastic/Red", s); //} //// TESTING: Simple goal box. //opal::Solid* boxSolid = getSimulator()->createSolid(); //boxSolid->setStatic(false); //boxSolid->setSleepiness(0); //boxSolid->setPosition(15.5, 10, -7); //opal::BoxShapeData data; //data.dimensions.set(1.5, 1.5, 1.5); //data.material.friction = 0.1; //data.material.density = 0.5; //boxSolid->addShape(data); //createPhysicalEntity("goal box", "Plastic/Green", boxSolid); //// TESTING: Make a volume sensor to detect the goal. //opal::VolumeSensorData goalSensorData; //goalSensorData.solid = gRobot->getChassis(); //goalSensorData.transform.makeTranslation(0, 0, -2); //gGoalSensor = getSimulator()->createVolumeSensor(); //gGoalSensor->init(goalSensorData); //gGoalSensorVolume = getSimulator()->createSolid(); //gGoalSensorVolume->setStatic(true); ////opal::Matrix44r m = gRobot->getChassis()->getTransform(); ////m.translate(0, 0, -2); //opal::Matrix44r m; //m.translate(0, 100, 0); //gGoalSensorVolume->setTransform(m); //opal::BoxShapeData sensorVolumeShape; //sensorVolumeShape.dimensions.set(2, 1, 2); ////getSimulator()->setupContactGroup(5, false); ////sensorVolumeShape.contactGroup = 5; //sensorVolumeShape.material.density = 0.01; //gGoalSensorVolume->addShape(sensorVolumeShape); ////createPhysicalEntityBox("goal sensor", "Translucent/Blue", boxDim, //// gGoalSensorVolume); //opal::JointData fixedJointData; //fixedJointData.setType(opal::FIXED_JOINT); //fixedJointData.solid0 = gRobot->getChassis(); //fixedJointData.solid1 = gGoalSensorVolume; //opal::Joint* fixedJoint = getSimulator()->createJoint(); //fixedJoint->init(fixedJointData); }