Changeset 120
- Timestamp:
- 06/06/05 18:55:02 (20 years ago)
- Location:
- trunk/VUT
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibility/scripts/GtpVisibility.vcproj
r74 r120 107 107 </File> 108 108 <File 109 RelativePath="..\include\DistanceQueue.h"> 110 </File> 111 <File 109 112 RelativePath="..\src\DummyPreprocessingManager.cpp"> 110 113 </File> … … 145 148 </File> 146 149 <File 147 RelativePath="..\include\DistanceQueue.h">148 </File>149 <File150 150 RelativePath="..\include\FrustumCullingManager.h"> 151 151 </File> -
trunk/VUT/GtpVisibility/src/HierarchyInterface.cpp
r112 r120 8 8 HierarchyInterface::HierarchyInterface(): 9 9 mFrameId(0), mNumTraversedNodes(0), mNumRenderedNodes(0), 10 mSceneRoot(0), mPreviousNode(0), mCurrentTestIdx(0), mUseOptimization( true)10 mSceneRoot(0), mPreviousNode(0), mCurrentTestIdx(0), mUseOptimization(false) 11 11 //, mIsShadowPass(false) 12 12 { -
trunk/VUT/Ogre/include/OgrePlatformHierarchyInterface.h
r115 r120 84 84 /** see set */ 85 85 bool GetOnlyShadowCasters(); 86 /** see set */ 87 bool GetUseOptimization(); 86 88 87 89 protected: 88 /** true if query should test using geomery whenever it is possible, false if89 bounding boxes are always used.90 */91 bool UseOptimization() const;92 93 90 /** materials for visualizing frustum and query culled nodes */ 94 91 void CreateNodeVizMaterials(); -
trunk/VUT/Ogre/resources/VisibilityDemo.overlay
r115 r120 1 Example/VisibilityDemoOverlay 1 template element TextArea(Example/Visibility/Templates/BasicText) 2 { 3 metrics_mode pixels 4 left 5 5 top 5 6 width 180 7 height 30 8 font_name TrebuchetMSBold 9 char_height 16 10 colour_top 0.5 0.7 0.5 11 colour_bottom 0.3 0.5 0.3 12 } 13 14 Example/Visibility/DemoOverlay 2 15 { 3 16 zorder 500 … … 24 37 25 38 26 element TextArea(Example/Visibility/Algorithm) 27 { 28 metrics_mode pixels 39 element TextArea(Example/Visibility/Algorithm): Example/Visibility/Templates/BasicText 40 { 29 41 left 5 30 42 top 5 31 43 width 180 32 height 3033 font_name TrebuchetMSBold34 char_height 1635 44 caption [SPACE] Algorithm 36 colour_top 0.5 0.7 0.5 37 colour_bottom 0.3 0.5 0.3 38 } 39 element TextArea(Example/Visibility/AlgorithmInfo) 40 { 41 metrics_mode pixels 45 } 46 element TextArea(Example/Visibility/AlgorithmInfo): Example/Visibility/Templates/BasicText 47 { 42 48 left 155 43 49 top 5 44 50 width 90 45 51 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/Visibility/Threshold) 54 { 55 metrics_mode pixels 52 caption : 53 } 54 55 element TextArea(Example/Visibility/Threshold): Example/Visibility/Templates/BasicText 56 { 56 57 left 5 57 58 top 20 58 59 width 90 59 60 height 30 60 font_name TrebuchetMSBold61 char_height 1662 61 caption [-][+] Threshold 63 colour_top 0.5 0.7 0.5 64 colour_bottom 0.3 0.5 0.3 65 } 66 element TextArea(Example/Visibility/ThresholdInfo) 67 { 68 metrics_mode pixels 62 } 63 element TextArea(Example/Visibility/ThresholdInfo): Example/Visibility/Templates/BasicText 64 { 69 65 left 155 70 66 top 20 71 67 width 90 72 68 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/Visibility/UseOptimization) 80 { 81 metrics_mode pixels 69 caption : 70 } 71 element TextArea(Example/Visibility/UseOptimization): Example/Visibility/Templates/BasicText 72 { 82 73 left 5 83 74 top 35 84 75 width 90 85 76 height 30 86 font_name TrebuchetMSBold87 char_height 1688 77 caption [O] Optimization 89 colour_top 0.5 0.7 0.5 90 colour_bottom 0.3 0.5 0.3 91 } 92 element TextArea(Example/Visibility/UseOptimizationInfo) 93 { 94 metrics_mode pixels 78 } 79 element TextArea(Example/Visibility/UseOptimizationInfo): Example/Visibility/Templates/BasicText 80 { 95 81 left 155 96 82 top 35 97 83 width 90 98 84 height 30 99 font_name TrebuchetMSBold 100 char_height 16 101 caption : 102 colour_top 0.5 0.7 0.5 103 colour_bottom 0.3 0.5 0.3 104 } 105 element TextArea(Example/Visibility/UseDepthPass) 106 { 107 metrics_mode pixels 85 caption : 86 } 87 element TextArea(Example/Visibility/UseDepthPass): Example/Visibility/Templates/BasicText 88 { 108 89 left 5 109 90 top 50 110 91 width 90 111 92 height 30 112 font_name TrebuchetMSBold113 char_height 16114 93 caption [X] Depth pass 115 colour_top 0.5 0.7 0.5 116 colour_bottom 0.3 0.5 0.3 117 } 118 element TextArea(Example/Visibility/UseDepthPassInfo) 119 { 120 metrics_mode pixels 94 } 95 element TextArea(Example/Visibility/UseDepthPassInfo): Example/Visibility/Templates/BasicText 96 { 121 97 left 155 122 98 top 50 123 99 width 90 124 100 height 30 125 font_name TrebuchetMSBold 126 char_height 16 127 caption : 128 colour_top 0.5 0.7 0.5 129 colour_bottom 0.3 0.5 0.3 101 caption : 130 102 } 131 103 … … 153 125 border_bottomright_uv 0.9961 0.0039 1.0000 0.0000 154 126 155 element TextArea(Example/Visibility/FrustumCulledNodes) 156 { 157 metrics_mode pixels 127 element TextArea(Example/Visibility/FrustumCulledNodes): Example/Visibility/Templates/BasicText 128 { 158 129 left 5 159 130 top 5 160 131 width 180 161 132 height 30 133 caption Frustum Culled Nodes 134 } 135 element TextArea(Example/Visibility/FrustumCulledNodesInfo): Example/Visibility/Templates/BasicText 136 { 137 left 180 138 top 5 139 width 90 140 height 30 141 caption : 142 } 143 element TextArea(Example/Visibility/QueryCulledNodes): Example/Visibility/Templates/BasicText 144 { 145 left 5 146 top 20 147 width 180 148 height 30 149 caption Query Culled Nodes 150 } 151 element TextArea(Example/Visibility/QueryCulledNodesInfo): Example/Visibility/Templates/BasicText 152 { 153 left 180 154 top 20 155 width 90 156 height 30 157 caption : 158 } 159 element TextArea(Example/Visibility/TraversedNodes): Example/Visibility/Templates/BasicText 160 { 161 left 5 162 top 35 163 width 180 164 height 30 165 caption Traversed Nodes 166 } 167 element TextArea(Example/Visibility/TraversedNodesInfo): Example/Visibility/Templates/BasicText 168 { 169 left 180 170 top 35 171 width 90 172 height 30 173 caption : 174 } 175 element TextArea(Example/Visibility/HierarchyNodes): Example/Visibility/Templates/BasicText 176 { 177 left 5 178 top 50 179 width 180 180 height 30 181 caption Hierarchy Nodes 182 } 183 element TextArea(Example/Visibility/HierarchyNodesInfo): Example/Visibility/Templates/BasicText 184 { 185 left 180 186 top 50 187 width 90 188 height 30 189 caption : 190 } 191 element TextArea(Example/Visibility/RenderedNodes): Example/Visibility/Templates/BasicText 192 { 193 left 5 194 top 65 195 width 180 196 height 30 197 caption Rendered Nodes 198 } 199 element TextArea(Example/Visibility/RenderedNodesInfo): Example/Visibility/Templates/BasicText 200 { 201 left 180 202 top 65 203 width 90 204 height 30 205 caption : 206 } 207 element TextArea(Example/Visibility/Objects): Example/Visibility/Templates/BasicText 208 { 209 left 5 210 top 80 211 width 180 212 height 30 213 caption Number of objects 214 } 215 element TextArea(Example/Visibility/ObjectsInfo): Example/Visibility/Templates/BasicText 216 { 217 left 180 218 top 80 219 width 90 220 height 30 221 caption : 222 } 223 element TextArea(Example/Visibility/QueriesIssued): Example/Visibility/Templates/BasicText 224 { 225 left 5 226 top 95 227 width 180 228 height 30 229 caption Queries issued 230 } 231 element TextArea(Example/Visibility/QueriesIssuedInfo): Example/Visibility/Templates/BasicText 232 { 233 left 180 234 top 95 235 width 90 162 236 font_name TrebuchetMSBold 163 char_height 16 164 caption Frustum Culled Nodes 165 colour_top 0.5 0.7 0.5 166 colour_bottom 0.3 0.5 0.3 167 } 168 element TextArea(Example/Visibility/FrustumCulledNodesInfo) 169 { 170 metrics_mode pixels 171 left 180 172 top 5 173 width 90 174 height 30 175 font_name TrebuchetMSBold 176 char_height 16 177 caption : 178 colour_top 0.5 0.7 0.5 179 colour_bottom 0.3 0.5 0.3 180 } 181 element TextArea(Example/Visibility/QueryCulledNodes) 182 { 183 metrics_mode pixels 184 left 5 185 top 20 186 width 180 187 height 30 188 font_name TrebuchetMSBold 189 char_height 16 190 caption Query Culled Nodes 191 colour_top 0.5 0.7 0.5 192 colour_bottom 0.3 0.5 0.3 193 } 194 element TextArea(Example/Visibility/QueryCulledNodesInfo) 195 { 196 metrics_mode pixels 197 left 180 198 top 20 199 width 90 200 height 30 201 font_name TrebuchetMSBold 202 char_height 16 203 caption : 204 colour_top 0.5 0.7 0.5 205 colour_bottom 0.3 0.5 0.3 206 } 207 element TextArea(Example/Visibility/TraversedNodes) 208 { 209 metrics_mode pixels 210 left 5 211 top 35 212 width 180 213 height 30 214 font_name TrebuchetMSBold 215 char_height 16 216 caption Traversed Nodes 217 colour_top 0.5 0.7 0.5 218 colour_bottom 0.3 0.5 0.3 219 } 220 element TextArea(Example/Visibility/TraversedNodesInfo) 221 { 222 metrics_mode pixels 223 left 180 224 top 35 225 width 90 226 height 30 227 font_name TrebuchetMSBold 228 char_height 16 229 caption : 230 colour_top 0.5 0.7 0.5 231 colour_bottom 0.3 0.5 0.3 232 } 233 element TextArea(Example/Visibility/HierarchyNodes) 234 { 235 metrics_mode pixels 236 left 5 237 top 50 238 width 180 239 height 30 240 font_name TrebuchetMSBold 241 char_height 16 242 caption Hierarchy Nodes 243 colour_top 0.5 0.7 0.5 244 colour_bottom 0.3 0.5 0.3 245 } 246 element TextArea(Example/Visibility/HierarchyNodesInfo) 247 { 248 metrics_mode pixels 249 left 180 250 top 50 251 width 90 252 height 30 253 font_name TrebuchetMSBold 254 char_height 16 255 caption : 256 colour_top 0.5 0.7 0.5 257 colour_bottom 0.3 0.5 0.3 258 } 259 element TextArea(Example/Visibility/RenderedNodes) 260 { 261 metrics_mode pixels 262 left 5 263 top 65 264 width 180 265 height 30 266 font_name TrebuchetMSBold 267 char_height 16 268 caption Rendered Nodes 269 colour_top 0.5 0.7 0.5 270 colour_bottom 0.3 0.5 0.3 271 } 272 element TextArea(Example/Visibility/RenderedNodesInfo) 273 { 274 metrics_mode pixels 275 left 180 276 top 65 277 width 90 278 height 30 279 font_name TrebuchetMSBold 280 char_height 16 281 caption : 282 colour_top 0.5 0.7 0.5 283 colour_bottom 0.3 0.5 0.3 284 } 285 element TextArea(Example/Visibility/Objects) 286 { 287 metrics_mode pixels 288 left 5 289 top 80 290 width 180 291 height 30 292 font_name TrebuchetMSBold 293 char_height 16 294 caption Number of objects 295 colour_top 0.5 0.7 0.5 296 colour_bottom 0.3 0.5 0.3 297 } 298 element TextArea(Example/Visibility/ObjectsInfo) 299 { 300 metrics_mode pixels 301 left 180 302 top 80 303 width 90 304 height 30 305 font_name TrebuchetMSBold 306 char_height 16 307 caption : 308 colour_top 0.5 0.7 0.5 309 colour_bottom 0.3 0.5 0.3 310 } 311 element TextArea(Example/Visibility/QueriesIssued) 312 { 313 metrics_mode pixels 314 left 5 315 top 95 316 width 180 317 height 30 318 font_name TrebuchetMSBold 319 char_height 16 320 caption Queries issued 321 colour_top 0.5 0.7 0.5 322 colour_bottom 0.3 0.5 0.3 323 } 324 element TextArea(Example/Visibility/QueriesIssuedInfo) 325 { 326 metrics_mode pixels 327 left 180 328 top 95 329 width 90 330 height 30 331 font_name TrebuchetMSBold 332 char_height 16 333 caption : 334 colour_top 0.5 0.7 0.5 335 colour_bottom 0.3 0.5 0.3 237 caption : 336 238 } 337 239 } 338 240 } 241 242 Example/Visibility/HelpOverlay 243 { 244 zorder 600 245 // Stats block 246 container BorderPanel(Example/Visibility/HelpPanel) 247 { 248 metrics_mode pixels 249 horz_align left 250 vert_align top 251 width 600 252 height 315 253 left 200 254 top 200 255 material Core/StatsBlockCenter 256 //material Example/Visibility/Helpscreen 257 border_size 1 1 1 1 258 border_material Core/StatsBlockBorder 259 border_topleft_uv 0.0000 1.0000 0.0039 0.9961 260 border_top_uv 0.0039 1.0000 0.9961 0.9961 261 border_topright_uv 0.9961 1.0000 1.0000 0.9961 262 border_left_uv 0.0000 0.9961 0.0039 0.0039 263 border_right_uv 0.9961 0.9961 1.0000 0.0039 264 border_bottomleft_uv 0.0000 0.0039 0.0039 0.0000 265 border_bottom_uv 0.0039 0.0039 0.9961 0.0000 266 border_bottomright_uv 0.9961 0.0039 1.0000 0.0000 267 268 container Panel(Example/Visibility/Help/BreakPanel) 269 { 270 metrics_mode pixels 271 left 5 272 top 22 273 width 590 274 height 1 275 material Core/StatsBreak 276 } 277 278 element TextArea(Example/Visibility/Help/Help) 279 { 280 metrics_mode pixels 281 left 5 282 top 5 283 width 90 284 height 30 285 font_name TrebuchetMSBold 286 char_height 19 287 caption Additional Options 288 colour_top 1 1 0.7 289 colour_bottom 1 1 0.7 290 } 291 292 element TextArea(Example/Visibility/Help/ShowHelpInfo): Example/Visibility/Templates/BasicText 293 { 294 left 5 295 top 40 296 width 180 297 height 30 298 caption [F1] Show / Hide this screen 299 } 300 element TextArea(Example/Visibility/Help/StatsInfo): Example/Visibility/Templates/BasicText 301 { 302 left 5 303 top 55 304 width 180 305 height 30 306 caption [F2] Show / Hide stats 307 } 308 element TextArea(Example/Visibility/Help/RecordedInfo): Example/Visibility/Templates/BasicText 309 { 310 left 5 311 top 70 312 width 180 313 height 30 314 caption [F3] Start / End frame recording 315 } 316 element TextArea(Example/Visibility/Help/AppStateInfo): Example/Visibility/Templates/BasicText 317 { 318 left 5 319 top 85 320 width 180 321 height 30 322 caption [F4] Toggle between interactive / recorded walkthrough 323 } 324 element TextArea(Example/Visibility/Help/ScreenshotsInfo): Example/Visibility/Templates/BasicText 325 { 326 left 5 327 top 115 328 width 180 329 height 30 330 caption [F11] Screenshot 331 } 332 element TextArea(Example/Visibility/Help/WriteOutInfo): Example/Visibility/Templates/BasicText 333 { 334 left 5 335 top 130 336 width 180 337 height 30 338 caption [F12] Write screen objects to file 339 } 340 //-- visualization 341 element TextArea(Example/Visibility/Help/VizInfo): Example/Visibility/Templates/BasicText 342 { 343 left 5 344 top 160 345 width 180 346 height 30 347 caption [1] Show / hide visualization 348 } 349 element TextArea(Example/Visibility/Help/NextVizModeInfo): Example/Visibility/Templates/BasicText 350 { 351 left 5 352 top 175 353 width 175 354 height 30 355 caption [2] Toggle visualization mode 356 } 357 element TextArea(Example/Visibility/Help/ZoomVizInfo): Example/Visibility/Templates/BasicText 358 { 359 left 5 360 top 190 361 width 190 362 height 30 363 caption [3][4] Zoom in / out of visualization 364 } 365 element TextArea(Example/Visibility/Help/SceneDetailInfo): Example/Visibility/Templates/BasicText 366 { 367 left 5 368 top 220 369 width 180 370 height 30 371 caption [R] Toggle between solid / wireframe / point based rendering 372 } 373 element TextArea(Example/Visibility/Help/DisplayCameraDetailsInfo): Example/Visibility/Templates/BasicText 374 { 375 left 5 376 top 235 377 width 180 378 height 30 379 caption [P] Show / hide camera details 380 } 381 element TextArea(Example/Visibility/Help/DisplayOctreeInfo): Example/Visibility/Templates/BasicText 382 { 383 left 5 384 top 250 385 width 180 386 height 30 387 caption [T] Show / hide octree 388 } 389 element TextArea(Example/Visibility/Help/UseShadowsInfo): Example/Visibility/Templates/BasicText 390 { 391 left 5 392 top 265 393 width 180 394 height 30 395 caption [S] Show / hide shadows 396 } 397 element TextArea(Example/Visibility/Help/FilterInfo): Example/Visibility/Templates/BasicText 398 { 399 left 5 400 top 280 401 width 180 402 height 30 403 caption [F] toggle filtering method (trilinear, anisotropic, bilinear) 404 } 405 } 406 } -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r118 r120 86 86 87 87 // set no depth write, no color, no lighting material 88 mSceneManager->setPass(solidBox->getTechnique()->getPass(0));89 //SetOcclusionPass();88 //mSceneManager->setPass(solidBox->getTechnique()->getPass(0)); 89 SetOcclusionPass(); 90 90 91 91 solidBox->SetupBoundingBoxVertices(*box); … … 166 166 } 167 167 //----------------------------------------------------------------------- 168 bool PlatformHierarchyInterface::UseOptimization() const169 {170 /* If camera for culling is different from camera for rendering or only solids171 will be rendereded => cannot optimize172 */173 return mUseOptimization && (mCamera == mCullCamera);174 }175 176 //-----------------------------------------------------------------------177 168 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery( 178 169 GtpVisibility::HierarchyNode *node, const bool wasVisible) … … 186 177 // if node is leaf and was visible => will be rendered anyway. 187 178 // In this case we can also test with the real geometry. 188 if (UseOptimization() && wasVisible && IsLeaf(node) ) 179 // If camera for culling is different from camera for rendering or only solids 180 // will be rendereded => cannot optimize 181 if (mUseOptimization && (mCamera == mCullCamera) && wasVisible && IsLeaf(node) ) 189 182 { 190 183 //LogManager::getSingleton().logMessage("render node\n"); … … 240 233 return mOnlyShadowCasters; 241 234 } 235 //----------------------------------------------------------------------- 236 bool PlatformHierarchyInterface::GetUseOptimization() 237 { 238 return mUseOptimization; 239 } 242 240 } // namespace Ogre -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r119 r120 16 16 : 17 17 mVisibilityManager(visManager), 18 mUseDepthPass(false),19 18 mIsDepthPass(false), 20 19 mShowVisualization(false), … … 23 22 mVisualizeCulledNodes(false), 24 23 mSkipTransparents(false), 25 mDelayRenderTransparents(true) 26 { 27 mHierarchyInterface = 28 24 mDelayRenderTransparents(true), 25 mUseDepthPass(true) 26 { 27 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); 29 28 30 29 //mDisplayNodes = true; … … 60 59 VisibilityOctreeSceneManager::~VisibilityOctreeSceneManager() 61 60 { 62 delete mHierarchyInterface; 61 if (mHierarchyInterface) 62 { 63 delete mHierarchyInterface; 64 mHierarchyInterface = NULL; 65 } 63 66 } 64 67 //----------------------------------------------------------------------- … … 66 69 { 67 70 // setting vertex program is not efficient 68 //Pass *usedPass = ((mIsDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass); 71 Pass *usedPass = ((mIsDepthPass && pass->getDepthWriteEnabled() && !pass->hasVertexProgram()) ? mDepthPass : pass); 72 73 /* 69 74 // set depth fill pass only if depth write enabled 70 75 Pass *usedPass = (mIsDepthPass && pass->getDepthWriteEnabled() ? mDepthPass : pass); 71 76 72 if (mIsDepthPass) 73 { 74 // set vertex program of current pass 75 if (pass->hasVertexProgram()) 77 if (mIsDepthPass && pass->hasVertexProgram()) 78 { 79 // set vertex program of current pass to depth pass 80 mDepthPass->setVertexProgram(pass->getVertexProgramName()); 81 82 if (mDepthPass->hasVertexProgram()) 76 83 { 77 mDepthPass->setVertexProgram(pass->getVertexProgramName()); 78 79 if (mDepthPass->hasVertexProgram()) 80 { 81 const GpuProgramPtr& prg = mDepthPass->getVertexProgram(); 82 // Load this program if not done already 83 if (!prg->isLoaded()) 84 prg->load(); 85 // Copy params 86 mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters()); 87 } 84 const GpuProgramPtr& prg = mDepthPass->getVertexProgram(); 85 // Load this program if not done already 86 if (!prg->isLoaded()) 87 prg->load(); 88 // Copy params 89 mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters()); 88 90 } 89 91 else if (mDepthPass->hasVertexProgram()) … … 91 93 mDepthPass->setVertexProgram(""); 92 94 } 93 } 94 95 OctreeSceneManager::setPass(usedPass);95 }*/ 96 97 SceneManager::setPass(usedPass); 96 98 97 99 return usedPass; … … 234 236 // for depth pass: add visible nodes found with the visibility culling 235 237 if (mUseDepthPass) 236 {238 { 237 239 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 238 {240 { 239 241 (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 240 }242 } 241 243 mIsDepthPass = false; 242 244 } 243 245 mSkipTransparents = false; 244 246 … … 249 251 SceneManager::_renderVisibleObjects(); 250 252 251 //WriteLog(); // write out stats253 WriteLog(); // write out stats 252 254 } 253 255 //----------------------------------------------------------------------- … … 351 353 std::stringstream d; 352 354 353 d << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", " 355 d << "Depth pass: " << StringConverter::toString(mUseDepthPass) << ", " 356 << "Delay transparents: " << StringConverter::toString(mDelayRenderTransparents) << ", " 357 << "Use optimization: " << StringConverter::toString(mHierarchyInterface->GetUseOptimization()) << ", " 358 << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << "\n" 354 359 << "Hierarchy nodes: " << mNumOctreeNodes << ", " 355 360 << "Traversed nodes: " << mHierarchyInterface->GetNumTraversedNodes() << ", " … … 358 363 << "Frustum culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumFrustumCulledNodes() << ", " 359 364 << "Queries issued: " << mVisibilityManager->GetCullingManager()->GetNumQueriesIssued() << "\n"; 365 /*<< "avg. FPS: " << mCurrentViewport->getTarget()->getAverageFPS() << ", " 366 << "best FPS: " << mCurrentViewport->getTarget()->getBestFPS() << ", " 367 << "worst FPS: " << mCurrentViewport->getTarget()->getWorstFPS() << ", " 368 << "best frame time: " << mCurrentViewport->getTarget()->getBestFrameTime() << ", " 369 << "worst frame time: " << mCurrentViewport->getTarget()->getWorstFrameTime() << "\n";*/ 360 370 361 371 LogManager::getSingleton().logMessage(d.str()); -
trunk/VUT/Ogre/src/OgreVisibilitySceneManagerDll.cpp
r115 r120 48 48 extern "C" void dllStartPlugin(void) 49 49 { 50 //visEnv = new GtpVisibility::VisibilityEnvironment();50 visEnv = new GtpVisibility::VisibilityEnvironment(); 51 51 visManager = new GtpVisibility::VisibilityManager(visEnv); 52 52 … … 64 64 Root::getSingleton().setSceneManager(ST_EXTERIOR_CLOSE, visibilityTerrainPlugin); 65 65 //Root::getSingleton().setSceneManager(ST_GENERIC, occlusionDotPlugin); 66 67 LogManager::getSingleton().logMessage("registered akira plugins");68 66 } 69 67 //----------------------------------------------------------------------- … … 77 75 78 76 delete visManager; 79 //delete visEnv;77 delete visEnv; 80 78 } 81 79 -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r119 r120 15 15 GtpVisibility::VisibilityManager *visManager): 16 16 mVisibilityManager(visManager), 17 mUseDepthPass(false),18 17 mIsDepthPass(false), 19 18 mShowVisualization(false), … … 22 21 mVisualizeCulledNodes(false), 23 22 mSkipTransparents(false), 24 mDelayRenderTransparents(true) 25 { 26 mHierarchyInterface = 27 28 29 23 mDelayRenderTransparents(true), 24 mUseDepthPass(false) 25 { 26 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); 27 28 //mDisplayNodes = true; 30 29 //mShowBoundingBoxes = true; 31 30 … … 57 56 VisibilityTerrainSceneManager::~VisibilityTerrainSceneManager() 58 57 { 59 delete mHierarchyInterface; 60 } 61 //----------------------------------------------------------------------- 62 Pass *VisibilityTerrainSceneManager::setPass(Pass* pass) 63 { 58 if (mHierarchyInterface) 59 { 60 delete mHierarchyInterface; 61 mHierarchyInterface = NULL; 62 } 63 } 64 //----------------------------------------------------------------------- 65 /*Pass *VisibilityTerrainSceneManager::setPass(Pass* pass) 66 { 67 static bool myLastUsedVertexProgram = false; 68 static bool myLastUsedFragmentProgram = false; 69 64 70 // set depth fill pass only if depth write enabled 65 Pass *usedPass = (mIsDepthPass && pass->getDepthWriteEnabled() ? mDepthPass : pass); 66 67 if (mIsDepthPass) 68 { 69 //if (pass->isTransparent()) return pass; 70 71 // set vertex program of current pass 72 if (pass->hasVertexProgram() && (pass->getVertexProgramName() != mDepthPass->getVertexProgramName())) 73 { 74 mDepthPass->setVertexProgram(pass->getVertexProgramName()); 75 76 if (mDepthPass->hasVertexProgram()) 77 { 78 const GpuProgramPtr& prg = mDepthPass->getVertexProgram(); 79 // Load this program if not done already 80 if (!prg->isLoaded()) prg->load(); 81 // Copy params 82 mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters()); 83 } 84 } 85 else if (mDepthPass->hasVertexProgram()) 86 { 87 mDepthPass->setVertexProgram(""); 88 } 89 } 90 91 TerrainSceneManager::setPass(usedPass); 71 Pass *usedPass = pass; 72 73 if (mIsDepthPass && pass->getDepthWriteEnabled()) 74 { 75 usedPass = mDepthPass; 76 } 77 78 if (mIlluminationStage == IRS_RENDER_TO_TEXTURE) 79 { 80 // Derive a special shadow caster pass from this one 81 usedPass = deriveShadowCasterPass(usedPass); 82 } 83 else if (mIlluminationStage == IRS_RENDER_MODULATIVE_PASS) 84 { 85 usedPass = deriveShadowReceiverPass(usedPass); 86 } 87 88 bool passSurfaceAndLightParams = true; 89 90 // take original pass here 91 if (usedPass->hasVertexProgram()) 92 { 93 mDestRenderSystem->bindGpuProgram(usedPass->getVertexProgram()->_getBindingDelegate()); 94 // bind parameters later since they can be per-object 95 myLastUsedVertexProgram = true; 96 // does the vertex program want surface and light params passed to rendersystem? 97 passSurfaceAndLightParams = usedPass->getVertexProgram()->getPassSurfaceAndLightStates(); 98 } 99 else 100 { 101 // Unbind program? 102 if (myLastUsedVertexProgram) 103 { 104 mDestRenderSystem->unbindGpuProgram(GPT_VERTEX_PROGRAM); 105 myLastUsedVertexProgram = false; 106 } 107 // Set fixed-function vertex parameters 108 } 109 110 if (passSurfaceAndLightParams) 111 { 112 // Set surface reflectance properties, only valid if lighting is enabled 113 if (usedPass->getLightingEnabled()) 114 { 115 mDestRenderSystem->_setSurfaceParams( 116 usedPass->getAmbient(), 117 usedPass->getDiffuse(), 118 usedPass->getSpecular(), 119 usedPass->getSelfIllumination(), 120 usedPass->getShininess(), 121 usedPass->getVertexColourTracking() ); 122 } 123 124 // Dynamic lighting enabled? 125 mDestRenderSystem->setLightingEnabled(usedPass->getLightingEnabled()); 126 } 127 128 // Using a fragment program? 129 if (usedPass->hasFragmentProgram()) 130 { 131 mDestRenderSystem->bindGpuProgram( 132 usedPass->getFragmentProgram()->_getBindingDelegate()); 133 // bind parameters later since they can be per-object 134 myLastUsedFragmentProgram = true; 135 } 136 else 137 { 138 // Unbind program? 139 if (myLastUsedFragmentProgram) 140 { 141 mDestRenderSystem->unbindGpuProgram(GPT_FRAGMENT_PROGRAM); 142 myLastUsedFragmentProgram = false; 143 } 144 145 // Set fixed-function fragment settings 146 147 // Fog (assumes we want pixel fog which is the usual) 148 // New fog params can either be from scene or from material 149 FogMode newFogMode; 150 ColourValue newFogColour; 151 Real newFogStart, newFogEnd, newFogDensity; 152 if (usedPass->getFogOverride()) 153 { 154 // New fog params from material 155 newFogMode = usedPass->getFogMode(); 156 newFogColour = usedPass->getFogColour(); 157 newFogStart = usedPass->getFogStart(); 158 newFogEnd = usedPass->getFogEnd(); 159 newFogDensity = usedPass->getFogDensity(); 160 } 161 else 162 { 163 // New fog params from scene 164 newFogMode = mFogMode; 165 newFogColour = mFogColour; 166 newFogStart = mFogStart; 167 newFogEnd = mFogEnd; 168 newFogDensity = mFogDensity; 169 } 170 mDestRenderSystem->_setFog(newFogMode, newFogColour, newFogDensity, newFogStart, newFogEnd); 171 172 } 173 174 // The rest of the settings are the same no matter whether we use programs or not 175 176 // Set scene blending 177 mDestRenderSystem->_setSceneBlending( 178 usedPass->getSourceBlendFactor(), usedPass->getDestBlendFactor()); 179 180 181 // Texture unit settings 182 183 Pass::TextureUnitStateIterator texIter = usedPass->getTextureUnitStateIterator(); 184 size_t unit = 0; 185 while(texIter.hasMoreElements()) 186 { 187 TextureUnitState* pTex = texIter.getNext(); 188 mDestRenderSystem->_setTextureUnitSettings(unit, *pTex); 189 ++unit; 190 } 191 // Disable remaining texture units 192 mDestRenderSystem->_disableTextureUnitsFrom(usedPass->getNumTextureUnitStates()); 193 194 // Set up non-texture related material settings 195 // Depth buffer settings 196 mDestRenderSystem->_setDepthBufferFunction(usedPass->getDepthFunction()); 197 mDestRenderSystem->_setDepthBufferCheckEnabled(usedPass->getDepthCheckEnabled()); 198 mDestRenderSystem->_setDepthBufferWriteEnabled(usedPass->getDepthWriteEnabled()); 199 mDestRenderSystem->_setDepthBias(usedPass->getDepthBias()); 200 // Alpha-reject settings 201 mDestRenderSystem->_setAlphaRejectSettings( 202 usedPass->getAlphaRejectFunction(), usedPass->getAlphaRejectValue()); 203 // Set colour write mode 204 // Right now we only use on/off, not per-channel 205 bool colWrite = usedPass->getColourWriteEnabled(); 206 mDestRenderSystem->_setColourBufferWriteEnabled(colWrite, colWrite, colWrite, colWrite); 207 // Culling mode 208 mDestRenderSystem->_setCullingMode(usedPass->getCullingMode()); 209 // Shading 210 mDestRenderSystem->setShadingType(usedPass->getShadingMode()); 92 211 93 212 return usedPass; 94 } 213 }*/ 95 214 //----------------------------------------------------------------------- 96 215 void VisibilityTerrainSceneManager::ShowVisualization(Camera *cam) … … 138 257 } 139 258 //----------------------------------------------------------------------- 259 Pass *VisibilityTerrainSceneManager::setPass(Pass* pass) 260 { 261 // setting vertex program is not efficient 262 //Pass *usedPass = ((mIsDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass); 263 // set depth fill pass only if depth write enabled 264 Pass *usedPass = (mIsDepthPass && pass->getDepthWriteEnabled() ? mDepthPass : pass); 265 266 if (mIsDepthPass) 267 { 268 // set vertex program of current pass 269 if (pass->hasVertexProgram()) 270 { 271 mDepthPass->setVertexProgram(pass->getVertexProgramName()); 272 273 if (mDepthPass->hasVertexProgram()) 274 { 275 const GpuProgramPtr& prg = mDepthPass->getVertexProgram(); 276 // Load this program if not done already 277 if (!prg->isLoaded()) 278 prg->load(); 279 // Copy params 280 mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters()); 281 } 282 } 283 else if (mDepthPass->hasVertexProgram()) 284 { 285 mDepthPass->setVertexProgram(""); 286 } 287 } 288 /*else if (mIsItemBufferPass) 289 { 290 usedPass = mItemBufferPass; 291 }*/ 292 SceneManager::setPass(usedPass); 293 294 return usedPass; 295 } 296 //----------------------------------------------------------------------- 140 297 void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 141 298 { … … 232 389 mIsDepthPass = false; 233 390 } 391 234 392 mSkipTransparents = false; 235 393 … … 342 500 std::stringstream d; 343 501 344 d << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", " 502 d << "Depth pass: " << StringConverter::toString(mUseDepthPass) << ", " 503 << "Delay transparents: " << StringConverter::toString(mDelayRenderTransparents) << ", " 504 << "Use optimization: " << StringConverter::toString(mHierarchyInterface->GetUseOptimization()) << ", " 505 << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", " 345 506 << "Hierarchy nodes: " << mNumOctreeNodes << ", " 346 507 << "Traversed nodes: " << mHierarchyInterface->GetNumTraversedNodes() << ", " -
trunk/VUT/work/TestCullingTerrain/TerrainMouseQueryListener.cpp
r115 r120 13 13 14 14 15 Real timeDelay = 0; 16 #define KEY_PRESSED(_key,_timeDelay, _macro) \ 15 #define KEY_PRESSED(_key, _timeDelay, _macro) \ 17 16 { \ 18 if (mInputDevice->isKeyDown(_key) && timeDelay <= 0) \17 if (mInputDevice->isKeyDown(_key) && mTimeDelay <= 0) \ 19 18 { \ 20 timeDelay = _timeDelay; \19 mTimeDelay = _timeDelay; \ 21 20 _macro ; \ 22 21 } \ … … 41 40 mCamera(cam), 42 41 mWindow(win), 43 mStatsOn(true),44 42 mNumScreenShots(0), 45 mTime UntilNextToggle(0),43 mTimeDelay(0), 46 44 mSceneDetailIndex(0), 47 45 mMoveScale(0.0f), … … 51 49 mFiltering(TFO_BILINEAR), 52 50 mGUIRenderer(renderer), 53 mShutdownRequested(false),54 mLMouseDown(false),55 mRMouseDown(false),56 51 mSceneMgr(sceneManager), 57 52 mCurrentObject(NULL), … … 60 55 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 61 56 //mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING), 57 mNodeVizMode(NODEVIZ_NONE), 58 mVizCameraHeight(Real(2500.0)), 59 mCamNode(camNode), 60 mAppState(WALKTHROUGH), 61 mCurrentFrame(0), 62 mTimeElapsed(0), 63 mRotateSpeed(72), 64 mMoveSpeed(50), 65 mVizCamera(vizCamera), 66 mStatsOn(true), 67 mShutdownRequested(false), 68 mLMouseDown(false), 69 mRMouseDown(false), 62 70 mShowOctree(false), 63 71 mUseDepthPass(false), 64 72 mUseOptimization(true), 65 mVizCamera(vizCamera),66 73 mShowVisualization(false), 67 mNodeVizMode(NODEVIZ_NONE),68 mVizCameraHeight(Real(2500.0)),69 mCamNode(camNode),70 74 mCullCamera(false), 71 mAppState(WALKTHROUGH),72 mCurrentFrame(0),73 75 mRecord(false), 74 mTimeElapsed(0),75 76 mUseShadows(false), 76 mVisualizeCulledNodes(false), 77 mRotateSpeed(72), 78 mMoveSpeed(50) 79 { 80 mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay"); 81 82 mInputDevice = PlatformManager::getSingleton().createInputReader(); 77 mShowHelp(false), 78 mDisplayCameraDetails(false), 79 mVisualizeCulledNodes(false) 80 { 81 mInputDevice = PlatformManager::getSingleton().createInputReader(); 83 82 mInputDevice->initialise(win, true, true); 84 83 85 showDebugOverlay(true); 86 87 // Register this so that we get mouse events. 88 /*mEventProcessor->addMouseListener(this); 84 /* 85 mEventProcessor->addMouseListener(this); 89 86 mEventProcessor->addMouseMotionListener(this); 90 87 mEventProcessor->addKeyListener(this); … … 94 91 mRayQueryExecutor = new RayQueryExecutor(mSceneMgr); 95 92 96 //-- show visibility overlay 97 Overlay* pOver = OverlayManager::getSingleton().getByName("Example/VisibilityDemoOverlay"); 98 93 mHelpOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/HelpOverlay"); 94 mDebugOverlay = OverlayManager::getSingleton().getByName("Core/DebugOverlay"); 95 96 97 //-- visibility culling stats overlay 98 mCullStatsOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/DemoOverlay"); 99 99 100 mAlgorithmInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/AlgorithmInfo"); 100 101 mThresholdInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/ThresholdInfo"); … … 121 122 mUseDepthPassInfo->setCaption(": false"); 122 123 mQueriesIssuedInfo->setCaption(": 0"); 123 124 pOver->show(); 125 124 125 // show stats overlays 126 showStats(true); 127 //mHelpOverlay->show(); 126 128 127 129 // set culling algorithm type 128 130 setAlgorithm(mCurrentAlgorithm); 129 131 130 131 132 // set scene manager options 132 133 mSceneMgr->setOption("UseOptimization", &mUseOptimization); 133 bool delayedRendering = !mUseOptimization; 134 mSceneMgr->setOption("DelayRenderTransparents", &delayedRendering); 134 135 // apply delayed rendering (i.e., transparents after hierarchical culling pass) 136 // only if optimization is not used 137 bool delayRenderTransparents = !mUseOptimization; 138 139 mSceneMgr->setOption("DelayRenderTransparents", &delayRenderTransparents); 135 140 mSceneMgr->setOption("UseDepthPass", &mUseDepthPass); 141 136 142 mSceneMgr->setOption("ShowOctree", &mShowOctree); 137 143 mSceneMgr->setOption("CullCamera", &mCullCamera); … … 229 235 230 236 //-- setup what is needed for immediate mouse/key movement 231 if (mTime UntilNextToggle>= 0)232 mTime UntilNextToggle-= evt.timeSinceLastFrame;237 if (mTimeDelay >= 0) 238 mTimeDelay -= evt.timeSinceLastFrame; 233 239 234 240 // If this is the first frame, pick a speed … … 329 335 return false; 330 336 331 if (timeDelay >= 0) 332 timeDelay -= evt.timeSinceLastFrame; 333 334 KEY_PRESSED(KC_SPACE, 0.3, nextAlgorithm()); 335 336 KEY_PRESSED(KC_O, 0.3, toggleUseOptimization()); 337 KEY_PRESSED(KC_T, 0.3, toggleShowOctree()); 338 KEY_PRESSED(KC_X, 0.3, toggleUseDepthPass()); 339 KEY_PRESSED(KC_1, 0.3, toggleShowViz()); 340 KEY_PRESSED(KC_2, 0.3, nextNodeVizMode()); 341 342 KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10)); 343 KEY_PRESSED(KC_ADD, 0, changeThreshold(10)); 344 345 KEY_PRESSED(KC_4, 0, zoomVizCamera(50)); 346 KEY_PRESSED(KC_5, 0, zoomVizCamera(-50)); 347 348 KEY_PRESSED(KC_F1, 0.3, nextAppState()); 349 KEY_PRESSED(KC_F2, 0.3, toggleRecord()); 350 KEY_PRESSED(KC_F3, 0.3, mTerrainContentGenerator->WriteObjects(objects_out_filename)); 351 KEY_PRESSED(KC_F4, 0.3, toggleUseShadows()); 352 //KEY_PRESSED(KC_F3, 0.3, writeFrames()); 353 //KEY_PRESSED(KC_F4, 0.3, loadFrames()); 354 355 updateStats(); 337 updateStats(); 356 338 357 339 return true; … … 408 390 } 409 391 ifstr.close(); 410 }411 //-----------------------------------------------------------------------412 void TerrainMouseQueryListener::setAppState(int state)413 {414 mAppState = state;415 392 } 416 393 //----------------------------------------------------------------------- … … 608 585 609 586 if (mUseDepthPass) 587 { 610 588 mUseDepthPassInfo->setCaption(": true"); 589 } 611 590 else 591 { 612 592 mUseDepthPassInfo->setCaption(": false"); 593 } 613 594 } 614 595 //----------------------------------------------------------------------- … … 673 654 mNodeVizMode = (mNodeVizMode + 1) % NODEVIZ_MODES_NUM; 674 655 675 bool renderNodesForViz = (mNodeVizMode == NODEVIZ_RENDER_NODES) || (mNodeVizMode == NODEVIZ_RENDER_NODES_AND_CONTENT); 656 bool renderNodesForViz = (mNodeVizMode == NODEVIZ_RENDER_NODES) || 657 (mNodeVizMode == NODEVIZ_RENDER_NODES_AND_CONTENT); 676 658 bool renderNodesContentForViz = (mNodeVizMode == NODEVIZ_RENDER_NODES_AND_CONTENT); 677 659 //bool renderNodesContentForViz = mNodeVizMode == NODEVIZ_RENDER_GEOMETRY; … … 752 734 bool TerrainMouseQueryListener::processUnbufferedKeyInput(const FrameEvent& evt) 753 735 { 754 if (mInputDevice->isKeyDown(KC_A)) 736 if (mInputDevice->isKeyDown(KC_ESCAPE)) 737 { 738 return false; 739 } 740 741 /* Move camera forward by keypress. */ 742 if (mInputDevice->isKeyDown(KC_UP)) 743 { 744 mTranslateVector.z = -mMoveScale; 745 } 746 747 /* Move camera backward by keypress. */ 748 if (mInputDevice->isKeyDown(KC_DOWN)) 755 749 { 756 // Move camera left 757 mTranslateVector.x = -mMoveScale; 758 } 759 760 if (mInputDevice->isKeyDown(KC_D)) 761 { 762 // Move camera RIGHT 763 mTranslateVector.x = mMoveScale; 764 } 765 766 /* Move camera forward by keypress. */ 767 if (mInputDevice->isKeyDown(KC_UP) || mInputDevice->isKeyDown(KC_W) ) 768 { 769 mTranslateVector.z = -mMoveScale; 770 } 771 772 /* Move camera backward by keypress. */ 773 if (mInputDevice->isKeyDown(KC_DOWN) || mInputDevice->isKeyDown(KC_S) ) 774 { 775 mTranslateVector.z = mMoveScale; 776 } 777 778 if (mInputDevice->isKeyDown(KC_PGUP)) 779 { 780 // Move camera up 781 mTranslateVector.y = mMoveScale; 782 } 783 784 if (mInputDevice->isKeyDown(KC_PGDOWN)) 785 { 786 // Move camera down 787 mTranslateVector.y = -mMoveScale; 750 mTranslateVector.z = mMoveScale; 788 751 } 789 752 … … 798 761 } 799 762 800 if( mInputDevice->isKeyDown( KC_ESCAPE) ) 801 { 802 return false; 803 } 804 805 if (mInputDevice->isKeyDown(KC_F) && mTimeUntilNextToggle <= 0) 806 { 807 mStatsOn = !mStatsOn; 808 showDebugOverlay(mStatsOn); 809 810 mTimeUntilNextToggle = 1; 811 } 812 if (mInputDevice->isKeyDown(KC_T) && mTimeUntilNextToggle <= 0) 813 { 814 switch(mFiltering) 815 { 816 case TFO_BILINEAR: 817 mFiltering = TFO_TRILINEAR; 818 mAniso = 1; 819 break; 820 case TFO_TRILINEAR: 821 mFiltering = TFO_ANISOTROPIC; 822 mAniso = 8; 823 break; 824 case TFO_ANISOTROPIC: 825 mFiltering = TFO_BILINEAR; 826 mAniso = 1; 827 break; 828 default: 829 break; 830 } 831 MaterialManager::getSingleton().setDefaultTextureFiltering(mFiltering); 832 MaterialManager::getSingleton().setDefaultAnisotropy(mAniso); 833 834 835 showDebugOverlay(mStatsOn); 836 837 mTimeUntilNextToggle = 1; 838 } 839 840 if (mInputDevice->isKeyDown(KC_SYSRQ) && mTimeUntilNextToggle <= 0) 841 { 842 char tmp[20]; 843 sprintf(tmp, "screenshot_%d.png", ++mNumScreenShots); 844 mWindow->writeContentsToFile(tmp); 845 mTimeUntilNextToggle = 0.5; 846 mWindow->setDebugText(String("Wrote ") + tmp); 847 } 848 849 if (mInputDevice->isKeyDown(KC_R) && mTimeUntilNextToggle <=0) 850 { 851 mSceneDetailIndex = (mSceneDetailIndex+1)%3 ; 852 switch(mSceneDetailIndex) { 853 case 0 : mCamera->setDetailLevel(SDL_SOLID) ; break ; 854 case 1 : mCamera->setDetailLevel(SDL_WIREFRAME) ; break ; 855 case 2 : mCamera->setDetailLevel(SDL_POINTS) ; break ; 856 } 857 mTimeUntilNextToggle = 0.5; 858 } 859 860 static bool displayCameraDetails = false; 861 if (mInputDevice->isKeyDown(KC_P) && mTimeUntilNextToggle <= 0) 862 { 863 displayCameraDetails = !displayCameraDetails; 864 mTimeUntilNextToggle = 0.5; 865 if (!displayCameraDetails) 866 mWindow->setDebugText(""); 867 } 868 if (displayCameraDetails) 763 KEY_PRESSED(KC_SPACE, 0.3, nextAlgorithm()); 764 KEY_PRESSED(KC_F, 0.3, nextFilter()); 765 KEY_PRESSED(KC_R, 0.3, nextSceneDetailLevel()); 766 767 KEY_PRESSED(KC_P, 0.3, toggleDisplayCameraDetails()); 768 KEY_PRESSED(KC_O, 0.3, toggleUseOptimization()); 769 KEY_PRESSED(KC_T, 0.3, toggleShowOctree()); 770 KEY_PRESSED(KC_X, 0.3, toggleUseDepthPass()); 771 KEY_PRESSED(KC_S, 0.3, toggleUseShadows()); 772 773 KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10)); 774 KEY_PRESSED(KC_ADD, 0, changeThreshold(10)); 775 776 //-- visualization 777 KEY_PRESSED(KC_1, 0.3, toggleShowViz()); 778 KEY_PRESSED(KC_2, 0.3, nextNodeVizMode()); 779 KEY_PRESSED(KC_3, 0, zoomVizCamera(50)); 780 KEY_PRESSED(KC_4, 0, zoomVizCamera(-50)); 781 782 KEY_PRESSED(KC_F1, 0.3, toggleShowHelp()); 783 KEY_PRESSED(KC_F2, 0.3, toggleShowStats()); 784 KEY_PRESSED(KC_F3, 0.3, nextAppState()); 785 786 KEY_PRESSED(KC_F10, 0.3, toggleRecord()); 787 KEY_PRESSED(KC_F11, 0.3, takeScreenShot()); 788 KEY_PRESSED(KC_F12, 0.3, mTerrainContentGenerator->WriteObjects(objects_out_filename)); 789 //KEY_PRESSED(KC_F3, 0.3, writeFrames()); 790 //KEY_PRESSED(KC_F4, 0.3, loadFrames()); 791 792 if (mDisplayCameraDetails) 869 793 { 870 794 // Print camera details … … 877 801 } 878 802 //----------------------------------------------------------------------- 803 void TerrainMouseQueryListener::nextFilter() 804 { 805 switch(mFiltering) 806 { 807 case TFO_BILINEAR: 808 mFiltering = TFO_TRILINEAR; 809 mAniso = 1; 810 break; 811 case TFO_TRILINEAR: 812 mFiltering = TFO_ANISOTROPIC; 813 mAniso = 8; 814 break; 815 case TFO_ANISOTROPIC: 816 mFiltering = TFO_BILINEAR; 817 mAniso = 1; 818 break; 819 default: 820 break; 821 } 822 823 MaterialManager::getSingleton().setDefaultTextureFiltering(mFiltering); 824 MaterialManager::getSingleton().setDefaultAnisotropy(mAniso); 825 826 showStats(mStatsOn); 827 } 828 //----------------------------------------------------------------------- 829 void TerrainMouseQueryListener::nextSceneDetailLevel() 830 { 831 mSceneDetailIndex = (mSceneDetailIndex+1)%3 ; 832 switch(mSceneDetailIndex) 833 { 834 case 0 : mCamera->setDetailLevel(SDL_SOLID) ; break ; 835 case 1 : mCamera->setDetailLevel(SDL_WIREFRAME) ; break ; 836 case 2 : mCamera->setDetailLevel(SDL_POINTS) ; break ; 837 } 838 } 839 //----------------------------------------------------------------------- 840 void TerrainMouseQueryListener::takeScreenShot() 841 { 842 char tmp[20]; 843 sprintf(tmp, "screenshot_%d.png", ++mNumScreenShots); 844 mWindow->writeContentsToFile(tmp); 845 mWindow->setDebugText(String("Wrote ") + tmp); 846 } 847 //----------------------------------------------------------------------- 848 void TerrainMouseQueryListener::toggleDisplayCameraDetails() 849 { 850 mDisplayCameraDetails = !mDisplayCameraDetails; 851 852 if (!mDisplayCameraDetails) 853 mWindow->setDebugText(""); 854 } 855 //----------------------------------------------------------------------- 879 856 bool TerrainMouseQueryListener::processUnbufferedMouseInput(const FrameEvent& evt) 880 857 { … … 897 874 return true; 898 875 } 899 900 void TerrainMouseQueryListener::show DebugOverlay(bool show)901 { 902 if (mDebugOverlay )876 //----------------------------------------------------------------------- 877 void TerrainMouseQueryListener::showStats(bool show) 878 { 879 if (mDebugOverlay && mCullStatsOverlay) 903 880 { 904 881 if (show) 905 882 { 906 883 mDebugOverlay->show(); 884 mCullStatsOverlay->show(); 907 885 } 908 886 else 909 887 { 910 888 mDebugOverlay->hide(); 889 mCullStatsOverlay->hide(); 911 890 } 912 891 } 913 892 } 914 915 916 917 893 //----------------------------------------------------------------------- 894 void TerrainMouseQueryListener::toggleShowStats() 895 { 896 mStatsOn = !mStatsOn; 897 898 showStats(mStatsOn); 899 } 900 //----------------------------------------------------------------------- 901 void TerrainMouseQueryListener::toggleShowHelp() 902 { 903 mShowHelp = !mShowHelp; 904 905 if (mShowHelp) 906 { 907 mHelpOverlay->show(); 908 } 909 else 910 { 911 mHelpOverlay->hide(); 912 } 913 } 914 915 -
trunk/VUT/work/TestCullingTerrain/TerrainMouseQueryListener.h
r115 r120 71 71 //enum {NODEVIZ_NONE, NODEVIZ_RENDER_GEOMETRY, NODEVIZ_MODES_NUM}; 72 72 73 void nextAlgorithm(); 74 void changeThreshold(int incr); 75 void updateStats(); 76 77 void toggleUseOptimization(); 78 void toggleShowOctree(); 79 void toggleUseDepthPass(); 80 void toggleShowViz(); 81 void nextNodeVizMode(); 82 void toggleRecord(); 83 84 void zoomVizCamera(int zoom); 73 void zoomVizCamera(int zoom); 85 74 86 75 void addFrameInfo(SceneNode *camNode, Real timeElapsed); 87 76 void setCurrentFrameInfo(Real timeElapsed); 88 77 89 void setAppState(int state);90 void nextAppState();91 92 78 void setAlgorithm(int algorithm); 93 79 … … 97 83 void loadFrames(); 98 84 99 void toggleUseShadows();100 85 101 86 … … 106 91 bool processUnbufferedMouseInput(const FrameEvent& evt); 107 92 108 void showDebugOverlay(bool show); 93 void showStats(bool show); 94 95 void updateStats(); 96 97 void toggleShowHelp(); 98 void toggleShowStats(); 99 100 void toggleUseShadows(); 101 void toggleDisplayCameraDetails(); 102 void takeScreenShot(); 103 void nextSceneDetailLevel(); 104 void nextFilter(); 105 void nextAlgorithm(); 106 void nextNodeVizMode(); 107 void nextAppState(); 108 void changeThreshold(int incr); 109 110 void toggleUseOptimization(); 111 void toggleShowOctree(); 112 void toggleUseDepthPass(); 113 void toggleShowViz(); 114 void toggleRecord(); 109 115 110 116 protected: … … 114 120 void Clamp2Terrain(); 115 121 116 bool mLMouseDown, mRMouseDown; // True if the mouse buttons are down 117 SceneManager *mSceneMgr; // A pointer to the scene manager 122 SceneManager *mSceneMgr; // A pointer to the scene manager 118 123 119 124 CEGUI::Renderer *mGUIRenderer; // cegui renderer 120 125 121 bool mShutdownRequested;122 126 int mCurrentAlgorithm; 123 127 int mVisibilityThreshold; 124 128 // the current frame number 129 int mCurrentFrame; 130 // the current application state 131 int mAppState; 132 // The number of objects on the screen 133 int mObjectCount; 134 // visualization mode 135 int mNodeVizMode; 136 137 SceneNode *mCurrentObject; // the newly created object 138 125 139 OverlayElement *mAlgorithmInfo; 126 140 OverlayElement *mThresholdInfo; … … 135 149 OverlayElement *mQueriesIssuedInfo; 136 150 137 SceneNode *mCurrentObject; // the newly created object138 int mObjectCount; // The number of objects on the screen139 140 151 RayQueryExecutor *mRayQueryExecutor; 141 152 TerrainContentGenerator *mTerrainContentGenerator; … … 145 156 bool mUseDepthPass; 146 157 bool mShowVisualization; 147 int mNodeVizMode;148 158 bool mCullCamera; 159 bool mRecord; 160 bool mUseShadows; 161 bool mVisualizeCulledNodes; 162 bool mShowHelp; 163 bool mStatsOn; 164 bool mLMouseDown, mRMouseDown; // True if the mouse buttons are down 165 bool mShutdownRequested; 166 bool mDisplayCameraDetails; 149 167 150 168 Real mVizCameraHeight; … … 156 174 std::vector<frame_info> mFrameInfo; 157 175 158 int mCurrentFrame;159 // the current application state160 int mAppState;161 bool mRecord;162 176 Real mTimeElapsed; 163 bool mUseShadows;164 165 bool mVisualizeCulledNodes;166 167 168 177 //EventProcessor* mEventProcessor; 169 178 InputReader* mInputDevice; … … 172 181 Vector3 mTranslateVector; 173 182 RenderWindow* mWindow; 174 bool mStatsOn;175 bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn;183 184 //bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 176 185 unsigned int mNumScreenShots; 177 float mMoveScale; 186 int mSceneDetailIndex; 187 int mAniso; 188 189 float mMoveScale; 178 190 Degree mRotScale; 179 191 // just to stop toggles flipping too fast 180 Real mTime UntilNextToggle;192 Real mTimeDelay; 181 193 Radian mRotX, mRotY; 182 194 TextureFilterOptions mFiltering; 183 int mAniso; 184 185 int mSceneDetailIndex; 186 Real mMoveSpeed; 195 196 Real mMoveSpeed; 187 197 Degree mRotateSpeed; 188 Overlay* mDebugOverlay; 198 199 Overlay* mDebugOverlay; 200 Overlay* mHelpOverlay; 201 Overlay* mCullStatsOverlay; 189 202 }; 190 203 -
trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp
r115 r120 163 163 164 164 // the objects are generated on the whole terrain 165 mTerrainContentGenerator->GenerateScene(1500, "robot"); 165 166 //mTerrainContentGenerator->GenerateScene(1500, "athene"); 166 mTerrainContentGenerator->GenerateScene(1500, "robot"); 167 // mTerrainContentGenerator->GenerateScene(500, "ninja"); 167 //mTerrainContentGenerator->GenerateScene(500, "ninja"); 168 168 } 169 169 … … 192 192 mTerrainFrameListener = new TerrainMouseQueryListener(mWindow, mCamera, mSceneMgr, 193 193 mGUIRenderer, mTerrainContentGenerator, mVizCamera, mCamNode); 194 mTerrainFrameListener->showDebugOverlay(true);194 195 195 mRoot->addFrameListener(mTerrainFrameListener); 196 196 }
Note: See TracChangeset
for help on using the changeset viewer.