int main(int argc, char **argv) { glutInit(&argc, argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(0, 0); glutInitWindowSize(700, 500); glutCreateWindow("GUI Test"); initializeScene(); // Keyboard glutKeyboardFunc(keyTyped); glutSpecialFunc(inputKey); // Display and Idle glutDisplayFunc(renderScene); glutIdleFunc(renderScene); glutReshapeFunc(setPerspective); // Mouse stuff glutMouseFunc(mouseClicked); glutMotionFunc(mouseDragged); glutPassiveMotionFunc(mouseMoved); glutMainLoop(); TexturesManager::flushAllTextures(); return(0); }
/** * Method is used to initialize physics manager, init PhysX extensions and cooking objects. */ void PhysicsManager::initializePhysicsManager() { if(!PxInitExtensions(*physicsSDK)) Logger::getInstance()->saveLog(Log<string>("Physics Extensions initialization error occurred!")); PxFoundation& foundation = physicsSDK->getFoundation(); cooking = PxCreateCooking(PX_PHYSICS_VERSION, &foundation, PxCookingParams()); if(!cooking) Logger::getInstance()->saveLog(Log<string>("Physics Cooking creation error occurred!")); defaultFilterShader = filterShader; initializeScene(); addPhysicsMaterial("Default",Vector3D(0.5,0.5,0.0)); //PxExtensionVisualDebugger::connect(physicsSDK->getPvdConnectionManager(),"localhost",5425, 10000, true); }
void SceneDisplayer::initializeFromNewMap(const std::string &mapEditorPath, const std::string &mapFilename, const std::string &relativeMapWorkingDir) { try { initializeEngineResources(mapEditorPath); std::string mapWorkingDirectory = FileHandler::simplifyDirectoryPath(FileHandler::getDirectoryFrom(mapFilename) + relativeMapWorkingDir); FileSystem::instance()->setupWorkingDirectory(mapWorkingDirectory); initializeScene(); mapHandler = new MapHandler(sceneManager, nullptr, nullptr); }catch(std::exception &e) { QMessageBox::critical(nullptr, "Error", e.what()); this->~SceneDisplayer(); exit(1); } }
void PD_flow_mrpt::initializePDFlow() { //Initialize Visualization initializeScene(); //Initialize CUDA mrpt::system::sleep(500); initializeCUDA(); //Start video streaming OpenCamera(); //Fill empty matrices CaptureFrame(); createImagePyramidGPU(); CaptureFrame(); createImagePyramidGPU(); solveSceneFlowGPU(); }
int main (int argc, char* argv[]) { srand (static_cast<unsigned>(time(0))); // Magic glewExperimental = GL_TRUE; // Init GLEW and GLFW if(initializeOpenGL() == -1) { return -1; } scene = new Scene(); utilHandler = new Utils(); createPreDefinedVoronoiPoints(); scene->setPreComputedVoronoiPoints(sVoronoiPoints); // Create geometries and add them to the scene // Floor floor_rect = new Rectangle(1.0f, 1.0f, Vector3<float>(0.0f, 0.0f, 0.0f)); floor_rect->rotate(Vector3<float>(1.0f, 0.0f, 0.0f), 90.0f); floor_rect->scale(Vector3<float>(2.5f, 1.0f, 2.0f)); floor_rect->translate(Vector3<float>(0.0f, -0.35f, 0.0f)); // HalfEdge mesh mesh = new HalfEdgeMesh(Vector4<float>(0.2f, 0.8f, 0.2f, 0.4f)); mesh->addVoronoiPoint(Vector3<float>(0.0f, 0.0f, 0.0f)); mesh->setDebugMode(true); // The following meshes has pre-defined voronoi patterns //mesh->createMesh("pillar"); //mesh->createMesh("icosphere"); //mesh->createMesh("bunnySmall_reduced"); //mesh->createMesh("cube"); mesh->createMesh("cow_2"); mesh->markCurrentVoronoiPoint(currentVoronoiIndex, Vector4<float>(1.0f, 1.0f, 1.0f, 1.0f)); scene->addGeometry(floor_rect, STATIC); scene->addGeometry(mesh, STATIC); initializeScene(); //Set functions to handle mouse input glfwSetMouseButtonCallback(window, mouseButton); glfwSetCursorPosCallback(window, mouseMotion); glfwSetScrollCallback(window, mouseScroll); glfwSetKeyCallback(window, keyboardInput); // render-loop do { calcFPS(1.0, windowTitle); // Clear the screen glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // render all geometries scene->render(); scene->stepSimulation(); // Swap buffers glfwSwapBuffers(window); glfwPollEvents(); } // Check if the ESC key was pressed or the window was closed while ( glfwGetKey(window, GLFW_KEY_ESCAPE ) != GLFW_PRESS && glfwWindowShouldClose(window) == 0 ); // Clean-up delete scene; // Close OpenGL window and terminate GLFW glfwTerminate(); return 0; }
void SceneBase::onTaskFirstUpdate() { initializeScene(); }
void ScheduleScreen::initializeGraphics() { initializeScene(); createScheduleScene(); addSchedulePoints(); }
void GameCore::startOgre() { reader=new ConfigReader(gameConfigFile); if(reader->readFile()) { writer=new ConfigWriter(gameConfigFile); writer->importConfigReader(reader); reader->pushConfigFile("GameSettings"); std::string pluginsConfig = reader->getFieldValueAsString("ConfigFiles", "plugins-configfile"); std::string resourcesConfig = reader->getFieldValueAsString("ConfigFiles", "resources-configfile"); std::string ogreConfig = reader->getFieldValueAsString("ConfigFiles", "ogre-config"); std::string ogreLogFile = reader->getFieldValueAsString("LogFiles", "ogre-logfile"); std::string gameLogFile = reader->getFieldValueAsString("LogFiles", "game-logfile"); serverTcpPort= reader->getFieldValueAsInteger("NetworkSettings", "tcp-port"); ttftpPort = reader->getFieldValueAsInteger("NetworkSettings", "ttftp-client-port"); nickname=reader->getFieldValueAsString("MultiplayerSettings","nickname"); wallHeight = reader->getFieldValueAsDouble("MapSettings", "wall-height"); mapPath = reader->getFieldValueAsString("MapSettings", "map-lookup-directory"); shadowsEnabled = reader->getFieldValueAsBool("GraphicsSettings", "shadows"); menuBackgroundMusic = reader->getFieldValueAsString("GameSounds", "menu-background"); gameBackgroundMusic = reader->getFieldValueAsString("GameSounds", "game-background"); lmgFireSound = reader->getFieldValueAsString("GameSounds", "lmg-fire"); bgSoundVolume=reader->getFieldValueAsDouble("GameSounds","bg-sound-volume"); bgSoundVolume=(bgSoundVolume<-1?.1:bgSoundVolume); (reader->getFieldValueAsString("MultiplayerSettings","player-color")=="blue"?color=0:color=1); maxDecals=reader->getFieldValueAsInteger("GraphicsSettings","max-decals"); if(maxDecals==-1) maxDecals=30; sensivity=((reader->getFieldValueAsDouble("MultiplayerSettings","mouse-sensivity")<=0?5:reader->getFieldValueAsDouble("MultiplayerSettings","mouse-sensivity"))); moveAnimationSpeed = reader->getFieldValueAsDouble("AnimationSpeeds", "move-speed"); fireAnimationSpeed = reader->getFieldValueAsDouble("AnimationSpeeds", "fire-speed"); moveSpeed=125; buildMap = true; singlePlayerMode = reader->getFieldValueAsBool("Debug", "singleplayer"); if (buildMap) mapFileName = reader->getFieldValueAsString("MapSettings", "map-file-name"); if (mapPath == "NULL") mapPath = "Map/"; else mapPath = mapPath.find("/") == std::string::npos ? mapPath.substr(mapPath.find("/")) : mapPath; gameStarted = teamDM = gameLoaded=false; initializeLogger(gameLogFile); logger->addLine("game config file " + gameConfigFile + " loaded to memory & logger initialized"); LogManager* logManager=new LogManager(); logManager->createLog(ogreLogFile,true,false,false); root = OGRE_NEW Root(pluginsConfig,ogreConfig, ""); ConfigFile configFile; configFile.load(resourcesConfig); //[start]taken from ogre framework Ogre::ConfigFile::SectionIterator seci = configFile.getSectionIterator(); Ogre::String secName, typeName, archName; while (seci.hasMoreElements()) { secName = seci.peekNextKey(); Ogre::ConfigFile::SettingsMultiMap *settings = seci.getNext(); Ogre::ConfigFile::SettingsMultiMap::iterator i; for (i = settings->begin(); i != settings->end(); ++i) { typeName = i->first; archName = i->second; Ogre::ResourceGroupManager::getSingleton().addResourceLocation( archName, typeName, secName); } } //[END] logger->addLine("ogre configuration has been read"); root->showConfigDialog(); renderWindow=root->initialise(true,"Team-Two"); logger->addLine("window created"); sceneManager=root->createSceneManager(ST_EXTERIOR_FAR,"core"); localPlayer=NULL; mapMode=false; mainCamera=sceneManager->createCamera("MainCam"); mainCamera->setNearClipDistance(1);mainCamera->setLodBias(2); mainCamera->setFarClipDistance(100000000); mainCamera->setAspectRatio(renderWindow->getWidth()/(float)renderWindow->getHeight()); menuSceneManager=root->createSceneManager(ST_GENERIC,"menu"); menuCamera=menuSceneManager->createCamera("MenuCam"); menuCamera->setNearClipDistance(1); menuMode=true; viewPort=renderWindow->addViewport(mainCamera); dynamics=NULL; if(shadowsEnabled) sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_STENCIL_ADDITIVE); else sceneManager->setShadowTechnique(Ogre::SHADOWTYPE_NONE); ResourceGroupManager::getSingletonPtr()->initialiseAllResourceGroups(); logger->addLine("GameCore: scanning map files"); lookupMapFiles(mapPath); logger->addLine("GameCore: --ok"); logger->addLine("GameCore: initializing event listeners"); initializeEventListeners(); logger->addLine("GameCore: --ok"); logger->addLine("GameCore: initializing CEGUI"); initializeCEGUI(); logger->addLine("GameCore: --ok"); logger->addLine("GameCore: initializing menu"); initializeMenu(); menuController->showLoading(); root->renderOneFrame(); #if WINDOWS_PLATFORM //Sleep(5000); #else sleep(5); #endif logger->addLine("GameCore: --ok"); logger->addLine("GameCore: initializing ingamemenu"); initializeInGameGUI(); logger->addLine("GameCore: --ok"); logger->addLine("GameCore: initializing networking"); initializeNetworking(); logger->addLine("GameCore: --ok"); //=================================================DEBUG if (singlePlayerMode) { initializePhysics(); logger->addLine("Physics initialized"); initializeScene(); logger->addLine("Scene initialized"); if (buildMap) initializeMap(mapPath + mapFileName); logger->addLine("Map initialized"); _initializeSinglePlayer(); initializeItems(); initializeTeleporters(); } //================================================= logger->addLine("GameCore: initializing sounds"); initializeSounds(); logger->addLine("GameCore: --ok"); root->addFrameListener(this); logger->addLine("GameLoop starting..."); menuController->hideLoading(); gameLoop(); } else std::cout<<"configuration file not found!...\n"; }
int main(int argc, char **argv){ ros::init(argc, argv, "sauna_mcl"); double resolution=0.2; #ifdef USE_VISUALIZATION_DEBUG initializeScene(); #endif ros::NodeHandle n; ros::NodeHandle nh; ros::NodeHandle paramHandle ("~"); TT.Tic(); ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// /// Parameters for the mapper ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// bool loadMap = false; ///< flag to indicate that we want to load a map std::string mapName("basement.ndmap"); ///<name and the path to the map bool makeMapVeryStatic = false; ///< indicates if we should make the map over confident (stationary that is) bool saveMap = true; ///< indicates if we want to save the map in a regular intervals std::string output_map_name = std::string("ndt_mapper_output.ndmap"); ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// /// Set the values from a config file ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// std::string input_laser_topic; paramHandle.param<std::string>("input_laser_topic", input_laser_topic, std::string("/base_scan")); paramHandle.param<std::string>("tf_base_link", tf_state_topic, std::string("/state_base_link")); paramHandle.param<std::string>("tf_laser_link", tf_laser_link, std::string("/hokuyo1_link")); bool use_sensor_pose; paramHandle.param<bool>("use_sensor_pose", use_sensor_pose, false); double sensor_pose_x, sensor_pose_y, sensor_pose_th; paramHandle.param<double>("sensor_pose_x", sensor_pose_x, 0.); paramHandle.param<double>("sensor_pose_y", sensor_pose_y, 0.); paramHandle.param<double>("sensor_pose_th", sensor_pose_th, 0.); paramHandle.param<bool>("load_map_from_file", loadMap, false); paramHandle.param<std::string>("map_file_name", mapName, std::string("basement.ndmap")); paramHandle.param<bool>("save_output_map", saveMap, true); paramHandle.param<std::string>("output_map_file_name", output_map_name, std::string("ndt_mapper_output.ndmap")); paramHandle.param<double>("map_resolution", resolution , 0.2); bool forceSIR=false; paramHandle.param<bool>("forceSIR", forceSIR, false); std::string bagfilename="bagfile_unset.bag"; paramHandle.param<std::string>("bagfile_name", bagfilename, std::string("bagfile_unset.bag")); ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// /// Prepare the map ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// fprintf(stderr,"USING RESOLUTION %lf\n",resolution); lslgeneric::NDTMap<pcl::PointXYZ> ndmap(new lslgeneric::LazyGrid<pcl::PointXYZ>(resolution)); ndmap.setMapSize(80.0, 80.0, 1.0); if(loadMap){ fprintf(stderr,"Loading Map from '%s'\n",mapName.c_str()); ndmap.loadFromJFF(mapName.c_str()); } ndtmcl = new NDTMCL<pcl::PointXYZ>(resolution,ndmap,-0.5); if(forceSIR) ndtmcl->forceSIR=true; fprintf(stderr,"*** FORCE SIR = %d****",forceSIR); ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// /// Open the bag file for reading ////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////// tfMessageReader<sensor_msgs::LaserScan> reader(bagfilename, input_laser_topic, std::string("/world"), tf_odo_topic); ///Set sensor offsets offa = sensor_pose_th; offx = sensor_pose_x; offy = sensor_pose_y; has_sensor_offset_set = true; fprintf(stderr,"Sensor Pose = (%lf %lf %lf)\n",offx, offy, offa); ///Loop while we have data in the bag while(!reader.bagEnd()){ sensor_msgs::LaserScan s; tf::Transform odo_pose; bool hasOdo = false; bool hasState = false; if(reader.getNextMessage(s, odo_pose)){ hasOdo = true; } tf::Transform state_pose; if(reader.getTf(tf_state_topic, s.header.stamp, state_pose)){ hasState = true; } ///If we have the data then lets run the localization if(hasState && hasOdo){ callback(s,odo_pose,state_pose); } } fprintf(stderr,"-- THE END --\n"); return 0; }