Changeset 1204 for GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE
- Timestamp:
- 08/15/06 22:47:29 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTree.h
r1202 r1204 27 27 public: 28 28 29 KdTreeApp() 30 { 31 mFrameListener = 0; 32 mRenderTargerListener = 0; 29 KdTreeApp() : 30 mFrameListener(0), 31 mRenderTargerListener(0) 32 { 33 33 34 } 34 35 35 KdTreeApp(const String& infile, const String& outfile) 36 { 37 mFrameListener = 0; 38 mRenderTargerListener = 0; 39 mDemoInfileName = infile; 40 mDemoOutfileName = outfile; 36 KdTreeApp(const KdTreeAppListener::Options& options) : 37 mFrameListener(0), 38 mRenderTargerListener(0), 39 mOptions(options) 40 { 41 41 } 42 42 … … 48 48 49 49 protected: 50 SceneNode *mCamNode;51 SceneNode *mDeathNode;52 Camera *mTopCam;53 Camera *mFollowCam;54 50 KdTreeAppListener *mFrameListener; 55 51 KdTreeAppRenderTargetListener *mRenderTargerListener; 52 SceneNode *mCamNode; 53 SceneNode *mMoveNode; 54 Camera *mTopCam; 55 //Camera *mFollowCam; 56 56 57 // scene options 57 58 String mSceneFiles; 58 59 String mSelectedSceneManager; 59 Real mMoveSpeed;60 Real mRotateSpeed;61 60 Real mRotationRadius; 62 Real mRotationPeriod;63 61 int mModelSpacing; 64 62 int mModelCount; … … 68 66 int mSelectEntities; 69 67 70 String mDemoInfileName;71 String mDemoOutfileName; 68 KdTreeAppListener::Options mOptions; 69 72 70 73 71 virtual void setupResources(void); -
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTreeAppListener.h
r1202 r1204 61 61 class KdTreeAppListener: public FrameListener, public KeyListener 62 62 { 63 64 public: 65 // visualization modes for scene nodes 66 enum VizMode 67 { 68 NODEVIZ_NONE, 69 NODEVIZ_RENDER_NODES, 70 NODEVIZ_RENDER_NODES_AND_CONTENT, 71 NODEVIZ_MODES_NUM 72 }; 73 74 enum AppState 75 { 76 AS_NORMAL, 77 AS_RECORD, 78 AS_PLAYBACK 79 }; 80 81 struct Options 82 { 83 Options(): 84 mDemoMode(false), 85 mRotateSpeed(36.0f), 86 mMoveSpeed(100.0f), 87 mRotationPeriod(30.0f), 88 mMaxDepth(12), 89 mKT(2.0f), 90 mKI(1.0f), 91 mRenderMethod("CHC") 92 { 93 94 } 95 96 String mDemoInfileName; 97 String mDemoOutfileName; 98 String mDemoLogfileName; 99 bool mDemoMode; 100 Degree mRotateSpeed; 101 Real mMoveSpeed; 102 Real mRotationPeriod; 103 int mMaxDepth; 104 Real mKT; 105 Real mKI; 106 String mRenderMethod; 107 }; 108 109 // Constructor takes a RenderWindow because it uses that to determine input context 110 KdTreeAppListener(RenderWindow* win, SceneManager* sm, const Options& options, 111 bool useBufferedInputKeys = false, bool useBufferedInputMouse = false); 112 113 virtual ~KdTreeAppListener(); 114 115 void initOverlayElement(OverlayElement **elInfo, String ext, 116 String name, int top, String caption); 117 118 void initStatsOverlay(); 119 120 void initKdTreeOverlay(); 121 122 void showDebugOverlay(bool show); 123 124 void toggleVizCamera(); 125 126 virtual bool processUnbufferedKeyInput(const FrameEvent& evt); 127 128 bool processUnbufferedMouseInput(const FrameEvent& evt); 129 130 void moveCamera(); 131 132 // Override frameStarted event to process that (don't care about frameEnded) 133 bool frameStarted(const FrameEvent& evt); 134 135 bool frameEnded(const FrameEvent& evt); 136 137 void switchMouseMode(); 138 139 void switchKeyMode(); 140 141 void keyClicked(KeyEvent* e); 142 143 void keyPressed(KeyEvent* e) {}; 144 void keyReleased(KeyEvent* e) {}; 145 146 63 147 protected: 64 int mSceneDetailIndex ; 65 Real mMoveSpeed; 66 Degree mRotateSpeed; 67 Real mRotationPeriod; 148 // basic 149 RenderWindow* mWindow; 150 SceneManager *mSceneMgr; 151 Options mOptions; 152 bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 153 154 // elements 155 SceneNode *mCamNode; 156 Camera* mCamera; 157 Camera* mTopCam; 158 159 // toggle 160 bool mStatsOn; 161 162 bool mVizCamera; 68 163 bool mShowTree; 69 164 bool mFreeMove; 70 165 bool mTopCamFollow; 71 166 167 // counters 168 int mSeqNum; 169 unsigned int mNumScreenShots; 170 171 // rendering/texture options 172 int mSceneDetailIndex; 173 TextureFilterOptions mFiltering; 174 int mAniso; 175 176 // chc stats 72 177 Real mDelayedQueriesIssued; 73 178 Real mDelayedTraversedNodes; 74 179 75 int mSeqNum; 76 77 Overlay* mDebugOverlay; 78 Overlay* mKdTreeOverlay; 180 // overlays 181 Overlay *mDemoOverlay; 182 Overlay *mDebugOverlay; 183 Overlay *mKdTreeOverlay; 184 185 OverlayElement *mDemoStatus; 79 186 80 187 OverlayElement *mKdTreeMaxDepthInfo; … … 95 202 OverlayElement *mQueriesIssuedInfo; 96 203 204 // input 97 205 EventProcessor* mEventProcessor; 98 206 InputReader* mInputDevice; 99 SceneNode *mCamNode; 100 Camera* mCamera; 101 Camera* mTopCam; 102 SceneManager *mSceneMgr; 103 Radian mDeathAngle; 104 207 208 // movement 105 209 Vector3 mTranslateVector; 106 RenderWindow* mWindow; 107 bool mStatsOn; 108 bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 109 unsigned int mNumScreenShots; 210 Vector3 mVizCamTransVect; 211 Radian mRotX, mRotY; 110 212 float mMoveScale; 111 213 Degree mRotScale; 214 Radian mDeathAngle; 215 112 216 // just to stop toggles flipping too fast 113 217 Real mTimeUntilNextToggle ; 114 Radian mRotX, mRotY;115 TextureFilterOptions mFiltering;116 int mAniso;117 118 // stuff for the viz camera119 bool mVizCamera;120 Vector3 mVizCamTransVect;121 122 void updateStats(void);123 218 124 219 // stuff for walkthrough recording/playback 125 String mDemoInfileName; 126 String mDemoOutfileName; 127 128 enum AppState 129 { 130 AS_NORMAL, 131 AS_RECORD, 132 AS_PLAYBACK 133 }; 134 220 //std::ofstream mDemoFramesLog; 221 std::list<Real> mDemoFPS; 222 Real mTimeUntilNextLogWrite; 135 223 FrameList mFrameList; 136 224 FrameList::iterator mCurrFrame; 137 225 Real mTimeRemaining; 226 Real mWaitBeforeDemoStart; 138 227 139 228 AppState mAppState; 140 141 Overlay * mDemoOverlay;142 OverlayElement * mDemoStatus;143 229 144 230 void setDemoOverlay(); … … 148 234 149 235 void saveFrameInfo(Real elapsedTime); 150 236 151 237 /** save demo frame data to file **/ 152 238 static void saveFrames(const String& filename, FrameList& framelist); … … 159 245 static void loadFramesBinary(const String& filename, FrameList& framelist); 160 246 161 public: 162 // visualization modes for scene nodes 163 enum 164 { 165 NODEVIZ_NONE, 166 NODEVIZ_RENDER_NODES, 167 NODEVIZ_RENDER_NODES_AND_CONTENT, 168 NODEVIZ_MODES_NUM 169 }; 170 171 // Constructor takes a RenderWindow because it uses that to determine input context 172 KdTreeAppListener(RenderWindow* win, SceneManager* sm, Real rs, Real ms, Real rp, 173 const String& infile, const String& outfile, 174 bool useBufferedInputKeys = false, bool useBufferedInputMouse = false); 175 176 virtual ~KdTreeAppListener(); 177 178 void initOverlayElement(OverlayElement **elInfo, String ext, 179 String name, int top, String caption); 180 181 void initStatsOverlay(); 182 183 void initKdTreeOverlay(); 184 185 void showDebugOverlay(bool show); 186 187 void toggleVizCamera(); 188 189 virtual bool processUnbufferedKeyInput(const FrameEvent& evt); 190 191 bool processUnbufferedMouseInput(const FrameEvent& evt); 192 193 void moveCamera(); 194 195 // Override frameStarted event to process that (don't care about frameEnded) 196 bool frameStarted(const FrameEvent& evt); 197 198 bool frameEnded(const FrameEvent& evt); 199 200 void switchMouseMode(); 201 202 void switchKeyMode(); 203 204 void keyClicked(KeyEvent* e); 205 206 void keyPressed(KeyEvent* e) {}; 207 void keyReleased(KeyEvent* e) {}; 247 void updateStats(void); 208 248 }; 209 249 -
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTree.cpp
r1203 r1204 5 5 6 6 #include "TestKdTree.h" 7 //#include "WinCmdLineParser.h"7 #include "WinCmdLineParser.h" 8 8 9 9 #ifdef __cplusplus 10 10 extern "C" { 11 11 #endif 12 13 void splitStrCmdLine(const char *strCmdLine, std::vector<std::string>& argv);14 bool getopt(const std::string& option, const std::vector<std::string>& argv, const std::string& optstring, std::string& optarg);15 12 16 13 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 … … 22 19 #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 23 20 // parse windows-style command line 24 std::string optarg = "i:o:", infile, outfile; 25 std::vector<std::string> argv; 26 27 splitStrCmdLine(strCmdLine, argv); 28 29 getopt("i", argv, optarg, infile); 30 getopt("o", argv, optarg, outfile); 31 32 //WinCmdLineParser cmdparser(strCmdLine); 33 34 //cmdparser 35 // .addOpt("o","",ARGUMENT_REQUIRED) 36 // .addOpt("i","",ARGUMENT_REQUIRED); 37 38 //cmdparser.getOpt("o", outfile); 39 //cmdparser.getOpt("i", infile); 21 22 WinCmdLineParser cmdparser(strCmdLine); 23 KdTreeAppListener::Options options; 24 25 try 26 { 27 cmdparser 28 .addOpt("i","infile", ARGUMENT_REQUIRED) 29 .addOpt("o","outfile", ARGUMENT_REQUIRED) 30 .addOpt("l","logfile", ARGUMENT_REQUIRED) 31 .addOpt("d","demomode", ARGUMENT_NONE) 32 .addOpt("","maxdepth", ARGUMENT_REQUIRED) 33 .addOpt("","kt", ARGUMENT_REQUIRED) 34 .addOpt("","ki", ARGUMENT_REQUIRED) 35 .addOpt("r","rendermethod", ARGUMENT_REQUIRED); 36 37 38 cmdparser.getOpt("i", options.mDemoInfileName); 39 cmdparser.getOpt("o", options.mDemoOutfileName); 40 cmdparser.getOpt("l", options.mDemoLogfileName); 41 options.mDemoMode = cmdparser.getOpt("d"); 42 43 std::string tmp; 44 std::stringstream s; 45 46 if (cmdparser.getOpt("maxdepth", tmp)) 47 { 48 s << tmp; 49 s >> options.mMaxDepth; 50 s.clear(); 51 } 52 53 if (cmdparser.getOpt("kt", tmp)) 54 { 55 s << tmp; 56 s >> options.mKT; 57 s.clear(); 58 } 59 60 if (cmdparser.getOpt("ki", tmp)) 61 { 62 s << tmp; 63 s >> options.mKI; 64 s.clear(); 65 } 66 67 if (cmdparser.getOpt("r",tmp)) 68 { 69 if (tmp == "INT" || tmp == "VFC" || tmp == "SWC" || tmp == "CHC") 70 { 71 options.mRenderMethod = tmp; 72 } 73 else 74 { 75 MessageBox(NULL, ("Invalid argument for option --rendermethod: " + tmp).c_str(), "Error", MB_OK | MB_ICONERROR ); 76 return -1; 77 } 78 } 79 80 } 81 catch (std::string s) 82 { 83 MessageBox(NULL, s.c_str(), "Error", MB_OK | MB_ICONERROR ); 84 return -1; 85 } 40 86 41 87 // Create application object 42 KdTreeApp app( infile, outfile);88 KdTreeApp app(options); 43 89 #else 44 90 // TODO: unix-style getopt … … 70 116 #endif 71 117 72 // split a space-separated string argument in an array of strings73 // sensitive to "74 void splitStrCmdLine(const char *strCmdLine, std::vector<std::string>& argv)75 {76 std::string cmdline(strCmdLine);77 argv.clear();78 79 std::string tmp;80 unsigned int strpos = 0;81 bool skipspace = false;82 83 while (strpos < cmdline.length())84 {85 while (strpos < cmdline.length() && cmdline[strpos] == ' ')86 strpos++;87 tmp.clear();88 while (strpos < cmdline.length() && (cmdline[strpos] != ' ' || skipspace))89 {90 if (cmdline[strpos] == '"')91 {92 ++ strpos;93 skipspace = !skipspace;94 if (!skipspace)95 continue;96 }97 98 tmp += cmdline[strpos ++];99 }100 argv.push_back(tmp);101 }102 103 //std::ofstream testout("test.txt");104 105 //testout << cmdline << "\n\n";106 107 //std::vector<std::string>::iterator it = argv.begin();108 //while (it != argv.end())109 //{110 // testout << *it << "\n";111 // ++ it;112 //}113 114 //testout.close();115 }116 117 // simplified std::-based getopt (no long options)118 // does not provide options consecutively like POSIX getopt, it rather gives you the value of the option you ask for119 // or returns false if option not present or anything else went wrong120 bool getopt(const std::string& option, const std::vector<std::string>& argv, const std::string& optstring, std::string& optarg)121 {122 static enum argtypes123 {124 no_argument,125 required_argument,126 optional_argument127 };128 129 // early terminate130 if (option.empty() || argv.empty() || optstring.empty())131 return false;132 133 // verify presence of option134 size_t iopt = optstring.find(option);135 if (iopt == std::string::npos)136 return false;137 138 // check if mandatory or optional argument139 int arg = no_argument;140 if (++ iopt < optstring.size() && optstring[iopt] == ':')141 arg = required_argument;142 if (++ iopt < optstring.size() && optstring[iopt] == ':')143 arg = optional_argument;144 145 146 // find the arguments value147 size_t item = 0;148 std::string optstr = "-" + option;149 150 while (item < argv.size())151 {152 if (argv[item] == optstr)153 {154 switch (arg)155 {156 case no_argument:157 optarg.clear();158 return true;159 break;160 case required_argument:161 if (++ item < argv.size() && argv[item][0] != '-')162 {163 optarg = argv[item];164 return true;165 }166 else167 {168 optarg.clear();169 return false;170 }171 break;172 case optional_argument:173 if (++ item < argv.size() && argv[item][0] != '-')174 {175 optarg = argv[item];176 return true;177 }178 else179 {180 optarg.clear();181 return true;182 }183 break;184 default:185 return false;186 }187 }188 ++ item;189 }190 191 return false;192 }193 194 118 #define ENT_GRID 0x01 195 119 #define ENT_RND 0x02 … … 237 161 238 162 tmp = cfDeath.getSetting("period"); 239 m RotationPeriod = static_cast<Real>(strtod(tmp.c_str(), &errptr));163 mOptions.mRotationPeriod = static_cast<Real>(strtod(tmp.c_str(), &errptr)); 240 164 241 165 tmp = cfDeath.getSetting("movespeed"); 242 m MoveSpeed = static_cast<Real>(strtod(tmp.c_str(), &errptr));166 mOptions.mMoveSpeed = static_cast<Real>(strtod(tmp.c_str(), &errptr)); 243 167 244 168 tmp = cfDeath.getSetting("rotatespeed"); 245 m RotateSpeed = static_cast<Real>(strtod(tmp.c_str(), &errptr));169 mOptions.mRotateSpeed = static_cast<Real>(strtod(tmp.c_str(), &errptr)); 246 170 247 171 // command line has preference over config file 248 if (mDemoInfileName.empty()) 249 mDemoInfileName = cfDeath.getSetting("demoinfile"); 250 251 if (mDemoOutfileName.empty()) 252 mDemoOutfileName = cfDeath.getSetting("demooutfile"); 172 if (mOptions.mDemoInfileName.empty()) 173 mOptions.mDemoInfileName = cfDeath.getSetting("demoinfile"); 174 175 if (mOptions.mDemoOutfileName.empty()) 176 mOptions.mDemoOutfileName = cfDeath.getSetting("demooutfile"); 177 178 // set default demo output name to avoid SNAFUs 179 if (mOptions.mDemoOutfileName.empty()) 180 mOptions.mDemoOutfileName = "demo.bin"; 181 182 if (mOptions.mDemoLogfileName.empty()) 183 mOptions.mDemoLogfileName = cfDeath.getSetting("demologfile"); 184 185 // set default demo logfile name to avoid SNAFUs 186 if (mOptions.mDemoLogfileName.empty()) 187 mOptions.mDemoLogfileName = "demo.csv"; 253 188 254 189 ExampleApplication::setupResources(); … … 357 292 358 293 SceneNode *deathPivotNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("deathPivotNode"); 359 m DeathNode = deathPivotNode->createChildSceneNode("movingNode", Vector3(0, 0, mRotationRadius)/*,294 mMoveNode = deathPivotNode->createChildSceneNode("movingNode", Vector3(0, 0, mRotationRadius)/*, 360 295 Quaternion(Radian(Math::HALF_PI), Vector3::UNIT_Y)*/); 361 m DeathNode->attachObject(movingDeath);296 mMoveNode->attachObject(movingDeath); 362 297 363 298 Entity *ent_ball = mSceneMgr->createEntity("ball","sphere.mesh"); 364 SceneNode *node_pivot = m DeathNode->createChildSceneNode("pivotNode");299 SceneNode *node_pivot = mMoveNode->createChildSceneNode("pivotNode"); 365 300 SceneNode *node_ball = node_pivot->createChildSceneNode("orbitNode", Vector3(120, 40, 0)); 366 301 node_ball->attachObject(ent_ball); … … 368 303 369 304 370 mFollowCam->setAutoTracking(true, mDeathNode);305 //mFollowCam->setAutoTracking(true, mMoveNode); 371 306 } 372 307 … … 432 367 void KdTreeApp::createFrameListener(void) 433 368 { 434 mFrameListener = new KdTreeAppListener(mWindow, mSceneMgr, m RotateSpeed, mMoveSpeed, mRotationPeriod, mDemoInfileName, mDemoOutfileName);435 mFrameListener->showDebugOverlay( true );369 mFrameListener = new KdTreeAppListener(mWindow, mSceneMgr, mOptions); 370 //mFrameListener->showDebugOverlay( true ); 436 371 mRoot->addFrameListener(mFrameListener); 437 372 mRenderTargerListener = new KdTreeAppRenderTargetListener(mSceneMgr); … … 443 378 // Get the SceneManager 444 379 mSceneMgr = mRoot->createSceneManager(mSelectedSceneManager,"MySceneManager"); 380 // set params 381 mSceneMgr->setOption("KdTreeMaxDepth", &mOptions.mMaxDepth); 382 mSceneMgr->setOption("KT", &mOptions.mKT); 383 mSceneMgr->setOption("KI", &mOptions.mKI); 384 mSceneMgr->setOption("RenderMethod", &mOptions.mRenderMethod); 445 385 } 446 386 -
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTreeAppListener.cpp
r1202 r1204 70 70 71 71 // Constructor takes a RenderWindow because it uses that to determine input context 72 KdTreeAppListener::KdTreeAppListener(RenderWindow* win, SceneManager* sm, Real rs, Real ms, Real rp, 73 const String& infile, const String& outfile, 74 bool useBufferedInputKeys, bool useBufferedInputMouse) 75 { 76 mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay"); 77 mKdTreeOverlay = OverlayManager::getSingleton().getByName("KdTree/DebugOverlay"); 78 79 80 mUseBufferedInputKeys = useBufferedInputKeys; 81 mUseBufferedInputMouse = useBufferedInputMouse; 72 KdTreeAppListener::KdTreeAppListener(RenderWindow* win, SceneManager* sm, const Options& options, 73 bool useBufferedInputKeys, bool useBufferedInputMouse): 74 // basic 75 mWindow(win), 76 mSceneMgr(sm), 77 mOptions(options), 78 mUseBufferedInputKeys(useBufferedInputKeys), 79 mUseBufferedInputMouse(useBufferedInputMouse), 80 // elements 81 mCamNode(0), 82 mCamera(0), 83 mTopCam(0), 84 // toggle 85 mStatsOn(true), 86 mVizCamera(false), 87 mShowTree(false), 88 mFreeMove(false), 89 mTopCamFollow(true), 90 //counters 91 mSeqNum(0), 92 mNumScreenShots(0), 93 // rendering/texture options 94 mSceneDetailIndex(PM_SOLID), 95 mFiltering(TFO_ANISOTROPIC), 96 mAniso(8), 97 // chc stats 98 mDelayedQueriesIssued(0.0f), 99 mDelayedTraversedNodes(0.0f), 100 // movement 101 mTranslateVector(Vector3::ZERO), 102 mVizCamTransVect(Vector3::ZERO), 103 mRotX(0.0f), 104 mRotY(0.0f), 105 mMoveScale(0.0f), 106 mRotScale(0.0f), 107 mDeathAngle(0.0f), 108 // just to stop toggles flipping too fast 109 mTimeUntilNextToggle(0.0f), 110 // stuff for walkthrough recording/playback 111 mTimeUntilNextLogWrite(0.0f), 112 mTimeRemaining(0.0f), 113 mWaitBeforeDemoStart(0.0f), 114 mAppState(AS_NORMAL) 115 { 82 116 mInputTypeSwitchingOn = mUseBufferedInputKeys || mUseBufferedInputMouse; 83 117 … … 97 131 } 98 132 99 mTopCamFollow = true; 100 mFreeMove = false; 101 mShowTree = false; 102 mVizCamera = false; 103 mVizCamTransVect = Vector3::ZERO; 104 mSeqNum = 0; 105 106 mDemoInfileName = infile; 107 mDemoOutfileName = outfile; 108 109 mAppState = AS_NORMAL; 110 111 mDelayedQueriesIssued = 0.0; 112 mDelayedTraversedNodes = 0.0; 133 MaterialManager::getSingleton().setDefaultTextureFiltering(mFiltering); 134 MaterialManager::getSingleton().setDefaultAnisotropy(mAniso); 113 135 114 136 mCamera = sm->getCamera("PlayerCam"); 115 137 mTopCam = sm->getCamera("TopCam"); 116 138 mCamNode = sm->getSceneNode("PlayerCamNode"); 117 mSceneMgr = sm; 118 mWindow = win; 119 mRotateSpeed = rs; 120 mMoveSpeed = ms; 121 mRotationPeriod = rp; 122 mDeathAngle = 0; 123 mStatsOn = true; 124 mNumScreenShots = 0; 125 mTimeUntilNextToggle = 0; 126 mSceneDetailIndex = 0; 127 mMoveScale = 0.0f; 128 mRotScale = 0.0f; 129 mTranslateVector = Vector3::ZERO; 130 mAniso = 8; 131 mFiltering = TFO_ANISOTROPIC; 132 133 MaterialManager::getSingleton().setDefaultTextureFiltering(mFiltering); 134 MaterialManager::getSingleton().setDefaultAnisotropy(mAniso); 135 139 140 mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay"); 141 mKdTreeOverlay = OverlayManager::getSingleton().getByName("KdTree/DebugOverlay"); 136 142 mDemoOverlay = 0; 137 143 mDemoStatus = 0; … … 140 146 initStatsOverlay(); 141 147 142 showDebugOverlay(true); 143 148 if (!mOptions.mDemoInfileName.empty()) 149 loadFrames(mOptions.mDemoInfileName, mFrameList); 150 151 if (!mOptions.mDemoInfileName.empty() && mOptions.mDemoMode) 152 { 153 // force 3 second wait when in demo mode - avoids initial low framerate due to loading delays 154 mWaitBeforeDemoStart = 3.0; 155 // set playback icon 156 togglePlayback(); 157 // hide all other overlays 158 mStatsOn = false; 159 } 160 161 showDebugOverlay(mStatsOn); 144 162 setDemoOverlay(); 145 146 if (!mDemoInfileName.empty())147 loadFrames(mDemoInfileName, mFrameList);148 163 } 149 164 //----------------------------------------------------------------------- … … 286 301 void KdTreeAppListener::showDebugOverlay(bool show) 287 302 { 288 if (mDebugOverlay )303 if (mDebugOverlay && mKdTreeOverlay) 289 304 { 290 305 if (show) … … 339 354 bool KdTreeAppListener::processUnbufferedKeyInput(const FrameEvent& evt) 340 355 { 356 // ignore all keystrokes except escape when in demo mode 357 if (mOptions.mDemoMode) 358 { 359 if (mInputDevice->isKeyDown(KC_ESCAPE)) 360 return false; 361 else 362 return true; 363 } 364 341 365 // demo recording stuff 342 366 if (mInputDevice->isKeyDown(KC_F5) && mTimeUntilNextToggle <= 0) … … 348 372 if (mInputDevice->isKeyDown(KC_F6) && mTimeUntilNextToggle <= 0) 349 373 { 350 if (!m DemoOutfileName.empty() && !mFrameList.empty())351 saveFrames(m DemoOutfileName, mFrameList);374 if (!mOptions.mDemoOutfileName.empty() && !mFrameList.empty()) 375 saveFrames(mOptions.mDemoOutfileName, mFrameList); 352 376 mTimeUntilNextToggle = 0.5; 353 377 } … … 615 639 } 616 640 617 if (mInputDevice->isKeyDown(KC_O) && mTimeUntilNextToggle <= 0)618 {619 LogManager::getSingleton().logMessage("############## Camera Position:");620 LogManager::getSingleton().logMessage("############## " + StringConverter::toString(mCamera->getPosition()));621 LogManager::getSingleton().logMessage("############## " + StringConverter::toString(mCamera->getOrientation()));622 LogManager::getSingleton().logMessage("############## Cull Camera Position:");623 LogManager::getSingleton().logMessage("############## " + StringConverter::toString(mTopCam->getPosition()));624 LogManager::getSingleton().logMessage("############## " + StringConverter::toString(mTopCam->getOrientation()));625 mTimeUntilNextToggle = 1.0;626 }641 //if (mInputDevice->isKeyDown(KC_P) && mTimeUntilNextToggle <= 0) 642 //{ 643 // LogManager::getSingleton().logMessage("############## Camera Position:"); 644 // LogManager::getSingleton().logMessage("############## " + StringConverter::toString(mCamera->getPosition())); 645 // LogManager::getSingleton().logMessage("############## " + StringConverter::toString(mCamera->getOrientation())); 646 // LogManager::getSingleton().logMessage("############## Cull Camera Position:"); 647 // LogManager::getSingleton().logMessage("############## " + StringConverter::toString(mTopCam->getPosition())); 648 // LogManager::getSingleton().logMessage("############## " + StringConverter::toString(mTopCam->getOrientation())); 649 // mTimeUntilNextToggle = 1.0; 650 //} 627 651 628 652 if (mInputDevice->isKeyDown(KC_B) && mTimeUntilNextToggle <= 0) … … 687 711 } 688 712 689 if (mInputDevice->isKeyDown(KC_ P))713 if (mInputDevice->isKeyDown(KC_O)) 690 714 { 691 715 mWindow->writeContentsToTimestampedFile("Screenshot",".jpg"); … … 921 945 { 922 946 // Move about 100 units per second, 923 mMoveScale = m MoveSpeed * evt.timeSinceLastFrame;947 mMoveScale = mOptions.mMoveSpeed * evt.timeSinceLastFrame; 924 948 // Take about 10 seconds for full rotation 925 mRotScale = m RotateSpeed * evt.timeSinceLastFrame;949 mRotScale = mOptions.mRotateSpeed * evt.timeSinceLastFrame; 926 950 } 927 951 mRotX = 0; … … 955 979 } 956 980 } 981 982 // do nothing until delay passes to stabilize frame rate 983 mWaitBeforeDemoStart -= evt.timeSinceLastFrame; 984 if (mWaitBeforeDemoStart > 0.0) 985 return true; 957 986 958 987 // demo playback - replace position with stored one … … 961 990 // update time 962 991 mTimeRemaining -= evt.timeSinceLastFrame; 992 993 // store fps when in demo mode 994 if (mOptions.mDemoMode) 995 { 996 // save FPS 997 mTimeUntilNextLogWrite -= evt.timeSinceLastFrame; 998 if (mTimeUntilNextLogWrite <= 0.0) 999 { 1000 const RenderTarget::FrameStats& stats = mWindow->getStatistics(); 1001 mTimeUntilNextLogWrite += 1.0; 1002 mDemoFPS.push_back(stats.lastFPS); 1003 } 1004 } 963 1005 964 1006 static FrameList::iterator lastFrame; … … 978 1020 { 979 1021 togglePlayback(); 1022 // exit app when in demo mode 1023 if (mOptions.mDemoMode) 1024 { 1025 // write FPS log 1026 Real minFPS = Math::POS_INFINITY, maxFPS = 0.0, avgFPS = 0.0; 1027 std::ofstream demolog(mOptions.mDemoLogfileName.c_str()); 1028 if (demolog) 1029 { 1030 for (std::list<Real>::iterator it = mDemoFPS.begin(); it != mDemoFPS.end(); it ++) 1031 { 1032 demolog << (int)*it << "\n"; 1033 1034 if (*it < minFPS) 1035 minFPS = *it; 1036 1037 if (*it > maxFPS) 1038 maxFPS = *it; 1039 1040 avgFPS += *it; 1041 } 1042 1043 avgFPS /= mDemoFPS.size(); 1044 1045 demolog << "\n" << (int)minFPS << "\n" << (int)avgFPS << "\n" << (int)maxFPS << "\n"; 1046 1047 demolog.close(); 1048 } 1049 return false; 1050 } 980 1051 } 981 1052 // interpolate position & orientation and modify move vectors … … 1060 1131 bool KdTreeAppListener::frameEnded(const FrameEvent& evt) 1061 1132 { 1062 updateStats(); 1133 if (!mOptions.mDemoMode) 1134 updateStats(); 1135 1063 1136 return true; 1064 1137 }
Note: See TracChangeset
for help on using the changeset viewer.