本文整理汇总了C++中ogre::Timer类的典型用法代码示例。如果您正苦于以下问题:C++ Timer类的具体用法?C++ Timer怎么用?C++ Timer使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Timer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: go
void Application::go()
{
Ogre::Timer loopTimer;
bool continueRunning = true;
while ( continueRunning )
{
Ogre::WindowEventUtilities::messagePump();
SimpleInputManager::capture();
// Update logic stuff
// Update graphics stuff
bool windowClosed = m_window->isClosed();
continueRunning &= ! windowClosed;
loopTimer.reset();
bool renderFrameSuccess = m_root->renderOneFrame();
continueRunning &= renderFrameSuccess;
continueRunning &= ! m_exitRequested;
}
}
示例2: update
void Application::update()
{
Ogre::Timer loopTimer;
bool continueRunning = true;
while (continueRunning)
{
Ogre::WindowEventUtilities::messagePump();
SimpleInputManager::capture();
float elapsedSeconds = loopTimer.getMicroseconds() * 1.0 / 1000000;
m_NXOgreTimeController->advance(elapsedSeconds);
loopTimer.reset();
updateOverlayInfo();
bool renderFrameSuccess = m_root->renderOneFrame();
if (!renderFrameSuccess || m_exitRequested)
{
continueRunning = false;
}
}
}
示例3: UpdThr
void App::UpdThr()
{
Ogre::Timer gtim;
//#ifdef _WIN32
//DWORD af = 2;
//gtim.setOption("QueryAffinityMask", &af);
//#endif
gtim.reset();
while (!mShutDown)
{
/// step Game **
double dt = double(gtim.getMicroseconds()) * 0.000001;
gtim.reset();
if (pSet->multi_thr == 1 && !bLoading)
{
bSimulating = true;
bool ret = pGame->OneLoop(dt);
if (!ret)
mShutDown = true;
DoNetworking();
bSimulating = false;
}
boost::this_thread::sleep(boost::posix_time::milliseconds(pSet->thread_sleep));
}
}
示例4: Run
// Run
//-------------------------------------------------------------------------------------
void BaseApp::Run( bool showDialog )
{
mShowDialog = showDialog;
if (!setup())
return;
if (!pSet->limit_fps)
mRoot->startRendering(); // default
else
{ Ogre::Timer tim;
while (1)
{
Ogre::WindowEventUtilities::messagePump();
if (tim.getMicroseconds() > 1000000.0 / pSet->limit_fps_val)
{
tim.reset();
if (!mRoot->renderOneFrame())
break;
}else
if (pSet->limit_sleep >= 0)
boost::this_thread::sleep(boost::posix_time::milliseconds(pSet->limit_sleep));
} }
destroyScene();
}
示例5: initializeCEGUI
void Application::initializeCEGUI()
{
Ogre::Timer timer;
timer.reset();
CEGUI::OgreRenderer::bootstrapSystem(*mOgreWindow);
mUIRoot = static_cast<CEGUI::GUISheet*>(CEGUI::WindowManager::getSingleton().createWindow("DefaultWindow", "Root"));
mUIRoot->setPosition(CEGUI::UVector2(CEGUI::UDim(0, 0), CEGUI::UDim(0, 0)));
mUIRoot->setSize(CEGUI::UVector2(CEGUI::UDim(1, 0), CEGUI::UDim(1, 0)));
mUIRoot->setVisible(true);
CEGUI::System::getSingleton().setGUISheet(mUIRoot);
CEGUI::SchemeManager::getSingleton().create("OISBDemo.scheme");
CEGUI::System::getSingleton().setDefaultMouseCursor("OgreTrayImages", "MouseArrow");
CEGUI::MouseCursor::getSingleton().hide();
//mUIRoot->addChildWindow(CEGUI::WindowManager::getSingleton().loadWindowLayout("Introduction.layout"));
mUIRoot->addChildWindow(CEGUI::WindowManager::getSingleton().loadWindowLayout("HUD.layout"));
mUIHUDThrottle = static_cast<CEGUI::ProgressBar*>(CEGUI::WindowManager::getSingleton().getWindow("HUD/Throttle"));
mUIHUDVelocity = CEGUI::WindowManager::getSingleton().getWindow("HUD/Velocity");
mUIHUDAltitude = CEGUI::WindowManager::getSingleton().getWindow("HUD/Altitude");
std::stringstream sstr;
sstr << timer.getMicroseconds();
CEGUI::Logger::getSingleton().logEvent("Time to start CEGUI: " + sstr.str());
}
示例6: go
//-------------------------------------------------------------------------------------
void App::go(void)
{
#ifdef _DEBUG
mResourcesCfg = "resources_d.cfg";
mPluginsCfg = "plugins_d.cfg";
#else
mResourcesCfg = "resources.cfg";
mPluginsCfg = "plugins.cfg";
#endif
if (!setup())
return;
Ogre::Timer timer;
//mRoot->startRendering();
float lastTime = timer.getMicroseconds()/1000000.0f;
float curTime = timer.getMicroseconds()/1000000.0f;
while(update(curTime - lastTime))
{
lastTime = curTime;
curTime = timer.getMicroseconds()/1000000.0f;
//timer.reset();
}
// clean up
destroyScene();
}
示例7: if
void OMW::Engine::go()
{
assert (!mContentFiles.empty());
assert (!mOgre);
Settings::Manager settings;
std::string settingspath;
settingspath = loadSettings (settings);
// Create encoder
ToUTF8::Utf8Encoder encoder (mEncoding);
mEncoder = &encoder;
prepareEngine (settings);
// Play some good 'ol tunes
MWBase::Environment::get().getSoundManager()->playPlaylist(std::string("Explore"));
if (!mSaveGameFile.empty())
{
MWBase::Environment::get().getStateManager()->loadGame(mSaveGameFile);
}
else if (!mSkipMenu)
{
// start in main menu
MWBase::Environment::get().getWindowManager()->pushGuiMode (MWGui::GM_MainMenu);
try
{
// Is there an ini setting for this filename or something?
MWBase::Environment::get().getSoundManager()->streamMusic("Special/morrowind title.mp3");
std::string logo = mFallbackMap["Movies_Morrowind_Logo"];
if (!logo.empty())
MWBase::Environment::get().getWindowManager()->playVideo(logo, true);
}
catch (...) {}
}
else
{
MWBase::Environment::get().getStateManager()->newGame (!mNewGame);
}
// Start the main rendering loop
Ogre::Timer timer;
while (!MWBase::Environment::get().getStateManager()->hasQuitRequest())
{
float dt = timer.getMilliseconds()/1000.f;
dt = std::min(dt, 0.2f);
timer.reset();
Ogre::Root::getSingleton().renderOneFrame(dt);
}
// Save user settings
settings.saveUser(settingspath);
std::cout << "Quitting peacefully." << std::endl;
}
示例8: Run
::FreeConsole();
}
void Game::Run()
{
InitializeGame();
ConnectToPVD();
InitializeKinect();
kinectController = BodyController();
InputManager* inputManager = InputManager::GetInstance();
inputManager->RegisterSensorListener(&kinectController);
inputManager->BeginAllCapture();
sceneManager = new SceneManager();
sceneManager->Initialize(mWindow, mRoot);
AllocConsole();
freopen("conin$","r",stdin);
freopen("conout$","w",stdout);
freopen("conout$","w",stderr);
printf("Debugging Window:\n");
/*std::shared_ptr<GameScene> gameScene(new GameScene(sceneManager, mRoot, "Probending Arena", contestantData));
sceneManager->FlagSceneSwitch(gameScene, true);
gameScene.reset();*/
std::shared_ptr<MenusScene> menuScene = std::make_shared<MenusScene>(sceneManager, mRoot, MenusScene::Screens::MainMenu);
sceneManager->FlagSceneSwitch(menuScene, true);
menuScene.reset();
bool rendering = true;
Ogre::Timer gameTimer = Ogre::Timer();
float currentTime = 0;
float previousTime = 0;
while (rendering)
{
gameTimer.reset();
if(!Update(currentTime / 1000.0f))
rendering = false;
//Ogre::WindowEventUtilities::messagePump();
#if(!MEMORY_LEAK_DETECT)
mRoot->renderOneFrame();
#endif
currentTime = (float)gameTimer.getMilliseconds();
示例9: renderThreadApp
//---------------------------------------------------------------------
unsigned long renderThreadApp(Ogre::ThreadHandle* threadHandle) {
LeDernierMorkid::LeDernierMorkidThreadData* threadData = reinterpret_cast<LeDernierMorkid::LeDernierMorkidThreadData*>(threadHandle->getUserParam());
GraphicsSystem* graphicsSystem = threadData->graphicsSystem;
Ogre::Barrier* barrier = threadData->barrier;
graphicsSystem->initialize("Le Dernier Morkid");
graphicsSystem->getInputHandler()->setGrabMousePointer(true);
graphicsSystem->getInputHandler()->setMouseVisible(false);
barrier->sync();
if (graphicsSystem->getQuit()) {
graphicsSystem->deinitialize();
return 0; // User cancelled config
}
graphicsSystem->createScene();
barrier->sync();
Ogre::RenderWindow* renderWindow = graphicsSystem->getRenderWindow();
Ogre::Timer timer;
unsigned long startTime = timer.getMicroseconds();
double timeSinceLast = 1.0 / 60.0;
while (!graphicsSystem->getQuit()) {
graphicsSystem->beginFrameParallel();
graphicsSystem->update(timeSinceLast);
graphicsSystem->finishFrameParallel();
if (!renderWindow->isVisible()) {
// Don't burn CPU cycles unnecessary when we're minimized.
Ogre::Threads::Sleep(500);
}
unsigned long endTime = timer.getMicroseconds();
timeSinceLast = (endTime - startTime) / 1000000.0;
timeSinceLast = std::min(1.0, timeSinceLast); // Prevent from going haywire.
startTime = endTime;
}
barrier->sync();
graphicsSystem->destroyScene();
barrier->sync();
graphicsSystem->deinitialize();
barrier->sync();
return 0;
}
示例10: yield
unsigned long yield( double frameTime, unsigned long startTime )
{
unsigned long endTime = mExternalTimer->getMicroseconds();
while( frameTime * 1000000.0 > (endTime - startTime) )
{
endTime = mExternalTimer->getMicroseconds();
#if OGRE_PLATFORM == OGRE_PLATFORM_WIN32
SwitchToThread();
#elif OGRE_PLATFORM == OGRE_PLATFORM_LINUX || OGRE_PLATFORM == OGRE_PLATFORM_ANDROID
sched_yield();
#endif
}
return endTime;
}
示例11: run
void Application::run()
{
initialize();
setupScene();
Ogre::Timer timer;
timer.reset();
mRunning = true;
while (mRunning)
{
const Ogre::Real delta=
timer.getMicroseconds() * static_cast<Ogre::Real>(0.000001f);
timer.reset();
runOneFrame(delta);
}
finalize();
}
示例12: frameRenderingQueued
// FrameListener callback (~ idleFunc). Perform animation here
bool frameRenderingQueued(const Ogre::FrameEvent& evt) {
float t = mTimer.getMilliseconds()*0.001;
// Do some simple animations by changing scene node transform parameters
Ogre::SceneNode* triangle = mScene->getSceneNode("Triangle");
triangle->resetToInitialState();
triangle->rotate(Ogre::Vector3(0, 0, 1), Ogre::Radian(t));
// Exercise 1: Use SceneNode to manipulate the object and create animation
// ...
return true; // Return false to quit
}
示例13: CreateTerrain
///--------------------------------------------------------------------------------------------------------------
// Create Terrain
///--------------------------------------------------------------------------------------------------------------
void CScene::CreateTerrain(bool bNewHmap, bool bTer, bool terLoad)
{
Ogre::Timer tm;
terrain = 0;
/// sky
Vector3 scl = app->pSet->view_distance*Vector3::UNIT_SCALE;
CreateSkyDome(sc->skyMtr, scl, sc->skyYaw);
UpdFog();
// light
app->mSceneMgr->destroyAllLights();
sun = app->mSceneMgr->createLight("Sun");
sun->setType(Light::LT_DIRECTIONAL); UpdSun();
if (bTer)
{
///.
UpdShaderParams();
UpdLayerPars();
/// -------- fill HeightField data --------
//Ogre::Timer ti;
if (terLoad || bNewHmap)
{
int wx = sc->td.iVertsX, wy = sc->td.iVertsY, wxy = wx * wy; //wy=wx
delete[] sc->td.hfHeight; sc->td.hfHeight = new float[wxy];
const int size = wxy * sizeof(float);
String name = app->gcom->TrkDir() + (bNewHmap ? "heightmap-new.f32" : "heightmap.f32");
// load from f32 HMap +
{
std::ifstream fi;
fi.open(name.c_str(), std::ios_base::binary);
fi.read((char*)&sc->td.hfHeight[0], size);
fi.close();
}
}
CreateBlendTex(); //+
//LogO(String("::: Time Hmap: ") + fToStr(ti.getMilliseconds(),0,3) + " ms"); ti.reset(); // 4MB ~13ms
///.
UpdBlendmap();
// Terrain
{
if (!mTerrainGlobals)
mTerrainGlobals = OGRE_NEW TerrainGlobalOptions();
OGRE_DELETE mTerrainGroup;
mTerrainGroup = OGRE_NEW TerrainGroup(app->mSceneMgr, Terrain::ALIGN_X_Z,
sc->td.iTerSize, sc->td.fTerWorldSize);
mTerrainGroup->setOrigin(Vector3::ZERO);
SetupTerrain();
if (sc->td.hfHeight)
mTerrainGroup->defineTerrain(0,0, sc->td.hfHeight);
else
mTerrainGroup->defineTerrain(0,0, 0.f);
// sync load since we want everything in place when we start
mTerrainGroup->loadAllTerrains(true);
TerrainGroup::TerrainIterator ti = mTerrainGroup->getTerrainIterator();
while (ti.hasMoreElements())
{
Terrain* t = ti.getNext()->instance;
terrain = t; //<set
terrain->setVisibilityFlags(RV_Terrain);
}
mTerrainGroup->freeTemporaryResources();
}
// Horizon ----------
if (app->pSet->horizon)
{
if (!mHorizonGlobals)
mHorizonGlobals = OGRE_NEW TerrainGlobalOptions();
OGRE_DELETE mHorizonGroup;
mHorizonGroup = OGRE_NEW TerrainGroup(app->mSceneMgr, Terrain::ALIGN_X_Z,
sc->td.iTerSize, sc->td.fTerWorldSize * 16.f);
mHorizonGroup->setOrigin(Vector3::ZERO);
SetupHorizon();
//if (sc->td.hfHeight)
// mHorizonGroup->defineTerrain(0,0, sc->td.hfHeight);
//.........这里部分代码省略.........
示例14: Play
void Client::Play() {
OgreEasy::SimpleOgreInit lOgreInit;
if(!lOgreInit.initOgre()) {
std::cout<<"Could not init ogre"<<std::endl;
return;
}
Ogre::Root* lRoot = lOgreInit.mRoot.get();
Ogre::RenderWindow* lWindow = lOgreInit.mWindow;
World* w = new World();
w->SetDebugMode(false);
GameObject camObject = w->AddObject("camera");
camObject.AddCameraComponent("camera");
camObject.SetPosition(Ogre::Vector3(0,0,0));
camObject.LookAt(Ogre::Vector3(0,0,0));
GameObject& light2 = w->AddObject("point_light");
light2.AddLightComponent(Ogre::Light::LT_DIRECTIONAL);
light2.SetPosition(Ogre::Vector3(0,0,40));
light2.LookAt(Ogre::Vector3(0,100,0));
GameObject& c = w->AddPhysicsObject("esine", "cube/Cube.mesh");
c.SetPosition(Ogre::Vector3(0,0,0));
c.AddBoxCollider(1,1,1);
PhysicsComponent phys = c.GetPhysicsComponent();
phys.SetMass(1.0);
c.SetMaterial("tex");
GameObject& c2 = w->AddPhysicsObject("esine2", "cube/Cube.mesh");
c2.SetPosition(Ogre::Vector3(1,2,1));
c2.AddBoxCollider(1,1,1);
PhysicsComponent phys2 = c2.GetPhysicsComponent();
phys2.SetMass(1.0);
c2.SetMaterial("tex");
GameObject& taso = w->AddPhysicsObject("taso", "cube/other/Cube.mesh");
taso.SetPosition(Ogre::Vector3(0, -10, 0));
taso.AddBoxCollider(10,0.1,10);
taso.SetMaterial("plane");
PhysicsComponent phys3 = taso.GetPhysicsComponent();
phys3.SetMass(0.0);
GameObject& anim = w->AddObject("anim" , "second_anim/Cube.mesh");
anim.SetPosition(Ogre::Vector3(0, -5, 0));
anim.SetMaterial("tex");
lRoot->clearEventTimes();
float f=0.0;
unsigned long t=0;
double d;
Ogre::Timer* a = new Ogre::Timer();
while(!lWindow->isClosed()) {
t=a->getMicroseconds();
camObject.SetPosition(Ogre::Vector3(cos(f)*15.0, -5, sin(f)*15.0));
camObject.LookAt(Ogre::Vector3(-0,-10,-0), Ogre::Vector3::UNIT_Y);
w->Update(d);
f+=d*.5;
d = (double)(a->getMicroseconds()-t)/1000000;
}
delete w;
}
示例15: LoadTrackEv
void App::LoadTrackEv()
{
Ogre::Timer ti;
NewCommon(false); // full destroy
iObjCur = -1;
scn->DestroyRoad();
scn->DestroyPace();
// load scene
scn->sc->LoadXml(gcom->TrkDir()+"scene.xml");
scn->sc->vdr = IsVdrTrack();
if (scn->sc->vdr) scn->sc->ter = false;
// water RTT recreate
scn->UpdateWaterRTT(mCamera);
BltWorldInit();
UpdWndTitle();
scn->CreateFluids();
scn->CreateWeather();
// set sky tex name for water
sh::MaterialInstance* m = mFactory->getMaterialInstance(scn->sc->skyMtr);
std::string skyTex = sh::retrieveValue<sh::StringValue>(m->getProperty("texture"), 0).get();
sh::Factory::getInstance().setTextureAlias("SkyReflection", skyTex);
sh::Factory::getInstance().setTextureAlias("CubeReflection", "ReflectionCube");
bNewHmap = false;/**/
scn->CreateTerrain(bNewHmap, scn->sc->ter);
if (track)
if (scn->sc->vdr) // vdrift track
{
if (!LoadTrackVdr(pSet->gui.track))
LogO("Error during track loading: " + pSet->gui.track);
CreateVdrTrack(pSet->gui.track, track);
CreateVdrTrackBlt();
}
// road ~
scn->road = new SplineRoad(this);
scn->road->Setup("sphere.mesh", pSet->road_sphr, scn->terrain, mSceneMgr, mCamera);
scn->road->LoadFile(gcom->TrkDir()+"road.xml");
scn->UpdPSSMMaterials();
// pace ~ ~
scn->pace = new PaceNotes(pSet);
scn->pace->Setup(mSceneMgr, mCamera, scn->terrain, gui->mGui, mWindow);
/// HW_Inst Test * * *
//inst = new Instanced();
//inst->Create(mSceneMgr,"sphere_inst.mesh");
CreateObjects();
if (pSet->bTrees && scn->sc->ter)
scn->CreateTrees(); // trees after objects so they aren't inside them
// updates after load
//--------------------------
gcom->ReadTrkStats();
gui->SetGuiFromXmls(); ///
Rnd2TexSetup();
//UpdVisGui();
//UpdStartPos();
UpdEditWnds(); //
try {
TexturePtr tex = TextureManager::getSingleton().getByName("waterDepth.png");
if (!tex.isNull())
tex->reload();
} catch(...) { }
gui->Status("#{Loaded}", 0.5,0.7,1.0);
if (pSet->check_load)
gui->WarningsCheck(scn->sc, scn->road);
LogO(String("::: Time Load Track: ") + fToStr(ti.getMilliseconds(),0,3) + " ms");
}