Changeset 99 for trunk/VUT/work
- Timestamp:
- 05/15/05 04:08:02 (20 years ago)
- Location:
- trunk/VUT/work
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/work/TestCulling/TestCullingApplication.cpp
r94 r99 111 111 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 112 112 mShowOctree(false), 113 mUse Culling(true),113 mUseVisibilityCulling(true), 114 114 mUseOptimization(true), 115 m UseCullCamera(false)115 mShowVisualization(false) 116 116 { 117 117 // Reduce move speed … … 153 153 154 154 mSceneMgr->setOption("UseOptimization", &mUseOptimization); 155 mSceneMgr->setOption("Use Culling", &mUseCulling);156 mSceneMgr->setOption(" CullCamera", &mUseCullCamera);155 mSceneMgr->setOption("UseVisibilityCulling", &mUseVisibilityCulling); 156 mSceneMgr->setOption("ShowVizualisation", &mShowVisualization); 157 157 mSceneMgr->setOption("ShowOctree", &mShowOctree); 158 158 … … 235 235 KEY_PRESSED(KC_ADD, 0, changeThreshold(10)); 236 236 KEY_PRESSED(KC_O, 0.3, toggleUseOptimization()); 237 KEY_PRESSED(KC_C, 0.3, toggleUse Culling());238 KEY_PRESSED(KC_V, 0.3, toggle CullCamera());237 KEY_PRESSED(KC_C, 0.3, toggleUseVisibilityCulling()); 238 KEY_PRESSED(KC_V, 0.3, toggleShowViz()); 239 239 240 240 updateStats(); … … 281 281 } 282 282 //----------------------------------------------------------------------- 283 void MouseQueryListener::toggleUse Culling()284 { 285 mUse Culling = !mUseCulling;286 287 mSceneMgr->setOption("Use Culling", &mUseCulling);288 } 289 //----------------------------------------------------------------------- 290 void MouseQueryListener::toggle CullCamera()291 { 292 m UseCullCamera = !mUseCullCamera;293 294 mSceneMgr->setOption("CullCamera", &m UseCullCamera);283 void MouseQueryListener::toggleUseVisibilityCulling() 284 { 285 mUseVisibilityCulling = !mUseVisibilityCulling; 286 287 mSceneMgr->setOption("UseVisibilityCulling", &mUseVisibilityCulling); 288 } 289 //----------------------------------------------------------------------- 290 void MouseQueryListener::toggleShowViz() 291 { 292 mShowVisualization = !mShowVisualization; 293 294 mSceneMgr->setOption("CullCamera", &mShowVisualization); 295 295 } 296 296 //----------------------------------------------------------------------- -
trunk/VUT/work/TestCulling/TestCullingApplication.h
r94 r99 66 66 void toggleUseOptimization(); 67 67 void toggleShowOctree(); 68 void toggleUse Culling();69 void toggle CullCamera();68 void toggleUseVisibilityCulling(); 69 void toggleShowViz(); 70 70 71 71 protected: … … 94 94 bool mUseOptimization; 95 95 bool mShowOctree; 96 bool mUse Culling;97 bool m UseCullCamera;96 bool mUseVisibilityCulling; 97 bool mShowVisualization; 98 98 99 99 Camera *mVisualizationCamera; -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r98 r99 27 27 if(mTerrainContentGenerator) 28 28 delete mTerrainContentGenerator; 29 //if(mRenderTargetListener) delete mRenderTargetListener; 29 30 } 30 31 //----------------------------------------------------------------------- 31 32 void TestCullingTerrainApplication::createCamera() 32 33 { 33 // Create the camera34 mCamera = mSceneMgr->createCamera(" CullCamera");35 36 // Set a nice viewpoint34 // create the camera 35 mCamera = mSceneMgr->createCamera("PlayerCam"); 36 37 // set a nice viewpoint 37 38 mCamera->setPosition(707, 2500, 528); 38 39 mCamera->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 39 40 40 //--create cullcamera41 mVisualizationCamera = mSceneMgr->createCamera("Vi sualizationCamera");42 mVisualizationCamera->setPosition( 707, 2500, 528);43 mVisualizationCamera->setOrientation( Quaternion(-0.3486, 0.0122, 0.9365, 0.0329));41 //--create visualization camera 42 mVisualizationCamera = mSceneMgr->createCamera("VizCam"); 43 mVisualizationCamera->setPosition(mCamera->getPosition()); 44 mVisualizationCamera->setOrientation(mCamera->getOrientation()); 44 45 45 46 mVisualizationCamera->setNearClipDistance(1); 46 47 mCamera->setNearClipDistance(1); 47 48 48 // Infinite far plane?49 // infinite far plane? 49 50 if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_INFINITE_FAR_PLANE)) 50 51 { … … 56 57 mVisualizationCamera->setFarClipDistance(1000); 57 58 mCamera->setFarClipDistance(1000); 58 } 59 59 } 60 } 61 62 //----------------------------------------------------------------------- 63 bool TestCullingTerrainApplication::setup() 64 { 65 bool result = ExampleApplication::setup(); 66 67 createRenderTargetListener(); 68 69 return result; 70 } 71 //----------------------------------------------------------------------- 72 void TestCullingTerrainApplication::createRenderTargetListener() 73 { 74 mWindow->addListener(new VisualizationRenderTargetListener(mSceneMgr)); 60 75 } 61 76 //----------------------------------------------------------------------- … … 152 167 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 153 168 mShowOctree(false), 154 mUse Culling(true),169 mUseVisibilityCulling(true), 155 170 mUseOptimization(true), 156 mUseCullCamera(false),157 171 mVisualizationCamera(vizCamera) 158 172 { … … 197 211 198 212 mSceneMgr->setOption("UseOptimization", &mUseOptimization); 199 mSceneMgr->setOption("UseCulling", &mUseCulling); 200 mSceneMgr->setOption("CullCamera", &mUseCullCamera); 213 mSceneMgr->setOption("UseVisibilityCulling", &mUseVisibilityCulling); 201 214 mSceneMgr->setOption("ShowOctree", &mShowOctree); 202 215 203 216 pOver->show(); 204 217 } … … 241 254 } // else if 242 255 } // mousePressed 243 244 //----------------------------------------------------------------------- 256 //----------------------------------------------------------------------- 245 257 void MouseQueryListener::mouseReleased(MouseEvent* e) 246 258 { … … 316 328 KEY_PRESSED(KC_O, 0.3, toggleUseOptimization()); 317 329 KEY_PRESSED(KC_Y, 0.3, toggleShowOctree()); 318 KEY_PRESSED(KC_C, 0.3, toggleUse Culling());319 KEY_PRESSED(KC_V, 0.3, toggle CullCamera());330 KEY_PRESSED(KC_C, 0.3, toggleUseVisibilityCulling()); 331 KEY_PRESSED(KC_V, 0.3, toggleShowViz()); 320 332 KEY_PRESSED(KC_X, 0.3, FixVizCamera()); 321 333 … … 397 409 } 398 410 //----------------------------------------------------------------------- 399 void MouseQueryListener::toggleUseCulling() 400 { 401 mUseCulling = !mUseCulling; 402 403 mSceneMgr->setOption("UseCulling", &mUseCulling); 404 } 405 //----------------------------------------------------------------------- 406 void MouseQueryListener::toggleCullCamera() 407 { 408 mUseCullCamera = !mUseCullCamera; 409 410 if(mUseCullCamera) 411 void MouseQueryListener::toggleUseVisibilityCulling() 412 { 413 mUseVisibilityCulling = !mUseVisibilityCulling; 414 415 mSceneMgr->setOption("UseVisibilityCulling", &mUseVisibilityCulling); 416 } 417 //----------------------------------------------------------------------- 418 void MouseQueryListener::toggleShowViz() 419 { 420 mShowVisualization = !mShowVisualization; 421 422 // create viewport with priority 10: will be rendered over standard viewport 423 if(mShowVisualization) 411 424 { 412 425 mWindow->addViewport(mVisualizationCamera, 10, 0.5, 0.5, 1, 1); … … 414 427 } 415 428 else 429 { 416 430 mWindow->removeViewport(10); 417 418 mSceneMgr->setOption("CullCamera", &mUseCullCamera); 431 } 419 432 } 420 433 //----------------------------------------------------------------------- … … 451 464 // Do nothing 452 465 e->consume(); 466 } 467 /**************************************************************/ 468 /* VisualizationRenderTargetListener implementation */ 469 /**************************************************************/ 470 VisualizationRenderTargetListener::VisualizationRenderTargetListener(SceneManager *sceneMgr) 471 :RenderTargetListener(), mSceneMgr(sceneMgr) 472 { 473 } 474 //----------------------------------------------------------------------- 475 void VisualizationRenderTargetListener::preViewportUpdate(const RenderTargetViewportEvent &evt) 476 { 477 const bool b = evt.source->getZOrder() == 10; // visualization viewport 478 479 mSceneMgr->setOption("ShowVisualization", &b); 480 481 RenderTargetListener::preViewportUpdate(evt); 482 } 483 //----------------------------------------------------------------------- 484 void VisualizationRenderTargetListener::postRenderTargetUpdate(const RenderTargetEvent &evt) 485 { 486 RenderTargetListener::postRenderTargetUpdate(evt); 453 487 } 454 488 //----------------------------------------------------------------------- -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h
r94 r99 7 7 #include "TerrainContentGenerator.h" 8 8 #include "VisibilityEnvironment.h" 9 #include <OgreRenderTargetListener.h> 9 10 10 11 Real timeDelay = 0; … … 23 24 "Stop and Wait Culling", 24 25 "Coherent Hierarchical Culling" 26 }; 27 28 class VisualizationRenderTargetListener: public RenderTargetListener 29 { 30 public: 31 VisualizationRenderTargetListener(SceneManager *sceneMgr); 32 33 protected: 34 void preViewportUpdate (const RenderTargetViewportEvent &evt); 35 void postRenderTargetUpdate (const RenderTargetEvent &evt); 36 37 SceneManager *mSceneMgr; 25 38 }; 26 39 … … 65 78 void toggleUseOptimization(); 66 79 void toggleShowOctree(); 67 void toggleUse Culling();68 void toggle CullCamera();80 void toggleUseVisibilityCulling(); 81 void toggleShowViz(); 69 82 void FixVizCamera(); 70 83 … … 100 113 bool mUseOptimization; 101 114 bool mShowOctree; 102 bool mUse Culling;103 bool m UseCullCamera;115 bool mUseVisibilityCulling; 116 bool mShowVisualization; 104 117 105 118 Camera *mVisualizationCamera; … … 113 126 114 127 protected: 128 //-- inherited from ExampleApplication 129 bool setup(); 115 130 void createScene(); 116 131 void createFrameListener(); 132 void createCamera(); 133 //void createViewports(); 134 135 virtual void createRenderTargetListener(); 136 137 /** cegui setup */ 117 138 void setupGui(); 118 virtual void createCamera();119 139 120 140 CEGUI::OgreCEGUIRenderer *mGUIRenderer; … … 128 148 129 149 TerrainContentGenerator *mTerrainContentGenerator; 150 151 Camera *mVisualizationCamera; 152 VisualizationRenderTargetListener *mRenderTargetListener; 130 153 131 Camera *mVisualizationCamera;132 133 154 private: 134 155 void chooseSceneManager(void); 135 156 }; 136 -
trunk/VUT/work/ogre_changes/OgreMain/src/OgreSceneManager.cpp
r61 r99 4178 4178 } 4179 4179 } 4180 #ifdef OGRE_COHERENT_OCCLUSION_CULLING4180 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 4181 4181 //----------------------------------------------------------------------- 4182 4182 void SceneManager::_renderSceneNode( Camera *cam, SceneNode *node ) … … 4193 4193 RenderQueue::QueueGroupIterator queueIt = getRenderQueue()->_getQueueGroupIterator(); 4194 4194 4195 // find currently processed queue groups and delelete them from render queue 4195 4196 while (queueIt.hasMoreElements()) 4196 4197 { … … 4198 4199 RenderQueueGroup* pGroup = queueIt.getNext(); 4199 4200 4200 // delete this queue group if already processed4201 4201 if (isRenderQueueToBeProcessed(qId)) 4202 4202 pGroup->clear(); … … 4206 4206 // Pass::processPendingPassUpdates(); 4207 4207 } 4208 #endif // OGRE_COHERENT_OCCLUSION_CULLING4209 } 4208 #endif //GTP_VISIBILITY_MODIFIED_OGRE 4209 } -
trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreOctreeSceneManager.cpp
r61 r99 316 316 317 317 mOctree = new Octree( 0 ); 318 #ifdef OGRE_COHERENT_OCCLUSION_CULLING318 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 319 319 mNumOctreeNodes = 1; 320 #endif // OGRE_COHERENT_OCCLUSION_CULLING320 #endif // GTP_VISIBILITY_MODIFIED_OGRE 321 321 mMaxDepth = depth; 322 322 mBox = box; … … 461 461 { 462 462 octant -> mChildren[ x ][ y ][ z ] = new Octree( octant ); 463 #ifdef OGRE_COHERENT_OCCLUSION_CULLING463 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 464 464 mNumOctreeNodes ++; 465 #endif // OGRE_COHERENT_OCCLUSION_CULLING465 #endif // GTP_VISIBILITY_MODIFIED_OGRE 466 466 467 467 const Vector3 *corners = octant -> mBox.getAllCorners(); … … 1028 1028 1029 1029 mOctree = new Octree( 0 ); 1030 #ifdef OGRE_COHERENT_OCCLUSION_CULLING1030 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 1031 1031 mNumOctreeNodes = 1; 1032 #endif // OGRE_COHERENT_OCCLUSION_CULLING1032 #endif // GTP_VISIBILITY_MODIFIED_OGRE 1033 1033 mOctree->mBox = box; 1034 1034 … … 1166 1166 return q; 1167 1167 } 1168 #ifdef OGRE_COHERENT_OCCLUSION_CULLING1168 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 1169 1169 //----------------------------------------------------------------------- 1170 1170 void OctreeSceneManager::_renderOctant(Camera *cam, Octree *octant) … … 1177 1177 OctreeNode *sn = *it; 1178 1178 1179 mNumObjects++;1179 ++mNumObjects; 1180 1180 1181 1181 // check bounding box visibility of scene nodes … … 1187 1187 1188 1188 if (mDisplayNodes) 1189 { 1189 1190 getRenderQueue()->addRenderable(sn); 1191 } 1190 1192 1191 1193 // check if the scene manager or this node wants the bounding box shown. 1192 1194 if (sn->getShowBoundingBox() || mShowBoundingBoxes) 1195 { 1193 1196 sn->_addBoundingBoxToQueue(getRenderQueue()); 1194 1195 if (mShowBoxes) 1196 getRenderQueue()->addRenderable(octant->getWireBoundingBox()); 1197 } 1197 1198 } 1198 1199 ++it; 1199 1200 } 1200 1201 1202 if (mShowBoxes) 1203 { 1204 getRenderQueue()->addRenderable(octant->getWireBoundingBox()); 1205 ++mNumObjects; 1206 } 1207 1201 1208 SceneManager::_renderVisibleObjects(); 1202 1209 1203 // delete all rendered objects from renderqueue1210 // delete all rendered objects from the render queue 1204 1211 _deleteRenderedQueueGroups(); 1205 1212 } 1206 #endif // OGRE_COHERENT_OCCLUSION_CULLING1207 } 1213 #endif // GTP_VISIBILITY_MODIFIED_OGRE 1214 } -
trunk/VUT/work/ogre_changes/RenderSystems/GL/src/OgreGLHardwareOcclusionQuery.cpp
r97 r99 161 161 162 162 // Check for hardware occlusion support 163 // if( glDeleteOcclusionQueriesNV_ptr != 0 ) // This is a hack to see if hw occlusion is supported. pointer is 0 if it's not supported.164 if( glDeleteQueriesARB_ptr != 0 )163 if ( glDeleteOcclusionQueriesNV_ptr != 0 ) // This is a hack to see if hw occlusion is supported. pointer is 0 if it's not supported. 164 //if ( glDeleteQueriesARB_ptr != 0 ) 165 165 { 166 166 m_bHWOcclusionSupport = true; … … 171 171 } 172 172 173 if ( m_bHWOcclusionSupport )174 { 175 //glGenOcclusionQueriesNV_ptr( 1, m_uintQuery );176 glGenQueriesARB_ptr(1, m_uintQuery);173 if ( m_bHWOcclusionSupport ) 174 { 175 glGenOcclusionQueriesNV_ptr( 1, m_uintQuery ); 176 //glGenQueriesARB_ptr(1, m_uintQuery); 177 177 } 178 178 } … … 182 182 GLHardwareOcclusionQuery::~GLHardwareOcclusionQuery() 183 183 { 184 if ( m_bHWOcclusionSupport )185 { 186 //glDeleteOcclusionQueriesNV_ptr( 1, &m_uintQuery[0] );187 glDeleteQueriesARB_ptr(1, &m_uintQuery[0]);184 if ( m_bHWOcclusionSupport ) 185 { 186 glDeleteOcclusionQueriesNV_ptr( 1, &m_uintQuery[0] ); 187 //glDeleteQueriesARB_ptr(1, &m_uintQuery[0]); 188 188 } 189 189 } … … 192 192 void GLHardwareOcclusionQuery::beginOcclusionQuery() 193 193 { 194 if ( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported194 if ( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 195 195 { 196 196 // do the actual occlusion query for this node 197 //glBeginOcclusionQueryNV_ptr( m_uintQuery[0] );198 glBeginQueryARB_ptr(GL_SAMPLES_PASSED_ARB, m_uintQuery[0]);197 glBeginOcclusionQueryNV_ptr( m_uintQuery[0] ); 198 //glBeginQueryARB_ptr(GL_SAMPLES_PASSED_ARB, m_uintQuery[0]); 199 199 } 200 200 } … … 202 202 void GLHardwareOcclusionQuery::endOcclusionQuery() 203 203 { 204 if ( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported205 { 206 //glEndOcclusionQueryNV_ptr();207 glEndQueryARB_ptr(GL_SAMPLES_PASSED_ARB);204 if ( m_bHWOcclusionSupport ) // Make it fail silently if hardware occlusion isn't supported 205 { 206 glEndOcclusionQueryNV_ptr(); 207 //glEndQueryARB_ptr(GL_SAMPLES_PASSED_ARB); 208 208 } 209 209 } … … 211 211 bool GLHardwareOcclusionQuery::pullOcclusionQuery( unsigned int * NumOfFragments, const bool waitForResult) 212 212 { 213 //unsigned int isAvailable = GL_TRUE;214 int isAvailable = GL_TRUE;213 unsigned int isAvailable = GL_TRUE; 214 //int isAvailable = GL_TRUE; 215 215 216 216 if( m_bHWOcclusionSupport ) 217 217 { 218 if (!waitForResult)219 { 220 //glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_AVAILABLE_NV, &isAvailable );221 glGetQueryivARB_ptr(m_uintQuery[0], GL_QUERY_RESULT_AVAILABLE_ARB, &isAvailable);222 } 223 224 if (isAvailable == GL_TRUE)225 { 226 glGet QueryObjectuivARB_ptr( m_uintQuery[0], GL_QUERY_RESULT_ARB, NumOfFragments);227 //glGet OcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments);218 if (!waitForResult) 219 { 220 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_AVAILABLE_NV, &isAvailable ); 221 //glGetQueryivARB_ptr(m_uintQuery[0], GL_QUERY_RESULT_AVAILABLE_ARB, &isAvailable); 222 } 223 224 if (isAvailable == GL_TRUE) 225 { 226 glGetOcclusionQueryuivNV_ptr( m_uintQuery[0], GL_PIXEL_COUNT_NV, NumOfFragments ); 227 //glGetQueryObjectuivARB_ptr( m_uintQuery[0], GL_QUERY_RESULT_ARB, NumOfFragments); 228 228 } 229 229 }
Note: See TracChangeset
for help on using the changeset viewer.