- Timestamp:
- 08/04/06 17:38:52 (18 years ago)
- Location:
- GTP/trunk
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/KdTreeDemo/OGRE/include/TestKdTreeAppListener.h
r1177 r1183 50 50 Real mMoveSpeed; 51 51 Degree mRotateSpeed; 52 Overlay* mDebugOverlay;53 Overlay* mKdTreeOverlay;54 52 Real mRotationPeriod; 55 53 bool mShowTree; 56 54 bool mFreeMove; 57 55 56 Real mDelayedQueriesIssued; 57 Real mDelayedTraversedNodes; 58 58 59 int mSeqNum; 60 61 Overlay* mDebugOverlay; 62 Overlay* mKdTreeOverlay; 63 64 OverlayElement *mKdTreeMaxDepthInfo; 65 OverlayElement *mKTInfo; 66 OverlayElement *mKIInfo; 67 OverlayElement *mHighlightLevelInfo; 68 OverlayElement *mBuildMethodInfo; 69 OverlayElement *mRenderMethodInfo; 70 OverlayElement *mMovementInfo; 71 72 OverlayElement *mFrustumCulledNodesInfo; 73 OverlayElement *mQueryCulledNodesInfo; 74 OverlayElement *mTraversedNodesInfo; 75 OverlayElement *mHierarchyNodesInfo; 76 OverlayElement *mRenderedNodesInfo; 77 OverlayElement *mObjectsCountInfo; 78 OverlayElement *mQueriesIssuedInfo; 59 79 60 80 void updateStats(void) 61 81 { 82 static unsigned int opt = 0; 83 static char str[100]; 84 62 85 static String currFps = "Current FPS: "; 63 86 static String avgFps = "Average FPS: "; … … 76 99 77 100 guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS)); 78 guiCurr->setCaption(currFps + StringConverter::toString( stats.lastFPS));101 guiCurr->setCaption(currFps + StringConverter::toString((int)stats.lastFPS)); 79 102 guiBest->setCaption(bestFps + StringConverter::toString(stats.bestFPS) 80 103 +" "+StringConverter::toString(stats.bestFrameTime)+" ms"); … … 87 110 OverlayElement* guiDbg = OverlayManager::getSingleton().getOverlayElement("Core/DebugText"); 88 111 guiDbg->setCaption(mWindow->getDebugText()); 112 113 114 //-- culling stats 115 mSceneMgr->getOption("NumFrustumCulledNodes", &opt); sprintf(str,": %d", opt); 116 mFrustumCulledNodesInfo->setCaption(str); 117 118 mSceneMgr->getOption("NumQueryCulledNodes", &opt); sprintf(str,": %d", opt); 119 mQueryCulledNodesInfo->setCaption(str); 120 121 mSceneMgr->getOption("NumHierarchyNodes", &opt); sprintf(str,": %d", opt); 122 mHierarchyNodesInfo->setCaption(str); 123 124 mSceneMgr->getOption("NumRenderedNodes", &opt); sprintf(str,": %d", opt); 125 mRenderedNodesInfo->setCaption(str); 126 127 // take old value into account in order to create no sudden changes 128 mSceneMgr->getOption("NumQueriesIssued", &opt); 129 mDelayedQueriesIssued = mDelayedQueriesIssued * 0.8 + (float)opt * 0.2f; 130 sprintf(str,": %d", (int)mDelayedQueriesIssued); 131 mQueriesIssuedInfo->setCaption(str); 132 133 mSceneMgr->getOption("NumTraversedNodes", &opt); 134 mDelayedTraversedNodes = mDelayedTraversedNodes * 0.8 + (float)opt * 0.2f; 135 sprintf(str,": %d", (int)mDelayedTraversedNodes); 136 mTraversedNodesInfo->setCaption(str); 89 137 } 90 138 catch(...) … … 95 143 96 144 public: 145 146 // visualization modes for scene nodes 147 enum 148 { 149 NODEVIZ_NONE, 150 NODEVIZ_RENDER_NODES, 151 NODEVIZ_RENDER_NODES_AND_CONTENT, 152 NODEVIZ_MODES_NUM 153 }; 97 154 98 155 // Constructor takes a RenderWindow because it uses that to determine input context … … 128 185 mCullTransVec = Vector3::ZERO; 129 186 mSeqNum = 0; 187 188 mDelayedQueriesIssued = 0.0; 189 mDelayedTraversedNodes = 0.0; 130 190 131 191 mCamera = sm->getCamera("PlayerCam"); … … 151 211 152 212 initKdTreeOverlay(); 213 initStatsOverlay(); 153 214 154 215 showDebugOverlay(true); … … 166 227 } 167 228 229 //----------------------------------------------------------------------- 230 void initOverlayElement(OverlayElement **elInfo, String ext, 231 String name, int top, String caption) 232 { 233 OverlayElement *el = 234 OverlayManager::getSingleton().getOverlayElement(ext + name); 235 236 (*elInfo) = OverlayManager::getSingleton().getOverlayElement(ext + name + "Info"); 237 (*elInfo)->setCaption(caption); 238 239 el->setTop(top); 240 (*elInfo)->setTop(top); 241 } 242 //----------------------------------------------------------------------- 243 void initStatsOverlay() 244 { 245 const int border_height = 10; 246 const int vert_space = 15; 247 248 //-- visibility culling stats overlay 249 int top = border_height; 250 251 String ext = "KdTree/Visibility/"; 252 253 initOverlayElement(&mFrustumCulledNodesInfo, ext, "FrustumCulledNodes", top, ": 0"); top += vert_space; 254 initOverlayElement(&mQueryCulledNodesInfo, ext, "QueryCulledNodes", top, ": 0"); top += vert_space; 255 initOverlayElement(&mTraversedNodesInfo, ext, "TraversedNodes", top, ": 0"); top += vert_space; 256 initOverlayElement(&mHierarchyNodesInfo, ext, "HierarchyNodes", top, ": 0"); top += vert_space; 257 initOverlayElement(&mRenderedNodesInfo, ext, "RenderedNodes", top, ": 0"); top += vert_space; 258 initOverlayElement(&mObjectsCountInfo, ext, "ObjectsCount", top, ": 0"); top += vert_space; 259 initOverlayElement(&mQueriesIssuedInfo, ext, "QueriesIssued", top, ": 0"); top += vert_space; 260 261 OverlayElement *visPanel = OverlayManager::getSingleton(). 262 getOverlayElement("KdTree/VisibilityStatsPanel"); 263 264 visPanel->setHeight(top + border_height); 265 } 266 //----------------------------------------------------------------------- 168 267 void initKdTreeOverlay() 169 268 { 170 String na = " N/A"; 171 String value; 269 const int border_height = 10; 270 const int vert_space = 15; 271 const String na = ": N/A"; 272 String sMD, sKT, sKI, sHL, sBM, sRM, sFM; 273 274 int top = border_height; 275 276 String ext = "KdTree/"; 172 277 173 278 int maxd; 174 279 if (mSceneMgr->getOption("KdTreeMaxDepth", &maxd)) 175 value = "" + StringConverter::toString(maxd);280 sMD = ": " + StringConverter::toString(maxd); 176 281 else 177 value = na; 178 String caption = OverlayManager::getSingleton().getOverlayElement("KdTree/Depth")->getCaption(); 179 OverlayManager::getSingleton().getOverlayElement("KdTree/Depth")->setCaption(caption + value); 282 sMD = na; 180 283 181 284 Real kt; 182 285 if (mSceneMgr->getOption("KT", &kt)) 183 value = "" + StringConverter::toString(kt);286 sKT = ": " + StringConverter::toString(kt); 184 287 else 185 value = na; 186 caption = OverlayManager::getSingleton().getOverlayElement("KdTree/KT")->getCaption(); 187 OverlayManager::getSingleton().getOverlayElement("KdTree/KT")->setCaption(caption + value); 288 sKT = na; 188 289 189 290 Real ki; 190 291 if (mSceneMgr->getOption("KI", &ki)) 191 value = "" + StringConverter::toString(ki);292 sKI = ": " + StringConverter::toString(ki); 192 293 else 193 value = na; 194 caption = OverlayManager::getSingleton().getOverlayElement("KdTree/KI")->getCaption(); 195 OverlayManager::getSingleton().getOverlayElement("KdTree/KI")->setCaption(caption + value); 294 sKI = na; 196 295 197 296 int hl; 198 297 if (mSceneMgr->getOption("HighlightLevel", &hl)) 199 value = "" + StringConverter::toString(hl);298 sHL = ": " + StringConverter::toString(hl); 200 299 else 201 value= na;300 sHL = na; 202 301 if (!mShowTree) 203 value = " off"; 204 caption = OverlayManager::getSingleton().getOverlayElement("KdTree/Highlight")->getCaption(); 205 OverlayManager::getSingleton().getOverlayElement("KdTree/Highlight")->setCaption(caption + value); 302 sHL = ": off"; 206 303 207 304 String bm; 208 305 if (mSceneMgr->getOption("BuildMethod", &bm)) 209 value = "" + bm;306 sBM = ": " + bm; 210 307 else 211 value = na; 212 caption = OverlayManager::getSingleton().getOverlayElement("KdTree/BuildMethod")->getCaption(); 213 OverlayManager::getSingleton().getOverlayElement("KdTree/BuildMethod")->setCaption(caption + value); 308 sBM = na; 214 309 215 310 String rm; … … 217 312 { 218 313 if (rm == "INT") 219 value = "Internal Frustum Culling";314 sRM = ": Internal Frustum Culling"; 220 315 else if (rm == "VFC") 221 value = "View Frustum Culling";316 sRM = ": View Frustum Culling"; 222 317 else if (rm == "SWC") 223 value = "Stop and Wait Culling";318 sRM = ": Stop and Wait Culling"; 224 319 else if (rm == "CHC") 225 value = "Coherent Hierarchical Culling";320 sRM = ": Coherent Hierarchical Culling"; 226 321 else 227 value= na;322 sRM = na; 228 323 } 229 324 else 230 value = na; 231 caption = OverlayManager::getSingleton().getOverlayElement("KdTree/RenderMethod")->getCaption(); 232 OverlayManager::getSingleton().getOverlayElement("KdTree/RenderMethod")->setCaption(caption + value); 233 234 value = na; 325 sRM = na; 326 327 sFM = na; 235 328 if (mFreeMove) 236 value = "Free";329 sFM = ": Free"; 237 330 else 238 value = " Ground"; 239 caption = OverlayManager::getSingleton().getOverlayElement("KdTree/Movement")->getCaption(); 240 OverlayManager::getSingleton().getOverlayElement("KdTree/Movement")->setCaption(caption + value); 331 sFM = ": Ground"; 332 333 initOverlayElement(&mRenderMethodInfo, ext, "RenderMethod", top, sRM); top += vert_space; 334 initOverlayElement(&mBuildMethodInfo, ext, "BuildMethod", top, sBM); top += vert_space; 335 initOverlayElement(&mKdTreeMaxDepthInfo, ext, "KdTreeMaxDepth", top, sMD); top += vert_space; 336 initOverlayElement(&mHighlightLevelInfo, ext, "HighlightLevel", top, sHL); top += vert_space; 337 initOverlayElement(&mKTInfo, ext, "KT", top, sKT); top += vert_space; 338 initOverlayElement(&mKIInfo, ext, "KI", top, sKI); top += vert_space; 339 initOverlayElement(&mMovementInfo, ext, "Movement", top, sFM); top += vert_space; 340 341 OverlayElement *visPanel = OverlayManager::getSingleton(). 342 getOverlayElement("KdTree/OptionsPanel"); 343 344 visPanel->setHeight(top + border_height); 241 345 } 242 346 243 void toggleCullCamera()347 void showDebugOverlay(bool show) 244 348 { 245 mCullCamera = !mCullCamera; 246 int zorder = 2; 247 if (mCullCamera) 248 { 249 Viewport* tvp = mWindow->addViewport(mTopCam,zorder,0.66,0.66,0.34,0.34); 250 tvp->setBackgroundColour(ColourValue(1.0, 0.0, 0.0)); 251 tvp->setOverlaysEnabled(false); 252 253 mTopCam->setAspectRatio( 254 Real(tvp->getActualWidth())/Real(tvp->getActualHeight())); 349 if (mDebugOverlay) 350 { 351 if (show) 352 { 353 mDebugOverlay->show(); 354 mKdTreeOverlay->show(); 355 } 356 else 357 { 358 mDebugOverlay->hide(); 359 mKdTreeOverlay->hide(); 360 } 361 } 362 } 363 364 void toggleVizCamera() 365 { 366 static const int zorder = 10; 367 static nodeVizMode = 0; 368 369 nodeVizMode = (nodeVizMode + 1) % NODEVIZ_MODES_NUM; 370 371 if (nodeVizMode != 0) 372 { 373 if (!mCullCamera) 374 { 375 Viewport* tvp = mWindow->addViewport(mTopCam,zorder,0.66,0.66,0.34,0.34); 376 tvp->setBackgroundColour(ColourValue(1.0, 0.0, 0.0)); 377 tvp->setOverlaysEnabled(false); 378 379 mTopCam->setAspectRatio( 380 Real(tvp->getActualWidth())/Real(tvp->getActualHeight())); 381 mCullCamera = true; 382 mSceneMgr->setOption("VisualizeCulledNodes", &mCullCamera); 383 } 384 385 bool renderNodesForViz = (nodeVizMode == NODEVIZ_RENDER_NODES) || 386 (nodeVizMode == NODEVIZ_RENDER_NODES_AND_CONTENT); 387 bool renderNodesContentForViz = (nodeVizMode == NODEVIZ_RENDER_NODES_AND_CONTENT); 388 389 mSceneMgr->setOption("RenderNodesForViz", &renderNodesForViz); 390 mSceneMgr->setOption("RenderNodesContentForViz", &renderNodesContentForViz); 255 391 } 256 392 else 257 393 { 258 394 mWindow->removeViewport(zorder); 395 mCullCamera = false; 396 mSceneMgr->setOption("VisualizeCulledNodes", &mCullCamera); 259 397 } 260 398 } … … 288 426 } 289 427 290 // stuff for the kdtree overlay 291 static String sRM = "[SPACE] Algorithm: "; 292 static String sBM = "[X] Build Method: "; 293 static String sMaxDepth = "[1][2] Max Tree Depth: "; 294 static String sHL = "[3][4] Highlight: "; 295 static String sKT = "[5][6] KT: "; 296 static String sKI = "[7][8] KI: "; 297 static String sMov = "[Q] Movement: "; 428 // stuff for the overlay 429 static String sNA = ": N/A"; 298 430 299 431 static String bmOptions[] = { "Recursive", "PriorityQueue" }; 432 static String bmOptionCaptions[] = { ": Recursive", ": PriorityQueue" }; 300 433 static int bmOptionsSize = sizeof(bmOptions) / sizeof(String); 301 434 static int bmCurrent = 0; … … 305 438 static String rmOptionCaptions[] = 306 439 { 307 " Internal Frustum Culling",308 " View Frustum Culling",309 " Stop and Wait Culling",310 " Coherent Hierarchical Culling"440 ": Internal Frustum Culling", 441 ": View Frustum Culling", 442 ": Stop and Wait Culling", 443 ": Coherent Hierarchical Culling" 311 444 }; 312 445 static int rmOptionsSize = sizeof(rmOptions) / sizeof (String); … … 325 458 if (mSceneMgr->setOption("KdTreeMaxDepth", &currdepth)) 326 459 { 327 OverlayManager::getSingleton().getOverlayElement("KdTree/Depth")->setCaption(sMaxDepth+ StringConverter::toString(currdepth));460 mKdTreeMaxDepthInfo->setCaption(": " + StringConverter::toString(currdepth)); 328 461 int hl; 329 462 if (mSceneMgr->getOption("HighlightLevel", &hl)) 330 OverlayManager::getSingleton().getOverlayElement("KdTree/Highlight")->setCaption(sHL+ StringConverter::toString(hl));463 mHighlightLevelInfo->setCaption(": " + StringConverter::toString(hl)); 331 464 else 332 OverlayManager::getSingleton().getOverlayElement("KdTree/Highlight")->setCaption(sHL + "N/A");465 mHighlightLevelInfo->setCaption(sNA); 333 466 } 334 467 } 335 468 else 336 469 { 337 OverlayManager::getSingleton().getOverlayElement("KdTree/Depth")->setCaption(sMaxDepth + "N/A");338 OverlayManager::getSingleton().getOverlayElement("KdTree/Highlight")->setCaption(sHL + "N/A");470 mKdTreeMaxDepthInfo->setCaption(sNA); 471 mHighlightLevelInfo->setCaption(sNA); 339 472 } 340 473 341 474 if (!mShowTree) 342 OverlayManager::getSingleton().getOverlayElement("KdTree/Highlight")->setCaption(sHL + "off");475 mHighlightLevelInfo->setCaption(": off"); 343 476 344 477 mTimeUntilNextToggle = 0.2; … … 356 489 357 490 if (mSceneMgr->setOption("HighlightLevel", &hl)) 358 OverlayManager::getSingleton().getOverlayElement("KdTree/Highlight")->setCaption(sHL+ StringConverter::toString(hl));491 mHighlightLevelInfo->setCaption(": " + StringConverter::toString(hl)); 359 492 } 360 493 else 361 494 { 362 OverlayManager::getSingleton().getOverlayElement("KdTree/Highlight")->setCaption(sHL + "N/A");495 mHighlightLevelInfo->setCaption(sNA); 363 496 } 364 497 365 498 if (!mShowTree) 366 OverlayManager::getSingleton().getOverlayElement("KdTree/Highlight")->setCaption(sHL + "off");499 mHighlightLevelInfo->setCaption(": off"); 367 500 368 501 mTimeUntilNextToggle = 0.2; … … 384 517 385 518 if (mSceneMgr->setOption("KT", &kt)) 386 OverlayManager::getSingleton().getOverlayElement("KdTree/KT")->setCaption(sKT+ StringConverter::toString(kt));519 mKTInfo->setCaption(": " + StringConverter::toString(kt)); 387 520 } 388 521 else 389 522 { 390 OverlayManager::getSingleton().getOverlayElement("KdTree/KT")->setCaption(sKT + "N/A");523 mKTInfo->setCaption(sNA); 391 524 } 392 525 … … 408 541 409 542 if (mSceneMgr->setOption("KI", &ki)) 410 OverlayManager::getSingleton().getOverlayElement("KdTree/KI")->setCaption(sKI+ StringConverter::toString(ki));543 mKIInfo->setCaption(": " + StringConverter::toString(ki)); 411 544 } 412 545 else 413 546 { 414 OverlayManager::getSingleton().getOverlayElement("KdTree/KI")->setCaption(sKI + "N/A");547 mKIInfo->setCaption(sNA); 415 548 } 416 549 … … 423 556 if (mSceneMgr->getOption("BuildMethod", &bm)) 424 557 { 558 for (int idx = 0; idx < bmOptionsSize; idx++) 559 if (bmOptions[idx] == bm) 560 bmCurrent = idx; 425 561 bmCurrent = (bmCurrent + 1) % bmOptionsSize; 426 562 if (mSceneMgr->setOption("BuildMethod", &bmOptions[bmCurrent])) 427 OverlayManager::getSingleton().getOverlayElement("KdTree/BuildMethod")->setCaption(sBM + bmOptions[bmCurrent]);563 mBuildMethodInfo->setCaption(bmOptionCaptions[bmCurrent]); 428 564 } 429 565 else 430 566 { 431 OverlayManager::getSingleton().getOverlayElement("KdTree/BuildMethod")->setCaption(sBM + "N/A");567 mBuildMethodInfo->setCaption(sNA); 432 568 } 433 569 … … 440 576 if (mSceneMgr->getOption("RenderMethod", &rm)) 441 577 { 578 for (int idx = 0; idx < rmOptionsSize; idx++) 579 if (rmOptions[idx] == rm) 580 rmCurrent = idx; 442 581 rmCurrent = (rmCurrent + 1) % rmOptionsSize; 443 582 if (mSceneMgr->setOption("RenderMethod", &rmOptions[rmCurrent])) 444 OverlayManager::getSingleton().getOverlayElement("KdTree/RenderMethod")->setCaption(sRM +rmOptionCaptions[rmCurrent]);583 mRenderMethodInfo->setCaption(rmOptionCaptions[rmCurrent]); 445 584 } 446 585 else 447 586 { 448 OverlayManager::getSingleton().getOverlayElement("KdTree/RenderMethod")->setCaption(sRM + "N/A");587 mRenderMethodInfo->setCaption(sNA); 449 588 } 450 589 … … 457 596 String move = "N/A"; 458 597 if (mFreeMove) 459 move = " Free";598 move = ": Free"; 460 599 else 461 move = " Ground";462 463 OverlayManager::getSingleton().getOverlayElement("KdTree/Movement")->setCaption(sMov +move);600 move = ": Ground"; 601 602 mMovementInfo->setCaption(move); 464 603 465 604 mTimeUntilNextToggle = 0.5; … … 503 642 } 504 643 505 if (mInputDevice->isKeyDown(KC_ Y) && mTimeUntilNextToggle <= 0)644 if (mInputDevice->isKeyDown(KC_O) && mTimeUntilNextToggle <= 0) 506 645 { 507 646 LogManager::getSingleton().logMessage("############## Camera Position:"); … … 522 661 if (mInputDevice->isKeyDown(KC_C) && mTimeUntilNextToggle <= 0) 523 662 { 524 toggle CullCamera();663 toggleVizCamera(); 525 664 mTimeUntilNextToggle = 0.5; 526 665 } … … 544 683 545 684 if (!mShowTree) 546 OverlayManager::getSingleton().getOverlayElement("KdTree/Highlight")->setCaption(sHL + "off");685 mHighlightLevelInfo->setCaption(": off"); 547 686 else 548 687 { 549 688 int hl; 550 689 if (mSceneMgr->getOption("HighlightLevel", &hl)) 551 OverlayManager::getSingleton().getOverlayElement("KdTree/Highlight")->setCaption(sHL+ StringConverter::toString(hl));690 mHighlightLevelInfo->setCaption(": " + StringConverter::toString(hl)); 552 691 else 553 OverlayManager::getSingleton().getOverlayElement("KdTree/Highlight")->setCaption(sHL + "N/A");692 mHighlightLevelInfo->setCaption(sNA); 554 693 } 555 694 … … 563 702 toggleShowAllBoxes = !toggleShowAllBoxes; 564 703 mSceneMgr->setOption("ShowAllBoxes", &toggleShowAllBoxes); 704 mTimeUntilNextToggle = 0.2; 705 } 706 707 if (mInputDevice->isKeyDown(KC_H) && mTimeUntilNextToggle <= 0) 708 { 709 bool toggleShow; 710 mSceneMgr->getOption("ShowNodeAABB", &toggleShow); 711 toggleShow = !toggleShow; 712 mSceneMgr->setOption("ShowNodeAABB", &toggleShow); 565 713 mTimeUntilNextToggle = 0.2; 566 714 } … … 762 910 } 763 911 764 void showDebugOverlay(bool show)765 {766 if (mDebugOverlay)767 {768 if (show)769 {770 mDebugOverlay->show();771 mKdTreeOverlay->show();772 }773 else774 {775 mDebugOverlay->hide();776 mKdTreeOverlay->hide();777 }778 }779 }780 781 912 // Override frameStarted event to process that (don't care about frameEnded) 782 913 bool frameStarted(const FrameEvent& evt) -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/include/OgreKdTree.h
r1182 r1183 211 211 //virtual void cbInsert(KdTree * caller, KdRenderable * rend) = 0; 212 212 213 WireBoundingBox * getWireBoundingBox( )213 WireBoundingBox * getWireBoundingBox(bool node = true) 214 214 { 215 215 if (mWBB == 0) 216 216 mWBB = new WireBoundingBox(); 217 217 218 mWBB->setupBoundingBox(mAABB); 218 if (node) 219 mWBB->setupBoundingBox(mAABB); 220 else 221 mWBB->setupBoundingBox(mWorldAABB); 219 222 220 223 #ifdef KDTREE_DEBUG 224 SceneManager * sceneManager = Root::getSingleton()._getCurrentSceneManager(); 221 225 int level = -1; 222 226 bool boxes = false; 223 if ( Root::getSingleton()._getCurrentSceneManager()->getOption("HighlightLevel",&level))227 if (sceneManager->getOption("HighlightLevel",&level)) 224 228 { 225 229 if (mLevel == level) … … 232 236 { 233 237 mWBB->setMaterial("BaseWhiteNoLighting"); 234 if ( Root::getSingleton()._getCurrentSceneManager()->getOption("ShowAllBoxes", &boxes))238 if (sceneManager->getOption("ShowAllBoxes", &boxes)) 235 239 { 236 240 if (boxes) … … 279 283 /** Updates bound of the real aabb of kdtree 280 284 */ 281 virtual void _updateBounds() = 0; 282 285 virtual void _updateBounds(bool recurse = true) = 0; 283 286 284 287 Branch * mParent; … … 325 328 326 329 // branches do not posses geometry => just merge child aabbs 327 virtual void _updateBounds( )330 virtual void _updateBounds(bool recurse = true) 328 331 { 329 332 // reset box … … 336 339 337 340 // update parent recursively 338 if ( mParent)339 mParent->_updateBounds( );341 if (recurse && mParent) 342 mParent->_updateBounds(recurse); 340 343 } 341 344 … … 365 368 366 369 // update the world aabb based on the contained geometry 367 virtual void _updateBounds( );370 virtual void _updateBounds(bool recurse = true); 368 371 369 372 virtual void remove(KdRenderable * rend) … … 464 467 void dump(void); 465 468 Real calcCost(void); 469 470 /** Switches between displaying the bounding box of the node and 471 the box of the contained scene nodes 472 */ 473 inline void setShowNodeAABB(bool show = true) { mShowNodeAABB = show; }; 474 inline bool getShowNodeAABB(void) { return mShowNodeAABB; }; 466 475 467 476 NodePtr getRoot(void) const { return mKdRoot; }; … … 523 532 Stats mStats; 524 533 534 // show node or object aabb 535 bool mShowNodeAABB; 536 537 525 538 // DEBUG 526 539 void KdTree::dump(KdTree::Node * node); -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTree.cpp
r1182 r1183 329 329 //---------------------------------------------------------------------------- 330 330 331 KdTree::KdTree(int maxdepth): mMaxDepth(maxdepth), mKdRoot(0), mBuildMethod(KDBM_RECURSIVE), mBuildLog(0) 331 KdTree::KdTree(int maxdepth): 332 mMaxDepth(maxdepth), 333 mKdRoot(0), 334 mBuildMethod(KDBM_RECURSIVE), 335 mBuildLog(0), 336 mShowNodeAABB(true) 332 337 { 333 338 #ifdef KDTREE_DEBUG … … 340 345 mp->setDiffuse(cv); 341 346 } 342 //try343 //{344 // ColourValue cv(0.0, 1.0, 0.0);345 // MaterialPtr mp = MaterialManager::getSingleton().create("aabbHiLite","General");346 // mp->setSelfIllumination(cv);347 // mp->setDiffuse(cv);348 //}349 //catch (Ogre::Exception&)350 //{351 // // SO FUCKING DON'T CARE !!!352 //}353 347 #endif 354 348 try … … 871 865 ++ mStats.mNumNodes; 872 866 ++ mStats.mNumLeaves; 867 // update bounding box 868 leaf->_updateBounds(false); 873 869 return leaf; 874 870 } … … 957 953 // update stats 958 954 ++ mStats.mNumNodes; 955 956 // update bounding box 957 branch->_updateBounds(false); 958 959 959 960 960 //assert(branch->mRight || branch->mLeft); … … 1261 1261 } 1262 1262 1263 // update bounding boxes when geometry (leaf) was added 1264 if (newNode->isLeaf()) 1265 newNode->_updateBounds(); 1266 1263 1267 //cleanup 1264 1268 OGRE_DELETE(sc.events); … … 1336 1340 WireBoundingBox * wbb = 0; 1337 1341 if (showBoxes) 1338 wbb = node->getWireBoundingBox( );1342 wbb = node->getWireBoundingBox(mShowNodeAABB); 1339 1343 #endif 1340 1344 … … 1357 1361 #else 1358 1362 if (showBoxes) 1359 queue->addRenderable(leaf->getWireBoundingBox( ));1363 queue->addRenderable(leaf->getWireBoundingBox(mShowNodeAABB)); 1360 1364 #endif 1361 1365 } … … 1368 1372 #else 1369 1373 if (showBoxes) 1370 queue->addRenderable(branch->getWireBoundingBox( ));1374 queue->addRenderable(branch->getWireBoundingBox(mShowNodeAABB)); 1371 1375 #endif 1372 1376 … … 1469 1473 1470 1474 // update the world aabb based on the contained geometry 1471 void KdTree::Leaf::_updateBounds( )1475 void KdTree::Leaf::_updateBounds(bool recurse) 1472 1476 { 1473 1477 // reset box … … 1479 1483 while (it != end) 1480 1484 { 1485 //(*it)->_updateBounds(); 1481 1486 mWorldAABB.merge((*it)->getBoundingBox()); 1482 1487 it++; … … 1484 1489 1485 1490 // update parent recursively 1486 if ( mParent)1487 mParent->_updateBounds( );1491 if (recurse && mParent) 1492 mParent->_updateBounds(recurse); 1488 1493 } 1489 1494 } // namespace Ogre -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneManager.cpp
r1182 r1183 59 59 60 60 mHierarchyInterface = new KdTreeHierarchyInterface(this, mDestRenderSystem); 61 62 // test 63 //String chc = "CHC"; 64 //setOption("RenderMethod", &chc); 61 65 } 62 66 … … 240 244 return true; 241 245 } 246 else if (strKey == "ShowNodeAABB") 247 { 248 bool sn = *static_cast<const bool *>(pValue); 249 if (mKdTree) 250 mKdTree->setShowNodeAABB(sn); 251 return true; 252 } 253 // options for CHC 254 if (strKey == "UseDepthPass") 255 { 256 mUseDepthPass = (*static_cast<const bool *>(pValue)); 257 return true; 258 } 259 if (strKey == "PrepareVisualization") 260 { 261 mShowVisualization = (*static_cast<const bool *>(pValue)); 262 return true; 263 } 264 if (strKey == "RenderNodesForViz") 265 { 266 mRenderNodesForViz = (*static_cast<const bool *>(pValue)); 267 return true; 268 } 269 if (strKey == "RenderNodesContentForViz") 270 { 271 mRenderNodesContentForViz = (*static_cast<const bool *>(pValue)); 272 return true; 273 } 274 if (strKey == "SkyBoxEnabled") 275 { 276 mSkyBoxEnabled = (*static_cast<const bool *>(pValue)); 277 return true; 278 } 279 if (strKey == "SkyPlaneEnabled") 280 { 281 mSkyPlaneEnabled = (*static_cast<const bool *>(pValue)); 282 return true; 283 } 284 if (strKey == "SkyDomeEnabled") 285 { 286 mSkyDomeEnabled = (*static_cast<const bool *>(pValue)); 287 return true; 288 } 289 if (strKey == "VisualizeCulledNodes") 290 { 291 mVisualizeCulledNodes = (*static_cast<const bool *>(pValue)); 292 return true; 293 } 294 if (strKey == "DelayRenderTransparents") 295 { 296 mDelayRenderTransparents = (*static_cast<const bool *>(pValue)); 297 return true; 298 } 299 300 if (strKey == "DepthWrite") 301 { 302 mEnableDepthWrite = (*static_cast<const bool *>(pValue)); 303 return true; 304 } 305 if (strKey == "UseItemBuffer") 306 { 307 mUseItemBuffer = (*static_cast<const bool *>(pValue)); 308 return true; 309 } 310 if (strKey == "ExecuteVertexProgramForAllPasses") 311 { 312 mExecuteVertexProgramForAllPasses = (*static_cast<const bool *>(pValue)); 313 return true; 314 } 315 if (strKey == "RenderTransparentsForItemBuffer") 316 { 317 mRenderTransparentsForItemBuffer = (*static_cast<const bool *>(pValue)); 318 return true; 319 } 320 242 321 243 322 return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface) … … 270 349 else if (strKey == "ShowAllBoxes") 271 350 { 272 *static_cast<bool *>(pDestValue) = mShowAllBoxes; 351 if (mRenderMethod == KdTree::KDRM_INTERNAL) 352 *static_cast<bool *>(pDestValue) = mShowAllBoxes; 353 else 354 *static_cast<bool *>(pDestValue) = mVisualizeCulledNodes; 273 355 return true; 274 356 } … … 308 390 return false; 309 391 } 392 return true; 393 } 394 else if (strKey == "ShowKdTree") 395 { 396 *static_cast<bool *>(pDestValue) = mShowBoxes; 397 return true; 398 } 399 else if (strKey == "ShowNodeAABB") 400 { 401 if (mKdTree) 402 *static_cast<bool *>(pDestValue) = mKdTree->getShowNodeAABB(); 403 else 404 *static_cast<bool *>(pDestValue) = false; 310 405 return true; 311 406 } … … 331 426 refKeys.push_back("RenderMethod"); 332 427 refKeys.push_back("ShowKdTree"); 428 refKeys.push_back("ShowNodeAABB"); 333 429 refKeys.push_back("TreeBox"); 334 430 #ifdef KDTREE_DEBUG … … 639 735 while (it != end) 640 736 { 641 (*it)->queueObjects(cam, getRenderQueue(), onlyShadowCasters); 737 if (!(*it)->isQueued(mHierarchyInterface->GetFrameId(), cam)) 738 { 739 (*it)->queueObjects(cam, getRenderQueue(), onlyShadowCasters); 740 } 642 741 it++; 643 742 } … … 841 940 } 842 941 // add bounding boxes of rendered objects 843 if (0)942 //if (0) 844 943 //for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 845 944 //{ -
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreKdTreeSceneNode.cpp
r1182 r1183 12 12 13 13 #include <OgreStringConverter.h> 14 #include <OgreLogManager.h> 14 15 15 16 namespace Ogre … … 140 141 } 141 142 143 // recalculate the world aabb 142 144 AxisAlignedBox KdTreeSceneNode::getBoundingBox() const 143 145 { 146 #if 0 147 AxisAlignedBox box; 148 149 // Update bounds from own attached objects 150 ObjectMap::const_iterator it = mObjectsByName.begin(); 151 ObjectMap::const_iterator end = mObjectsByName.end(); 152 for ( ; it != end ; ++it) 153 { 154 // Merge world bounds of each object 155 box.merge(it->second->getWorldBoundingBox(true)); 156 } 157 158 if (box.getMinimum() != mWorldAABB.getMinimum() ||box.getMaximum() != mWorldAABB.getMaximum()) 159 { 160 try 161 { 162 Log * log = LogManager::getSingleton().getLog("KdTreeBuild.log"); 163 log->logMessage("mWorldAABB was not up to date"); 164 } 165 catch (Exception) 166 { 167 // F.U. 168 } 169 } 170 171 return box; 172 #else 144 173 return mWorldAABB; 174 #endif 145 175 } 146 176
Note: See TracChangeset
for help on using the changeset viewer.