void Sample::think(double time) { static bool oddStep = true; // // CUDA Compute // // PASS 0 (compute): compute the volume scalar field for the next time step simulateOpenCL( /*dt =*/ 0.5f, oddStep); // 0.5 happens to be numerically stable for this simple explicit heat propagator // // OpenGL Visualize // // Update any camera changes viewUpdate(); // PASS 1: Frontface distance renderGLFrontface(); // PASS 2: Volume raycasting renderGLVolume(oddStep); oddStep = !oddStep; // ...Draw the UI renderUI(getWidth(), getHeight(), time - m_prevTime); m_prevTime = time; }
bool WMTemplateRoiSelection::processCompute( WLEMMeasurement::SPtr emm ) { WLTimeProfiler tp( "WMTemplateRoiSelection", __func__ ); // show process visualization WProgress::SPtr processComp( new WProgress( "Do the process." ) ); m_progress->addSubProgress( processComp ); // ---------- PROCESSING ---------- viewUpdate( emm ); // ---------- OUTPUT ---------- WLEMMCommand::SPtr cmd( new WLEMMCommand( WLEMMCommand::Command::COMPUTE ) ); cmd->setEmm( emm ); m_output->updateData( cmd ); // update the output-connector after processing processComp->finish(); // finish the process visualization return true; }
bool MasterConfig::handleEvent( eq::EventCommand command ) { switch( command.getEventType( )) { case eq::Event::CHANNEL_POINTER_BUTTON_PRESS: { const eq::Event& event = command.get< eq::Event >(); _currentViewID = event.context.view.identifier; return true; } case eq::Event::KEY_PRESS: case eq::Event::KEY_RELEASE: if( Config::handleEvent( command )) { _redraw = true; LBVERB << "Redraw: requested by eq::Config" << std::endl; } // no break; case eq::Event::CHANNEL_POINTER_BUTTON_RELEASE: case eq::Event::CHANNEL_POINTER_MOTION: case eq::Event::WINDOW_POINTER_WHEEL: case eq::Event::MAGELLAN_AXIS: { if( _currentViewID == uint128_t::ZERO ) return false; View* view = static_cast<View*>( find<eq::View>( _currentViewID )); if( view->handleEvent( command )) { _redraw = true; LBVERB << "Redraw: requested by view event handler" << std::endl; } return true; } case eq::Event::STATISTIC: { Config::handleEvent( command ); const eq::Event& event = command.get< eq::Event >(); if( event.statistic.type != eq::Statistic::CONFIG_FINISH_FRAME ) return false; ViewUpdateVisitor viewUpdate( _redraw ); accept( viewUpdate ); return _redraw; } case eq::Event::WINDOW_EXPOSE: case eq::Event::WINDOW_RESIZE: case eq::Event::WINDOW_CLOSE: case eq::Event::VIEW_RESIZE: _redraw = true; LBVERB << "Redraw: window change" << std::endl; break; default: break; } if( eq::Config::handleEvent( command )) { _redraw = true; LBVERB << "Redraw: requested by config event handler" << std::endl; } return _redraw; }
// Game Start Methode. void Game::run() { // Initalisierung einer Uhr sf::Time timeSinceLastUpdate = sf::Time::Zero; Player.setName(XMLDoc.loadPlayerName()); Player.setPosition(200,200); begin = clock(); // Solange das Fenster Offen ist. while (Window.isOpen()) { sf::Time frameTime = frameClock.restart(); timeSinceLastUpdate += frameTime; initPlayerPosition(); // Überprüfung ob man gewonnen hat. if(World.checkGoal()) { bool RankingSuccess = false; end = clock(); // Zeit messung ende. // Zeit in Sekunden ausrechnen. elapsed_secs = double(end - begin) / CLOCKS_PER_SEC; // Zum Zeit in Int umwandeln für die Sekunden. if(checkRanking((int)elapsed_secs)) { RankingSuccess = true; } Window.close(); InfoFenster.Window_Success(RankingSuccess); } // Game Over wenn 0 Leben. if(Player.getLeben() == 0) { Window.close(); InfoFenster.Abspann(600, 600); } while (timeSinceLastUpdate > TimePerFrame) { timeSinceLastUpdate -= TimePerFrame; processEvents(); update(TimePerFrame); } // Gravitation erstellen. GravityFall(); GravityUp(); // Auswertung Kollision. if(World.checkKollision()) { Player.MinusLeben(); movement.x =- 5000.f; } //Bewegung ausführen Player.AnimationTest(movement, frameTime, 0, PlayerModel); // View anpassen. viewUpdate(); // Wenn keine Taste gedrückt, Animation stoppen. if (noKeyWasPressed) { Player.AnimationTest(movement, frameTime, 1, PlayerModel); } noKeyWasPressed = true; // Drawn des Games render(); } }
bool WMHeadPositionCorrection::processCompute( WLEMMeasurement::SPtr emm ) { if( !emm->hasModality( WLEModality::MEG ) ) { errorLog() << "No MEG data available!"; return false; } if( !emm->hasModality( WLEModality::HPI ) ) { errorLog() << "No HPI data available!"; return false; } if( !m_hasRefPos ) { if( !emm->getHpiInfo()->getDevToHead()->empty() ) { WLEMMHpiInfo::TransformationT::SPtr t = emm->getHpiInfo()->getDevToHead()->inverse(); m_correction.setRefTransformation( *t ); m_hasRefPos = true; m_propStatus->set( STATUS_REF_POS, true ); infoLog() << "Set reference position from EMM: \n" << *t; } else { errorLog() << "No reference head position!"; return false; } } WLTimeProfiler profiler( getName(), __func__, true ); WLEMDMEG::SPtr meg = emm->getModality< WLEMDMEG >( WLEModality::MEG ); WLEMDHPI::SPtr hpi = emm->getModality< WLEMDHPI >( WLEModality::HPI ); WLEMDMEG::SPtr megOut( new WLEMDMEG( *meg ) ); if( !m_correction.isInitialzied() ) { WLEMDMEG::createCoilInfos( meg.get() ); m_correction.setMegCoilInfos( meg->getCoilInformation() ); m_correction.setMovementThreshold( m_propMvThreshold->get( false ) ); m_correction.setSphereRadius( m_propRadius->get( false ) ); m_correction.init(); } if( !m_correction.process( megOut.get(), *meg, *hpi ) ) { errorLog() << "Error in correcting head position!"; return false; } WLEMMeasurement::SPtr emmOut = emm->clone(); std::vector< WLEMData::SPtr > mods = emm->getModalityList(); for( size_t i = 0; i < mods.size(); ++i ) { if( mods[i]->getModalityType() == WLEModality::MEG ) { mods[i] = megOut; break; } } emmOut->setModalityList( mods ); viewUpdate( emmOut ); WLEMMCommand::SPtr cmdOut( new WLEMMCommand( WLEMMCommand::Command::COMPUTE ) ); cmdOut->setEmm( emmOut ); m_output->updateData( cmdOut ); return true; }