Changeset 30
- Timestamp:
- 03/24/05 18:00:59 (20 years ago)
- Location:
- trunk/VUT/OcclusionCullingSceneManager
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.cpp
r29 r30 114 114 115 115 // show overlay 116 Overlay* pOver = OverlayManager::getSingleton().getByName("Example/OcclusionDemoOverlay"); 117 mAlgorithmInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/OcclusionTechniqueInfo"); 118 //mMaterialInfo = OverlayManager::getSingleton().getOverlayElement("Example/Shadows/MaterialInfo"); 116 Overlay* pOver = OverlayManager::getSingleton().getByName("Example/OcclusionDemoOverlay"); 117 118 mAlgorithmInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/AlgorithmInfo"); 119 mThresholdInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/ThresholdInfo"); 120 mFrustumCulledNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/FrustumCulledNodesInfo"); 121 mQueryCulledNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/QueryCulledNodesInfo"); 122 mTraversedNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Occlusion/TraversedNodesInfo"); 123 124 //mMaterialInfo = OverlayManager::getSingleton().getOverlayElement("Example/Shadows/MaterialInfo"); 119 125 //mInfo = OverlayManager::getSingleton().getOverlayElement("Example/Shadows/Info"); 120 126 121 127 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 122 //mMaterialInfo->setCaption(": " + mAtheneMaterials[mCurrentAtheneMaterial]); 128 mThresholdInfo->setCaption(": dfddfdffdfd0"); 129 mFrustumCulledNodesInfo->setCaption(": 0"); 130 mQueryCulledNodesInfo->setCaption(": 0"); 131 mTraversedNodesInfo->setCaption(": 0"); 132 123 133 pOver->show(); 124 134 } // MouseQueryListener … … 185 195 186 196 KEY_PRESSED(KC_O, 1, changeAlgorithm()); 197 //KEY_PRESSED(KC_T, 1, changeAlgorithm()); 187 198 199 changeStats(); 200 188 201 return ExampleFrameListener::frameStarted(evt) && ExampleFrameListener::frameEnded(evt); 189 202 } … … 192 205 { 193 206 mCurrentAlgorithm = ++mCurrentAlgorithm % OcclusionCullingSceneManager::NUM_RENDERMODES; 194 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 195 207 208 mAlgorithmInfo->setCaption(": " + mCurrentAlgorithmCaptions[mCurrentAlgorithm]); 196 209 mSceneMgr->setOption("Algorithm", &mCurrentAlgorithm); 197 210 } 198 211 //----------------------------------------------------------------------- 212 void MouseQueryListener::changeStats() 213 { 214 unsigned int opt = 0; 215 216 mSceneMgr->getOption("Threshold", &opt); mThresholdInfo->setCaption(": " + opt); 217 mSceneMgr->getOption("NumFrustumCulledNodes", &opt); mFrustumCulledNodesInfo->setCaption(": " + opt); 218 mSceneMgr->getOption("NumQueryCulledNodes", &opt); mQueryCulledNodesInfo->setCaption(": " + opt); 219 mSceneMgr->getOption("NumTraversedNodes", &opt); mTraversedNodesInfo->setCaption(": " + opt); 220 } 221 //----------------------------------------------------------------------- 199 222 INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT ) 200 223 { -
trunk/VUT/OcclusionCullingSceneManager/TestCulling/TestCullingApplication.h
r29 r30 88 88 */ 89 89 void changeAlgorithm(); 90 90 void changeStats(); 91 91 92 92 protected: … … 98 98 // bool mShutdownRequested; 99 99 int mCurrentAlgorithm; 100 100 101 OverlayElement *mAlgorithmInfo; 102 OverlayElement *mThresholdInfo; 103 OverlayElement *mFrustumCulledNodesInfo; 104 OverlayElement *mQueryCulledNodesInfo; 105 OverlayElement *mTraversedNodesInfo; 106 101 107 }; 102 108 … … 142 148 143 149 }*/ 144 // Override scene manager (use indoor instead of generic)145 150 146 151 -
trunk/VUT/OcclusionCullingSceneManager/include/OgreOcclusionCullingSceneManager.h
r29 r30 71 71 enum {MODE_QUERY, MODE_RENDER}; 72 72 73 intisLeaf(SceneNode *node);74 int countSceneNodes(SceneNode *node);73 bool isLeaf(SceneNode *node); 74 unsigned int countSceneNodes(SceneNode *node); 75 75 void renderZPass(); 76 76 void traverseNode(SceneNode *node); … … 105 105 PriorityQueue *mDistanceQueue; 106 106 107 unsigned int mFrameId; 108 unsigned int mVisibilityThreshold; 109 unsigned int mNumSceneNodes; 110 int mCurrentTestIdx; 111 int mQueryMode; 112 113 std::vector<HardwareOcclusionQuery *> mOcclusionQueries; 107 std::vector<HardwareOcclusionQuery *> mOcclusionQueries; 114 108 // two halfes of a aabb 115 109 SolidHalfBoundingBox *mHalfBoundingBox[2]; 116 110 int mCurrentAlgorithm; 111 112 unsigned int mFrameId; 113 unsigned int mVisibilityThreshold; 114 115 int mCurrentTestIdx; 116 int mQueryMode; 117 118 //--- statistics 119 unsigned int mNumSceneNodes; 120 unsigned int mNumTraversedNodes; 121 unsigned int mNumQueryCulledNodes; 122 unsigned int mNumFrustumCulledNodes; 123 unsigned int mNumRenderedGeometry; 117 124 }; 118 125 -
trunk/VUT/OcclusionCullingSceneManager/scripts/OcclusionDemo.overlay
r29 r30 24 24 25 25 26 element TextArea(Example/Occlusion/ OcclusionTechnique)26 element TextArea(Example/Occlusion/Algorithm) 27 27 { 28 28 metrics_mode pixels … … 37 37 colour_bottom 0.3 0.5 0.3 38 38 } 39 element TextArea(Example/Occlusion/OcclusionTechniqueInfo) 40 { 41 metrics_mode pixels 42 left 155 43 top 5 44 width 90 45 height 30 46 font_name TrebuchetMSBold 47 char_height 16 48 caption : 49 colour_top 0.5 0.7 0.5 50 colour_bottom 0.3 0.5 0.3 51 } 52 53 element TextArea(Example/Occlusion/Materials) 54 { 55 metrics_mode pixels 56 left 5 57 top 20 58 width 90 59 height 30 60 font_name TrebuchetMSBold 61 char_height 16 62 caption [M] Athene Material 63 colour_top 0.5 0.7 0.5 64 colour_bottom 0.3 0.5 0.3 65 } 66 element TextArea(Example/Occlusion/MaterialInfo) 67 { 68 metrics_mode pixels 69 left 155 70 top 20 71 width 90 72 height 30 73 font_name TrebuchetMSBold 74 char_height 16 75 caption : 76 colour_top 0.5 0.7 0.5 77 colour_bottom 0.3 0.5 0.3 78 } 79 element TextArea(Example/Occlusion/OcclusionInfo) 80 { 81 metrics_mode pixels 82 left 5 83 top 35 84 width 250 85 height 30 86 font_name TrebuchetMSBold 87 char_height 16 39 element TextArea(Example/Occlusion/AlgorithmInfo) 40 { 41 metrics_mode pixels 42 left 155 43 top 5 44 width 90 45 height 30 46 font_name TrebuchetMSBold 47 char_height 16 48 caption : 49 colour_top 0.5 0.7 0.5 50 colour_bottom 0.3 0.5 0.3 51 } 52 53 element TextArea(Example/Occlusion/Threshold) 54 { 55 metrics_mode pixels 56 left 5 57 top 20 58 width 90 59 height 30 60 font_name TrebuchetMSBold 61 char_height 16 62 caption [-][+] Thresholdz 63 colour_top 0.5 0.7 0.5 64 colour_bottom 0.3 0.5 0.3 65 } 66 element TextArea(Example/Occlusion/ThresholdInfo) 67 { 68 metrics_mode pixels 69 left 155 70 top 20 71 width 90 72 height 30 73 font_name TrebuchetMSBold 74 char_height 16 75 caption :dddd 88 76 colour_top 0.5 0.7 0.5 89 77 colour_bottom 0.3 0.5 0.3 … … 112 100 border_bottomright_uv 0.9961 0.0039 1.0000 0.0000 113 101 114 115 element TextArea(Example/Occlusion/CulledNodes) 116 { 117 metrics_mode pixels 118 left 5 119 top 5 120 width 180 121 height 30 122 font_name TrebuchetMSBold 123 char_height 16 124 caption Culled Nodes 102 element TextArea(Example/Occlusion/FrustumCulledNodes) 103 { 104 metrics_mode pixels 105 left 5 106 top 5 107 width 180 108 height 30 109 font_name TrebuchetMSBold 110 char_height 16 111 caption Frustum Culled Nodes 112 colour_top 0.5 0.7 0.5 113 colour_bottom 0.3 0.5 0.3 114 } 115 element TextArea(Example/Occlusion/FrustumCulledNodesInfo) 116 { 117 metrics_mode pixels 118 left 155 119 top 5 120 width 90 121 height 30 122 font_name TrebuchetMSBold 123 char_height 16 124 caption :jjkj 125 colour_top 0.5 0.7 0.5 126 colour_bottom 0.3 0.5 0.3 127 } 128 element TextArea(Example/Occlusion/QueryCulledNodes) 129 { 130 metrics_mode pixels 131 left 5 132 top 20 133 width 180 134 height 30 135 font_name TrebuchetMSBold 136 char_height 16 137 caption Query Query Culled Nodes 125 138 colour_top 0.5 0.7 0.5 126 139 colour_bottom 0.3 0.5 0.3 127 140 } 141 element TextArea(Example/Occlusion/QueryCulledNodesInfo) 142 { 143 metrics_mode pixels 144 left 155 145 top 20 146 width 90 147 height 30 148 font_name TrebuchetMSBold 149 char_height 16 150 caption : 151 colour_top 0.5 0.7 0.5 152 colour_bottom 0.3 0.5 0.3 153 } 154 element TextArea(Example/Occlusion/TraversedNodes) 155 { 156 metrics_mode pixels 157 left 5 158 top 35 159 width 180 160 height 30 161 font_name TrebuchetMSBold 162 char_height 16 163 caption Traversed Nodes 164 colour_top 0.5 0.7 0.5 165 colour_bottom 0.3 0.5 0.3 166 } 167 element TextArea(Example/Occlusion/TraversedNodesInfo) 168 { 169 metrics_mode pixels 170 left 155 171 top 35 172 width 90 173 height 30 174 font_name TrebuchetMSBold 175 char_height 16 176 caption : 177 colour_top 0.5 0.7 0.5 178 colour_bottom 0.3 0.5 0.3 179 } 180 element TextArea(Example/Occlusion/SceneNodes) 181 { 182 metrics_mode pixels 183 left 5 184 top 50 185 width 180 186 height 30 187 font_name TrebuchetMSBold 188 char_height 16 189 caption Traversed Scene Nodes 190 colour_top 0.5 0.7 0.5 191 colour_bottom 0.3 0.5 0.3 192 } 193 element TextArea(Example/Occlusion/SceneNodesInfo) 194 { 195 metrics_mode pixels 196 left 155 197 top 50 198 width 90 199 height 30 200 font_name TrebuchetMSBold 201 char_height 16 202 caption : 203 colour_top 0.5 0.7 0.5 204 colour_bottom 0.3 0.5 0.3 205 } 128 206 } 129 207 } -
trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneManager.cpp
r29 r30 15 15 OcclusionCullingSceneManager::OcclusionCullingSceneManager(): 16 16 mFrameId(1), mDistanceQueue(NULL), mVisibilityThreshold(0), mCurrentTestIdx(0), 17 mQueryMode(MODE_RENDER), mNumSceneNodes(0), mCurrentAlgorithm(RENDER_COHERENT) 17 mQueryMode(MODE_RENDER), mNumSceneNodes(0), mCurrentAlgorithm(RENDER_COHERENT), 18 mNumTraversedNodes(0), mNumQueryCulledNodes(0), mNumFrustumCulledNodes(0), mNumRenderedGeometry(0) 18 19 { 19 20 mHalfBoundingBox[0] = mHalfBoundingBox[1] = 0; … … 36 37 void OcclusionCullingSceneManager::_renderVisibleObjects(void) 37 38 { 39 mNumTraversedNodes = 0; 40 mNumQueryCulledNodes = 0; 41 mNumFrustumCulledNodes = 0; 42 mNumRenderedGeometry = 0; 43 38 44 mDistanceQueue = new PriorityQueue(myless<SceneNode *>(mCameraInProgress)); 39 40 45 mDistanceQueue->push(mSceneRoot); 41 42 46 mCurrentTestIdx = 0; 43 44 47 //renderZPass(); 45 48 … … 62 65 delete mDistanceQueue; 63 66 64 /*mDestRenderSystem->_setDepthBufferParams(true, false, CMPF_LESS);65 SceneManager::_renderVisibleObjects();66 mDestRenderSystem->_setDepthBufferParams();67 mDistanceQueue.push(mSceneRoot);68 Preprocess();69 //ResetQueries();70 */71 72 67 mFrameId ++; 73 68 } … … 102 97 traverseNode(node); 103 98 } 99 else 100 { 101 mNumQueryCulledNodes ++; 102 } 104 103 } 105 104 … … 108 107 { 109 108 SceneNode *node = mDistanceQueue->top(); 110 111 109 mDistanceQueue->pop(); 112 110 … … 134 132 // always traverse a node if it was visible 135 133 if(wasVisible) 134 { 136 135 traverseNode(node); 136 } 137 } 138 else 139 { 140 mNumFrustumCulledNodes ++; 137 141 } 138 142 } … … 157 161 traverseNode(node); 158 162 } 163 else 164 { 165 mNumFrustumCulledNodes ++; 166 } 159 167 } 160 168 } … … 179 187 query->pullOcclusionQuery(&visiblePixels); 180 188 181 //char str[100]; sprintf(str, "number: %d, id: %d", (int)visiblePixels, mCurrentTestIdx);182 //MessageBox( NULL, str, "this is my plugin", MB_OK | MB_ICONERROR | MB_TASKMODAL);183 184 189 // node visible 185 190 if(visiblePixels > mVisibilityThreshold) … … 187 192 traverseNode(node); 188 193 } 189 } 194 else 195 { 196 mNumQueryCulledNodes ++; 197 } 198 } 199 else 200 { 201 mNumFrustumCulledNodes ++; 202 } 190 203 } 191 204 } … … 203 216 /* 204 217 static RenderOperation ro; 205 206 // Issue view / projection changes if any207 218 useRenderableViewProjMode(&box); 208 209 219 box.getRenderOperation(ro); 210 220 ro.srcRenderable = &box; … … 237 247 void OcclusionCullingSceneManager::traverseNode(SceneNode *node) 238 248 { 239 if(isLeaf(node)) 249 mNumTraversedNodes ++; 250 251 if(node->numAttachedObjects() > 0) 240 252 { 241 253 render(node); 242 254 } 243 else // internal node: add children to priority queue for further processing 244 {245 255 256 // internal node: add children to priority queue for further processing 257 Node::ChildNodeIterator it = node->getChildIterator(); 246 258 247 while (it.hasMoreElements()) 248 { 249 SceneNode* sceneChild = static_cast<SceneNode*>(it.getNext()); 250 mDistanceQueue->push(sceneChild); 251 } 252 } 259 while (it.hasMoreElements()) 260 { 261 SceneNode* sceneChild = static_cast<SceneNode*>(it.getNext()); 262 mDistanceQueue->push(sceneChild); 263 } 253 264 } 254 265 //----------------------------------------------------------------------- 255 266 void OcclusionCullingSceneManager::render(SceneNode *node) 256 267 { 257 //setRenderingMode(MODE_RENDER);258 //MessageBox( NULL, "harhar", "this is my plugin", MB_OK | MB_ICONERROR | MB_TASKMODAL);268 setRenderingMode(MODE_RENDER); 269 259 270 //HACK (too slow) 260 271 node->_findVisibleObjects(mCameraInProgress, getRenderQueue(), false, … … 266 277 void OcclusionCullingSceneManager::_updateSceneGraph(Camera* cam) 267 278 { 268 int numnodes = countSceneNodes(mSceneRoot);269 279 unsigned int numnodes = countSceneNodes(mSceneRoot); 280 270 281 //-- initialise occlusion queries. 271 282 if(numnodes != mNumSceneNodes) 272 283 { 273 284 deleteQueries(); 285 274 286 mNumSceneNodes = numnodes; 275 287 276 288 for(unsigned int i=0; i < mNumSceneNodes; i++) 277 289 { 278 HardwareOcclusionQuery *hw = mDestRenderSystem->createHardwareOcclusionQuery(); 279 mOcclusionQueries.push_back(hw); 280 } 290 mOcclusionQueries.push_back(mDestRenderSystem->createHardwareOcclusionQuery()); 291 } 281 292 } 282 293 … … 284 295 } 285 296 //----------------------------------------------------------------------- 286 int OcclusionCullingSceneManager::countSceneNodes(SceneNode *node) 287 { 288 int num = 1; 289 if(isLeaf(node)) 290 { 291 return num; 292 } 293 297 unsigned int OcclusionCullingSceneManager::countSceneNodes(SceneNode *node) 298 { 299 unsigned int result = 1; 300 294 301 Node::ChildNodeIterator it = node->getChildIterator(); 295 302 … … 297 304 { 298 305 SceneNode* sceneChild = static_cast<SceneNode*>(it.getNext()); 299 num+= countSceneNodes(sceneChild);306 result += countSceneNodes(sceneChild); 300 307 } 301 308 302 return num;303 } 304 //----------------------------------------------------------------------- 305 intOcclusionCullingSceneManager::isLeaf(SceneNode *node)309 return result; 310 } 311 //----------------------------------------------------------------------- 312 bool OcclusionCullingSceneManager::isLeaf(SceneNode *node) 306 313 { 307 314 return (node->numChildren() == 0); … … 353 360 return true; 354 361 } 355 362 if ( key == "Threshold" ) 363 { 364 mCurrentAlgorithm = * static_cast < const int * > ( val ); 365 return true; 366 } 367 356 368 return SceneManager::setOption( key, val ); 357 369 } … … 362 374 { 363 375 * static_cast < int * > ( val ) = mCurrentAlgorithm; 376 return true; 377 } 378 if ( key == "Threshold" ) 379 { 380 * static_cast < int * > ( val ) = mVisibilityThreshold; 381 return true; 382 } 383 if ( key == "NumSceneNodes" ) 384 { 385 * static_cast < unsigned int * > ( val ) = mNumSceneNodes; 386 return true; 387 } 388 if ( key == "NumTraversedNodes" ) 389 { 390 * static_cast < unsigned int * > ( val ) = mNumTraversedNodes; 391 return true; 392 } 393 if ( key == "NumQueryCulledNodes" ) 394 { 395 * static_cast < unsigned int * > ( val ) = mNumQueryCulledNodes; 396 return true; 397 } 398 if ( key == "NumFrustumCulledNodes" ) 399 { 400 * static_cast < unsigned int * > ( val ) = mNumFrustumCulledNodes; 364 401 return true; 365 402 } … … 377 414 SceneManager::getOptionKeys( refKeys ); 378 415 refKeys.push_back( "Algorithm" ); 379 416 refKeys.push_back( "Threshold" ); 417 refKeys.push_back( "NumSceneNodes" ); 418 refKeys.push_back( "NumTraversedNodes" ); 419 refKeys.push_back( "NumQueryCulledNodes" ); 420 refKeys.push_back( "NumFrustumCulledNodes" ); 421 //refKeys.push_back( "mNumRenderedGeometry" ); 380 422 return true; 381 423 }
Note: See TracChangeset
for help on using the changeset viewer.