示例#1
0
void keyboard( unsigned char key, int x, int y )
{
    // Handle general keyboard options shared across simulations
    
    // Exit on escape key or q
    if( key == 27 || key == 'q' || key == 'Q' )
    {
        exit(0);
    }
    // Step the system forward one timestep
    else if( key == 's' || key =='S' )
    {
        stepSystem();
        glutPostRedisplay();
    }
    // Space bar pauses and unpauses
    else if( key == ' ' )
    {
        g_paused = !g_paused;
    }
    //  else if( key == 'c' || key == 'C' )
    //  {
    //    centerCamera();
    //    g_display_controller.reshape(g_display_controller.getWindowWidth(),g_display_controller.getWindowHeight());
    //    glutPostRedisplay();
    //  }
#ifdef PNGOUT
    // Save a png screenshot
    else if( key == 'i' || key == 'I' )
    {
        std::cout << outputmod::startpink << "TDSmoke STATUS: " << outputmod::endpink << "Saving screenshot as 'output.png'." << std::endl;
        dumpPNG("output.png");
    }
#endif
    
    // Allow the simulation to respond to keyboard input on its own
    g_simulation_ensemble->keyboard(key,x,y);
    
    glutPostRedisplay();
    assert( renderingutils::checkGLErrors() );
}
示例#2
0
void stepSystem()
{
    // If the user wants to generate a PNG movie
#ifdef PNGOUT
        std::stringstream oss;
        oss << g_movie_dir << "/frame" << std::setw(5) << std::setfill('0') << g_current_step << ".png";
        //std::cout << outputmod::startpink << "TDSmoke STATUS: " << outputmod::endpink << "Saving png to " << oss.str() << ". Exiting." << std::endl;
        dumpPNG(oss.str());
#endif
    
    // Determine if the simulation is complete.
    if( g_current_step >= g_final_step )
    {
        if( !g_opengl_rendering_enabled ) std::cout << std::endl;
        std::cout << outputmod::startpink << "TDSmoke STATUS: " << outputmod::endpink << "Simulation complete at time " << g_current_step*g_dt << ". Exiting." << std::endl;
        g_simulation_ran_to_completion = true;
        exit(0);
    }
    
    // Step the system forward in time
    g_simulation_ensemble->stepSystem(g_dt);
    g_current_step++;
}
示例#3
0
void stepSystem()
{
  assert( !(g_save_to_binary&&g_simulate_comparison) );

  // Determine if the simulation is complete
  if( g_current_step >= g_num_steps )
  {
    std::cout << outputmod::startpink << "FOSSSim message: " << outputmod::endpink << "Simulation complete at time " << g_current_step*g_dt << ". Exiting." << std::endl;
    g_simulation_ran_to_completion = true;
    exit(0);
  }  

  // If comparing simulations, copy state of comparison scene to simulated scene
  if( g_simulate_comparison ) {
    g_executable_simulation->copyComparisonSceneToScene();
  }

  // Step the system forward in time
  g_executable_simulation->stepSystem(g_dt);
  g_current_step++;

  // If the user wants to save output to a binary
  if( g_save_to_binary ) 
    {
      g_executable_simulation->serializeScene(g_binary_output);
    }
  

  // Update the state of the renderers
  if( g_rendering_enabled ) g_executable_simulation->updateOpenGLRendererState();
  g_executable_simulation->updateSVGRendererState();

  // If comparing simulations, load comparison scene's equivalent step
  if( g_simulate_comparison ) g_executable_simulation->loadComparisonScene(g_binary_input);

  // If the user wants to generate a SVG movie
  if( g_svg_enabled )
  {
    // Generate a filename
    std::stringstream name;
    name << std::setfill('0');
    name << g_movie_dir << "/frame" << std::setw(20) << g_current_step << ".svg";    
    // Actually write the svg out
    g_executable_simulation->renderSceneSVG(name.str());    
  }  
  
  // If comparing simulations, compute the accumulated residual
  if( g_simulate_comparison ) g_executable_simulation->updateSceneComparison();
  
  // If the user wants to generate a PNG movie
  #ifdef PNGOUT
    std::stringstream oss;
    oss << "pngs/frame" << std::setw(5) << std::setfill('0') << g_current_step << ".png";
    dumpPNG(oss.str());
  #endif

  // Execute the user-customized output callback
  miscOutputCallback();

  // Execute the user-customized scripting callback
  sceneScriptingCallback();

}