Changeset 1422 for code/branches/network/src/orxonox
- Timestamp:
- May 25, 2008, 8:29:05 PM (17 years ago)
- Location:
- code/branches/network/src/orxonox
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
code/branches/network/src/orxonox/Orxonox.cc
r1414 r1422 466 466 timer_->reset(); 467 467 468 float renderTime = 0.0f; 469 float frameTime = 0.0f; 470 clock_t time = 0; 471 468 472 COUT(3) << "Orxonox: Starting the main loop." << std::endl; 469 473 while (!bAbort_) … … 480 484 evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]); 481 485 evt.timeSinceLastFrame = calculateEventTime(now, eventTimes[1]); 486 frameTime += evt.timeSinceLastFrame; 482 487 483 488 // show the current time in the HUD 484 489 // HUD::getSingleton().setTime(now); 490 if (frameTime > 0.4f) 491 { 492 HUD::getSingleton().setRenderTimeRatio(renderTime / frameTime); 493 frameTime = 0.0f; 494 renderTime = 0.0f; 495 } 485 496 486 497 // Call those objects that need the real time 498 for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it) 499 it->tick((float)evt.timeSinceLastFrame); 500 // Call the scene objects 487 501 for (Iterator<Tickable> it = ObjectList<Tickable>::start(); it; ++it) 488 502 it->tick((float)evt.timeSinceLastFrame * this->timefactor_); 489 // Call the scene objects490 for (Iterator<TickableReal> it = ObjectList<TickableReal>::start(); it; ++it)491 it->tick((float)evt.timeSinceLastFrame);492 503 // TODO: currently a hack. Somehow the console doesn't work with OrxonoxClass 493 504 orxonoxConsole_->tick((float)evt.timeSinceLastFrame); … … 497 508 ogreRoot._fireFrameStarted(evt); 498 509 499 ogreRoot._updateAllRenderTargets(); // only render in non-server mode500 501 510 // get current time 502 511 now = timer_->getMilliseconds(); 512 calculateEventTime(now, eventTimes[2]); 513 514 ogreRoot._updateAllRenderTargets(); // only render in non-server mode 515 516 // get current time 517 now = timer_->getMilliseconds(); 503 518 504 519 // create an event to pass to the frameEnded method in ogre 505 520 evt.timeSinceLastEvent = calculateEventTime(now, eventTimes[0]); 506 evt.timeSinceLastFrame= calculateEventTime(now, eventTimes[2]);521 renderTime += calculateEventTime(now, eventTimes[2]); 507 522 508 523 // again, just to be sure ogre works fine -
code/branches/network/src/orxonox/hud/HUD.cc
r1414 r1422 75 75 fpsText->setCaption("init"); 76 76 77 // creating text to display render time ratio 78 rTRText = static_cast<TextAreaOverlayElement*>(om->createOverlayElement("TextArea", "rTRText")); 79 rTRText->show(); 80 rTRText->setMetricsMode(Ogre::GMM_PIXELS); 81 rTRText->setDimensions(0.001, 0.001); 82 rTRText->setPosition(10, 30); 83 rTRText->setFontName("Console"); 84 rTRText->setCharHeight(20); 85 rTRText->setCaption("init"); 86 77 87 // create energy bar 78 88 energyBar = static_cast<BarOverlayElement*>(om->createOverlayElement("Bar", "energyBar")); … … 99 109 container->setMetricsMode(Ogre::GMM_RELATIVE); 100 110 container->addChild(fpsText); 111 container->addChild(rTRText); 101 112 102 113 energyBar->init(0.01, 0.94, 0.4, container); … … 133 144 float fps = GraphicsEngine::getSingleton().getAverageFPS(); 134 145 fpsText->setCaption("FPS: " + Ogre::StringConverter::toString(fps)); 146 } 147 148 void HUD::setRenderTimeRatio(float ratio) 149 { 150 rTRText->setCaption("Render time ratio: " + Ogre::StringConverter::toString(ratio)); 135 151 } 136 152 -
code/branches/network/src/orxonox/hud/HUD.h
r1414 r1422 49 49 Ogre::OverlayContainer* container; 50 50 Ogre::TextAreaOverlayElement* fpsText; 51 Ogre::TextAreaOverlayElement* rTRText; 51 52 BarOverlayElement* energyBar; 52 53 BarOverlayElement* speedoBar; … … 60 61 void addRadarObject(Vector3 pos); 61 62 RadarObject* getFirstRadarObject(); 63 void setRenderTimeRatio(float ratio); 62 64 63 65 static HUD* instance_s;
Note: See TracChangeset
for help on using the changeset viewer.