void World::render(){ renderWorld(); _team1.p->render(); centerCamera(); for (list<Bullet>::iterator it = _team1.proj.begin(); it != _team1.proj.end(); ++it){ it->render(); } }
void loadScene( const std::string& file_name ) { // Maximum time in the simulation to run for. This has nothing to do with run time, cpu time, etc. This is time in the 'virtual world'. scalar max_time; // Maximum frequency, in wall clock time, to execute the simulation for. This serves as a cap for simulations that run too fast to see a solution. scalar steps_per_sec_cap = 100.0; // Contains the center and 'scale factor' of the view renderingutils::Viewport view; // Load the simulation and pieces of rendring and UI state assert( g_executable_simulation == NULL ); TwoDSceneXMLParser xml_scene_parser; xml_scene_parser.loadExecutableSimulation( file_name, g_simulate_comparison, g_rendering_enabled, g_display_controller, &g_executable_simulation, view, g_dt, max_time, steps_per_sec_cap, g_bgcolor, g_description, g_scene_tag ); assert( g_executable_simulation != NULL ); g_scene = xml_scene_parser.getScene(); // If the user did not request a custom viewport, try to compute a reasonable default. if( view.size <= 0.0 ) { centerCamera(); } // Otherwise set the viewport per the user's request. else { g_display_controller.setCenterX(view.cx); g_display_controller.setCenterY(view.cy); g_display_controller.setScaleFactor(view.size); } // To cap the framerate, compute the minimum time a single timestep should take g_sec_per_frame = 1.0/steps_per_sec_cap; // Integer number of timesteps to take g_num_steps = ceil(max_time/g_dt); // We begin at the 0th timestep g_current_step = 0; }
void keyboard( unsigned char key, int x, int y ) { g_display_controller.keyboard(key,x,y); if( key == 27 || key == 'q' ) { exit(0); } else if( key == 's' || key =='S' ) { stepSystem(); glutPostRedisplay(); } else if( key == ' ' ) { // int x = fork(); // if(x==0) { // system("play thermo.dat"); // exit(1); // } g_paused = !g_paused; } else if( key == 'c' || key == 'C' ) { centerCamera(); g_display_controller.reshape(g_display_controller.getWindowWidth(),g_display_controller.getWindowHeight()); glutPostRedisplay(); } else if( key == 'i' || key == 'I' ) { std::cout << outputmod::startpink << "FOSSSim message: " << outputmod::endpink << "Saving screenshot as 'output.svg'." << std::endl; g_executable_simulation->renderSceneSVG("output.svg"); } assert( renderingutils::checkGLErrors() ); }
Window::Window( const QString& scene_name, QWidget* parent ) : QMainWindow( parent ) , m_content_widget( nullptr ) { m_content_widget = new ContentWidget{ scene_name, this }; QMenu* file{ menuBar()->addMenu( tr( "File" ) ) }; QMenu* view{ menuBar()->addMenu( tr( "View" ) ) }; QAction* separator{ new QAction{ this } }; separator->setSeparator( true ); // File menu actions // Load the input xml file QAction* open_scene{ new QAction{ tr( "Open..." ), this } }; open_scene->setShortcut( tr( "Ctrl+o" ) ); file->addAction( open_scene ); connect( open_scene, SIGNAL( triggered() ), m_content_widget, SLOT( openScene() ) ); // Reload the current xml file QAction* reload_scene{ new QAction{ tr( "Reload" ), this } }; reload_scene->setShortcut( tr( "Ctrl+r" ) ); file->addAction( reload_scene ); connect( reload_scene, SIGNAL( triggered() ), m_content_widget, SLOT( reloadScene() ) ); // Add a separator file->addAction( separator ); // Export an image of the scene QAction* export_image{ new QAction{ tr( "Export Image..." ), this } }; export_image->setShortcut( tr( "Ctrl+i" ) ); file->addAction( export_image ); connect( export_image, SIGNAL( triggered() ), m_content_widget, SLOT( exportImage() ) ); // Export a movie of the scene QAction* export_movie{ new QAction{ tr( "Export Movie..." ), this } }; export_movie->setShortcut( tr( "Ctrl+m" ) ); file->addAction( export_movie ); connect( export_movie, SIGNAL( triggered() ), m_content_widget, SLOT( exportMovie() ) ); // Add a separator QAction* separator2{ new QAction{ this } }; separator2->setSeparator( true ); file->addAction( separator2 ); // Export the current camera settings QAction* export_camera_settings{ new QAction{ tr( "Export Camera..." ), this } }; file->addAction( export_camera_settings ); connect( export_camera_settings, SIGNAL( triggered() ), m_content_widget, SLOT( exportCameraSettings() ) ); // View menu actions // Toggle the heads up display QAction* toggle_hud{ new QAction{ tr( "Togge HUD" ), this } }; toggle_hud->setShortcut( tr( "h" ) ); view->addAction( toggle_hud ); connect( toggle_hud, SIGNAL( triggered() ), m_content_widget, SLOT( toggleHUD() ) ); // Add a separator view->addAction( separator ); // Center the camera QAction* center_camera{ new QAction( tr( "Center Camera" ), this ) }; center_camera->setShortcut( tr( "c" ) ); view->addAction( center_camera ); connect( center_camera, SIGNAL( triggered() ), m_content_widget, SLOT( centerCamera() ) ); setCentralWidget( m_content_widget ); }