Changeset 1220 for GTP/trunk/App/Demos/Vis
- Timestamp:
- 08/18/06 17:25:57 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTree.h
r1204 r1220 57 57 // scene options 58 58 String mSceneFiles; 59 String mSelectedSceneManager;60 59 Real mRotationRadius; 61 60 int mModelSpacing; … … 67 66 68 67 KdTreeAppListener::Options mOptions; 69 70 68 71 69 virtual void setupResources(void); -
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTreeAppListener.h
r1215 r1220 36 36 #define __KdTreeAppListener_H__ 37 37 38 #include "Ogre.h" 39 #include "OgreKeyEvent.h" 40 #include "OgreEventListeners.h" 41 #include "OgreStringConverter.h" 42 #include "OgreException.h" 43 38 #include <Ogre.h> 39 #include <OgreKeyEvent.h> 40 #include <OgreEventListeners.h> 41 #include <OgreStringConverter.h> 42 #include <OgreException.h> 43 44 #include <OgreKdTree.h> 45 46 #define CONV_OCM_TO_KDT_ALG(i) (i == 0 ? 3 : i) 47 #define CONV_KDT_TO_OCM_ALG(i) (i % 3) 44 48 #define VIZ_VIEWPORT_Z_ORDER 10 45 49 … … 72 76 }; 73 77 78 enum SceneMgr 79 { 80 SM_KDT, 81 SM_OCM, 82 SM_OCT, 83 SM_GEN, 84 SM_SIZE, 85 SM_NOTSET 86 }; 87 74 88 enum ShowTree 75 89 { … … 90 104 { 91 105 Options(): 92 mDemoMode(false),93 mEnhancedVisibility(false),94 106 mRotateSpeed(36.0f), 95 107 mMoveSpeed(100.0f), 96 108 mRotationPeriod(30.0f), 97 mMaxDepth(12),98 109 mKT(2.0f), 99 110 mKI(1.0f), 100 mRenderMethod("CHC") 111 mMaxDepth(12), 112 mSceneManager(SM_KDT), 113 mRenderMethod(KdTree::KDRM_GTP_CHC), 114 mBuildMethod(KdTree::KDBM_PRIORITYQUEUE), 115 mDemoMode(false), 116 mEnhancedVisibility(false) 101 117 { 102 118 103 119 } 104 120 105 String mSceneManager;106 121 String mDemoInfileName; 107 122 String mDemoOutfileName; 108 123 String mDemoLogfileName; 109 bool mDemoMode; 110 bool mEnhancedVisibility; 124 String mComment; 111 125 Degree mRotateSpeed; 112 126 Real mMoveSpeed; 113 127 Real mRotationPeriod; 114 int mMaxDepth;115 128 Real mKT; 116 129 Real mKI; 117 String mRenderMethod; 118 String mComment; 130 int mMaxDepth; 131 int mSceneManager; 132 int mRenderMethod; 133 int mBuildMethod; 134 bool mDemoMode; 135 bool mEnhancedVisibility; 119 136 }; 120 137 … … 164 181 void keyReleased(KeyEvent* e) {}; 165 182 183 const static Real DEMO_WAIT; 166 184 const static String NA; 167 const static Real DEMO_WAIT; 185 const static String RENDERMETHOD[]; 186 const static String RENDERMETHODCAPTION[]; 187 const static String BUILDMETHOD[]; 188 const static String BUILDMETHODCAPTION[]; 189 const static String SCENEMANAGER[]; 190 const static String SCENEMANAGERNAME[]; 168 191 protected: 169 192 // basic -
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/scripts/TestKdTree.vcproj
r1203 r1220 21 21 Optimization="0" 22 22 ImproveFloatingPointConsistency="TRUE" 23 AdditionalIncludeDirectories="..\include;"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\OgreMain\include";..\..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include "23 AdditionalIncludeDirectories="..\include;"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\OgreMain\include";..\..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include;..\..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\include;..\..\..\..\..\..\Lib\Vis\OnlineCullingCHC\include" 24 24 PreprocessorDefinitions="WIN32;_DEBUG;_WINDOWS;GTP_VISIBILITY_MODIFIED_OGRE" 25 25 MinimalRebuild="TRUE" … … 84 84 OptimizeForProcessor="2" 85 85 OptimizeForWindowsApplication="TRUE" 86 AdditionalIncludeDirectories="..\include;"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\OgreMain\include";..\..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include "86 AdditionalIncludeDirectories="..\include;"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\OgreMain\include";..\..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include;..\..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\include;..\..\..\..\..\..\Lib\Vis\OnlineCullingCHC\include" 87 87 PreprocessorDefinitions="WIN32;NDEBUG;_WINDOWS;GTP_VISIBILITY_MODIFIED_OGRE" 88 88 StringPooling="TRUE" -
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTree.cpp
r1215 r1220 30 30 .addOpt("l","logfile", ARGUMENT_REQUIRED) 31 31 .addOpt("d","demomode", ARGUMENT_NONE) 32 .addOpt("","buildmode", ARGUMENT_REQUIRED) 32 33 .addOpt("","maxdepth", ARGUMENT_REQUIRED) 33 34 .addOpt("","kt", ARGUMENT_REQUIRED) … … 49 50 std::stringstream s; 50 51 52 if (cmdparser.getOpt("buildmode", tmp)) 53 { 54 int bm = KdTree::KDBM_NOTSET; 55 for (int i = 0; i < KdTree::KDBM_SIZE; i ++) 56 { 57 if (tmp == KdTreeAppListener::BUILDMETHOD[i]) 58 bm = i; 59 } 60 if (bm != KdTree::KDBM_NOTSET) 61 { 62 options.mBuildMethod = bm; 63 } 64 else 65 { 66 MessageBox(NULL, ("Invalid argument for option --buildmode: " + tmp).c_str(), "Error", MB_OK | MB_ICONERROR ); 67 return -1; 68 } 69 } 70 51 71 if (cmdparser.getOpt("maxdepth", tmp)) 52 72 { … … 72 92 if (cmdparser.getOpt("r",tmp)) 73 93 { 74 if (tmp == "INT" || tmp == "VFC" || tmp == "SWC" || tmp == "CHC") 75 { 76 options.mRenderMethod = tmp; 94 int rm = KdTree::KDRM_NOTSET; 95 for (int i = 0; i < KdTree::KDRM_SIZE; i ++) 96 { 97 if (tmp == KdTreeAppListener::RENDERMETHOD[i]) 98 rm = i; 99 } 100 if (rm != KdTree::KDRM_NOTSET) 101 { 102 options.mRenderMethod = rm; 77 103 } 78 104 else 79 105 { 80 MessageBox(NULL, ("Invalid argument for option --renderm ethod: " + tmp).c_str(), "Error", MB_OK | MB_ICONERROR );106 MessageBox(NULL, ("Invalid argument for option --rendermode: " + tmp).c_str(), "Error", MB_OK | MB_ICONERROR ); 81 107 return -1; 82 108 } … … 85 111 if (cmdparser.getOpt("s",tmp)) 86 112 { 87 if (tmp == "KDT" || tmp == "OCT" || tmp == "OCM" || tmp == "GEN") 88 { 89 options.mSceneManager = tmp; 113 int sm = KdTreeAppListener::SM_NOTSET; 114 for (int i = 0; i < KdTreeAppListener::SM_SIZE; i ++) 115 { 116 if (tmp == KdTreeAppListener::SCENEMANAGER[i]) 117 sm = i; 118 } 119 if (sm != KdTreeAppListener::SM_NOTSET) 120 { 121 options.mSceneManager = sm; 90 122 } 91 123 else … … 149 181 cfDeath.load("testKdTree.cfg"); 150 182 151 mSelectedSceneManager = cfDeath.getSetting("scenemanager");152 183 mSceneFiles = cfDeath.getSetting("scene"); 153 184 … … 194 225 mOptions.mDemoOutfileName = cfDeath.getSetting("demooutfile"); 195 226 196 // set default demo output name to avoid SNAFUs197 //if (mOptions.mDemoOutfileName.empty())198 // mOptions.mDemoOutfileName = "demo.bin";199 200 227 if (mOptions.mDemoLogfileName.empty()) 201 228 mOptions.mDemoLogfileName = cfDeath.getSetting("demologfile"); 202 203 // set default demo logfile name to avoid SNAFUs204 //if (mOptions.mDemoLogfileName.empty())205 // mOptions.mDemoLogfileName = "demo.csv";206 207 // override scene manager set in config file208 if (!mOptions.mSceneManager.empty())209 {210 if (mOptions.mSceneManager == "KDT")211 mSelectedSceneManager = "KdTreeSceneManager";212 else if (mOptions.mSceneManager == "OCT")213 mSelectedSceneManager = "OctreeSceneManager";214 else if (mOptions.mSceneManager == "OCM")215 mSelectedSceneManager = "OcclusionCullingSceneManager";216 else if (mOptions.mSceneManager == "GEN")217 mSelectedSceneManager = "DefaultSceneManager";218 }219 // the other way round for log220 else221 {222 if (mSelectedSceneManager == "KdTreeSceneManager")223 mOptions.mSceneManager = "KDT";224 else if (mSelectedSceneManager == "OctreeSceneManager")225 mOptions.mSceneManager = "OCT";226 else if (mSelectedSceneManager == "OcclusionCullingSceneManager")227 mOptions.mSceneManager = "OCM";228 else if (mSelectedSceneManager == "DefaultSceneManager")229 mOptions.mSceneManager = "GEN";230 }231 229 232 230 ExampleApplication::setupResources(); … … 416 414 { 417 415 // Get the SceneManager 418 mSceneMgr = mRoot->createSceneManager(mSelectedSceneManager,"MySceneManager"); 419 // set params 420 mSceneMgr->setOption("KdTreeMaxDepth", &mOptions.mMaxDepth); 421 mSceneMgr->setOption("KT", &mOptions.mKT); 422 mSceneMgr->setOption("KI", &mOptions.mKI); 423 mSceneMgr->setOption("RenderMethod", &mOptions.mRenderMethod); 424 mSceneMgr->setOption("EnhancedVisibility", &mOptions.mEnhancedVisibility); 416 mSceneMgr = mRoot->createSceneManager( 417 KdTreeAppListener::SCENEMANAGERNAME[mOptions.mSceneManager], 418 "MySceneManager"); 419 // set params depending on scene manager 420 if (mOptions.mSceneManager == KdTreeAppListener::SM_KDT) 421 { 422 mSceneMgr->setOption("BuildMethod", &mOptions.mBuildMethod); 423 mSceneMgr->setOption("KdTreeMaxDepth", &mOptions.mMaxDepth); 424 mSceneMgr->setOption("KT", &mOptions.mKT); 425 mSceneMgr->setOption("KI", &mOptions.mKI); 426 mSceneMgr->setOption("RenderMethod", &mOptions.mRenderMethod); 427 mSceneMgr->setOption("EnhancedVisibility", &mOptions.mEnhancedVisibility); 428 } 429 // set algorithm when scene manager is OCM - numbering is different though 430 if (mOptions.mSceneManager == KdTreeAppListener::SM_OCM) 431 { 432 int alg = CONV_KDT_TO_OCM_ALG(mOptions.mRenderMethod); 433 mSceneMgr->setOption("Algorithm", &alg); 434 } 425 435 } 426 436 … … 452 462 mTopCam->setDirection(0,0,-1); 453 463 mTopCam->pitch(Radian(-Math::HALF_PI)); 454 //mTopCam->setCullingFrustum(mCamera);464 mTopCam->setCullingFrustum(mCamera); 455 465 mTopCam->setNearClipDistance(1); 456 466 -
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/src/TestKdTreeAppListener.cpp
r1215 r1220 6 6 #include <windows.h> 7 7 8 const Real KdTreeAppListener::DEMO_WAIT = 5.0; 8 9 const String KdTreeAppListener::NA = ": N/A"; 9 const Real KdTreeAppListener::DEMO_WAIT = 5.0; 10 const String KdTreeAppListener::RENDERMETHOD[] = { "INT", "VFC", "SWC", "CHC" }; 11 const String KdTreeAppListener::RENDERMETHODCAPTION[] = 12 { 13 "Internal Frustum Culling", 14 "View Frustum Culling", 15 "Stop and Wait Culling", 16 "Coherent Hierarchical Culling" 17 }; 18 const String KdTreeAppListener::BUILDMETHOD[] = { "RE", "PQ" }; 19 const String KdTreeAppListener::BUILDMETHODCAPTION[] = { "Recursive", "Priority Queue" }; 20 const String KdTreeAppListener::SCENEMANAGER[] = { "KDT", "OCM", "OCT", "GEN" }; 21 const String KdTreeAppListener::SCENEMANAGERNAME[] = 22 { 23 "KdTreeSceneManager", 24 "OcclusionCullingSceneManager", 25 "OctreeSceneManager", 26 "DefaultSceneManager" 27 }; 10 28 11 29 void KdTreeAppListener::updateStats(void) … … 220 238 const int border_height = 10; 221 239 const int vert_space = 15; 240 int top = border_height; 241 242 String ext = "KdTree/"; 222 243 String sMD, sKT, sKI, sHL, sBM, sRM, sFM, sTC, sEV; 223 224 int top = border_height;225 226 String ext = "KdTree/";227 244 228 245 int maxd; … … 252 269 sHL = ": off"; 253 270 254 Stringbm;271 int bm; 255 272 if (mSceneMgr->getOption("BuildMethod", &bm)) 256 sBM = ": " + bm;273 sBM = ": " + BUILDMETHODCAPTION[bm]; 257 274 else 258 275 sBM = NA; 259 276 260 Stringrm;277 int rm; 261 278 if (mSceneMgr->getOption("RenderMethod", &rm)) 262 { 263 if (rm == "INT") 264 sRM = ": Internal Frustum Culling"; 265 else if (rm == "VFC") 266 sRM = ": View Frustum Culling"; 267 else if (rm == "SWC") 268 sRM = ": Stop and Wait Culling"; 269 else if (rm == "CHC") 270 sRM = ": Coherent Hierarchical Culling"; 271 else 272 sRM = NA; 273 } 279 sRM = ": " + RENDERMETHODCAPTION[rm]; 274 280 else 275 281 sRM = NA; 282 283 // hack to allow mode switching in OCM 284 if (mOptions.mSceneManager == SM_OCM) 285 { 286 rm = CONV_KDT_TO_OCM_ALG(mOptions.mRenderMethod); 287 sRM = ": " + RENDERMETHODCAPTION[CONV_OCM_TO_KDT_ALG(rm)]; 288 } 276 289 277 290 bool enh; … … 430 443 void KdTreeAppListener::toggleBuildMethod() 431 444 { 432 static String bmOptions[] = { "Recursive", "PriorityQueue" }; 433 static String bmOptionCaptions[] = { ": Recursive", ": PriorityQueue" }; 434 static int bmOptionsSize = sizeof(bmOptions) / sizeof(String); 435 static int bmCurrent = 0; 436 437 String bm; 445 int bm; 446 438 447 if (mSceneMgr->getOption("BuildMethod", &bm)) 439 448 { 440 for (int idx = 0; idx < bmOptionsSize; idx++) 441 if (bmOptions[idx] == bm) 442 bmCurrent = idx; 443 bmCurrent = (bmCurrent + 1) % bmOptionsSize; 444 if (mSceneMgr->setOption("BuildMethod", &bmOptions[bmCurrent])) 445 mBuildMethodInfo->setCaption(bmOptionCaptions[bmCurrent]); 449 bm = (bm + 1) % KdTree::KDBM_SIZE; 450 if (mSceneMgr->setOption("BuildMethod", &bm)) 451 mBuildMethodInfo->setCaption(": " + BUILDMETHODCAPTION[bm]); 446 452 } 447 453 else … … 453 459 void KdTreeAppListener::toggleRenderMethod() 454 460 { 455 static String rmOptions[] = { "INT", "VFC", "SWC", "CHC" }; 456 static String rmOptionCaptions[] = 457 { 458 ": Internal Frustum Culling", 459 ": View Frustum Culling", 460 ": Stop and Wait Culling", 461 ": Coherent Hierarchical Culling" 462 }; 463 static int rmOptionsSize = sizeof(rmOptions) / sizeof (String); 464 static int rmCurrent = 0; 465 466 String rm; 461 int rm; 462 467 463 if (mSceneMgr->getOption("RenderMethod", &rm)) 468 464 { 469 for (int idx = 0; idx < rmOptionsSize; idx++) 470 if (rmOptions[idx] == rm) 471 rmCurrent = idx; 472 rmCurrent = (rmCurrent + 1) % rmOptionsSize; 473 if (mSceneMgr->setOption("RenderMethod", &rmOptions[rmCurrent])) 474 mRenderMethodInfo->setCaption(rmOptionCaptions[rmCurrent]); 465 rm = (rm + 1) % KdTree::KDRM_SIZE; 466 if (mSceneMgr->setOption("RenderMethod", &rm)) 467 mRenderMethodInfo->setCaption(": " + RENDERMETHODCAPTION[rm]); 475 468 } 476 469 else 477 470 { 478 471 mRenderMethodInfo->setCaption(NA); 472 } 473 474 // hack to allow mode switching in OCM, cannot extract setting from sm 475 if (mOptions.mSceneManager == SM_OCM) 476 { 477 static int alg = CONV_KDT_TO_OCM_ALG(mOptions.mRenderMethod); 478 alg = (alg + 1) % 3; 479 if (mSceneMgr->setOption("Algorithm", &alg)) 480 mRenderMethodInfo->setCaption(": " + RENDERMETHODCAPTION[CONV_OCM_TO_KDT_ALG(alg)]); 479 481 } 480 482 } … … 539 541 } 540 542 541 if (mInputDevice->isKeyDown(KC_ F11) && mTimeUntilNextToggle <= 0)543 if (mInputDevice->isKeyDown(KC_0) && mTimeUntilNextToggle <= 0) 542 544 { 543 545 toggleBuildMethod(); … … 1500 1502 { 1501 1503 // demo settings 1502 logwrite << mOptions.mSceneManager;1503 if (mOptions.mSceneManager == "KDT")1504 { 1505 logwrite << ds << mOptions.mRenderMethod<< ds << mOptions.mMaxDepth << ds1504 logwrite << SCENEMANAGER[mOptions.mSceneManager]; 1505 if (mOptions.mSceneManager == SM_KDT) 1506 { 1507 logwrite << ds << RENDERMETHOD[mOptions.mRenderMethod] << ds << mOptions.mMaxDepth << ds 1506 1508 << mOptions.mKT << ds << mOptions.mKI; 1507 1509 } 1508 //else if (mOptions.mSceneManager == "OCM" && mOptions.mRenderMethod != "INT")1509 //{1510 // logwrite << ds << mOptions.mRenderMethod;1511 //}1510 else if (mOptions.mSceneManager == SM_OCM && mOptions.mRenderMethod != KdTree::KDRM_INTERNAL) 1511 { 1512 logwrite << ds << RENDERMETHOD[(mOptions.mRenderMethod+3)%3]; 1513 } 1512 1514 logwrite << fs; 1513 1515 // per second stats
Note: See TracChangeset
for help on using the changeset viewer.