Changeset 3246 for GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
- Timestamp:
- 01/04/09 21:48:45 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3245 r3246 113 113 /// max depth where candidates for tighter bounds are searched 114 114 int maxDepthForTestingChildren = 3; 115 115 /// use full resolution for ssao or half 116 116 bool ssaoUseFullResolution = false; 117 117 … … 140 140 141 141 ViewCellsTree *viewCellsTree = NULL; 142 ViewCell *viewCell = NULL; 142 143 143 144 static int globalVisibleId = 0; 144 145 145 ViewCell *viewCell = NULL;146 146 147 147 … … 255 255 bool useLenseFlare = true; 256 256 257 bool usePvs = false; 258 259 257 260 PerfTimer frameTimer, algTimer; 258 261 /// the performance graph window … … 263 266 static Matrix4x4 invTrafo = IdentityMatrix(); 264 267 268 float mouseMotion = 0.2f; 269 265 270 266 271 ////////////// 267 //-- algorithm parameters272 //-- chc++ algorithm parameters 268 273 269 274 /// the pixel threshold where a node is still considered invisible … … 356 361 SceneQuery *GetOrCreateSceneQuery(); 357 362 358 void RenderPvs(); 363 void LoadPvs(); 364 365 void LoadVisibilitySolution(); 366 367 void RenderViewCell(); 359 368 360 369 … … 419 428 env.GetFloatParam(string("keyForwardMotion"), keyForwardMotion); 420 429 env.GetFloatParam(string("keyRotation"), keyRotation); 430 env.GetFloatParam(string("mouseMotion"), mouseMotion); 421 431 env.GetFloatParam(string("tempCohFactor"), ssaoTempCohFactor); 422 432 env.GetFloatParam(string("turbitity"), turbitity); … … 443 453 env.GetStringParam(string("filename"), filename); 444 454 env.GetStringParam(string("visibilitySolution"), visibilitySolution); 455 456 env.GetBoolParam(string("usePvs"), usePvs); 445 457 446 458 //env.GetStringParam(string("modelPath"), model_path); … … 474 486 cout << "stats filename: " << statsFilename << endl; 475 487 cout << "filename: " << filename << endl; 488 cout << "use PVS: " << usePvs << endl; 476 489 cout << "visibilitySolution: " << visibilitySolution << endl; 477 490 … … 558 571 559 572 //LoadModel("fisch.dem", dynamicObjects); 560 LoadModel("hbuddha.dem", dynamicObjects);573 //LoadModel("hbuddha.dem", dynamicObjects); 561 574 562 575 //LoadModel("venusm.dem", dynamicObjects); … … 568 581 resourceManager->mUseSpecialColors = false; 569 582 583 /* 570 584 buddha = dynamicObjects.back(); 571 585 … … 594 608 dynamicObjects.push_back(ent); 595 609 } 596 610 */ 597 611 598 612 /* int cityEntities = LoadModel("vienna_full_hp.dem", dynamicObjects); … … 619 633 /// set the depth of the bvh depending on the triangles per leaf node 620 634 bvh->SetVirtualLeaves(trianglesPerVirtualLeaf); 621 622 ///////////623 //-- load the visibility solution624 625 const string vis_filename =626 string(model_path + visibilitySolution + ".vis");627 628 VisibilitySolutionLoader visLoader;629 630 viewCellsTree = visLoader.Load(vis_filename, bvh);631 632 635 633 636 // set far plane based on scene extent … … 753 756 void InitGLstate() 754 757 { 755 glClearColor(0.4f, 0.4f, 0.4f, 1 .0f);758 glClearColor(0.4f, 0.4f, 0.4f, 1e20f); 756 759 757 760 glPixelStorei(GL_UNPACK_ALIGNMENT, 1); … … 1063 1066 void MainLoop() 1064 1067 { 1065 Matrix4x4 oldTrafo = buddha->GetTransform()->GetMatrix(); 1066 Vector3 buddhaPos = motionPath->GetCurrentPosition(); 1067 Matrix4x4 trafo = TranslationMatrix(buddhaPos); 1068 1069 buddha->GetTransform()->SetMatrix(trafo); 1070 1071 #if TODO 1072 /*for (int i = 0; i < 10; ++ i) 1073 { 1074 SceneEntity *ent = dynamicObjects[i]; 1075 Vector3 newPos = ent->GetWorldCenter(); 1076 1077 if (GetOrCreateSceneQuery()->CalcIntersection(newPos)) 1068 if (buddha) 1069 { 1070 Matrix4x4 oldTrafo = buddha->GetTransform()->GetMatrix(); 1071 Vector3 buddhaPos = motionPath->GetCurrentPosition(); 1072 Matrix4x4 trafo = TranslationMatrix(buddhaPos); 1073 1074 buddha->GetTransform()->SetMatrix(trafo); 1075 1076 #if TODO // drop objects on ground floor 1077 for (int i = 0; i < 10; ++ i) 1078 1078 { 1079 Matrix4x4 mat = TranslationMatrix(newPos - ent->GetCenter()); 1080 ent->GetTransform()->SetMatrix(mat); 1079 SceneEntity *ent = dynamicObjects[i]; 1080 Vector3 newPos = ent->GetWorldCenter(); 1081 1082 if (GetOrCreateSceneQuery()->CalcIntersection(newPos)) 1083 { 1084 Matrix4x4 mat = TranslationMatrix(newPos - ent->GetCenter()); 1085 ent->GetTransform()->SetMatrix(mat); 1086 } 1081 1087 } 1082 }*/1083 1088 #endif 1084 1089 1085 1090 1086 /////////////////////////1087 //-- update animations1088 1089 //const float rotAngle = M_PI * 1e-3f;1090 const float rotAngle = 1.0f * M_PI / 180.0f;1091 1092 Matrix4x4 rotMatrix = RotationZMatrix(rotAngle);1093 dynamicObjects[1]->GetTransform()->MultMatrix(rotMatrix);1094 1095 motionPath->Move(0.01f);1096 1091 ///////////////////////// 1092 //-- update animations 1093 1094 //const float rotAngle = M_PI * 1e-3f; 1095 const float rotAngle = 1.0f * M_PI / 180.0f; 1096 1097 Matrix4x4 rotMatrix = RotationZMatrix(rotAngle); 1098 dynamicObjects[1]->GetTransform()->MultMatrix(rotMatrix); 1099 1100 motionPath->Move(0.01f); 1101 } 1097 1102 1098 1103 … … 1181 1186 glEnableClientState(GL_VERTEX_ARRAY); 1182 1187 1188 if (usePvs) 1189 { 1190 if (!viewCellsTree) LoadVisibilitySolution(); 1191 LoadPvs(); 1192 } 1193 1183 1194 // render with the specified method (forward rendering, forward + depth, deferred) 1184 1195 switch (renderMethod) … … 1260 1271 else 1261 1272 { 1262 RenderPvs();1263 1264 1273 // actually render the scene geometry using the specified algorithm 1265 1274 traverser->RenderScene(); … … 1283 1292 const int sunVisiblePixels = useLenseFlare && useDeferred ? TestSunVisible() : 0; 1284 1293 1294 1285 1295 1286 1296 /////////////// … … 1574 1584 // make a snapshot of the current frame 1575 1585 makeSnapShot = true; 1586 break; 1587 case '.': 1588 // enable / disable view cells 1589 usePvs = !usePvs; 1590 if (!usePvs) SceneEntity::SetGlobalVisibleId(-1); 1576 1591 break; 1577 1592 default: … … 1829 1844 camera->Pitch(eyeXAngle); 1830 1845 1831 pos += horView * (yMotionBegin - y) * 0.2f;1846 pos += horView * (yMotionBegin - y) * mouseMotion; 1832 1847 1833 1848 camera->SetPosition(pos); … … 1897 1912 rVec = rot * rVec; 1898 1913 1899 pos -= rVec * (x - horizontalMotionBegin) * 0.1f;1900 pos[2] += (verticalMotionBegin - y) * 0.1f;1914 pos -= rVec * (x - horizontalMotionBegin) * mouseMotion; 1915 pos[2] += (verticalMotionBegin - y) * mouseMotion; 1901 1916 1902 1917 camera->SetPosition(pos); … … 1960 1975 void DisplayVisualization() 1961 1976 { 1977 // render current view cell 1978 if (usePvs) RenderViewCell(); 1979 1980 visualization->SetViewCell(usePvs ? viewCell : NULL); 1962 1981 visualization->SetFrameId(traverser->GetCurrentFrameId()); 1963 visualization->SetViewCell(viewCell);1982 1964 1983 1965 1984 Begin2D(); … … 2229 2248 sprintf(msg[i ++], "multiqueries: %d, tight bounds: %d, render queue: %d", 2230 2249 useMultiQueries, useTightBounds, useRenderQueue); 2231 sprintf(msg[i ++], "render technique: %s, SSAO: %d", renderMethodStr[renderMethod], useAdvancedShading);2250 sprintf(msg[i ++], "render technique: %s, use pvss: %d", renderMethodStr[renderMethod], usePvs); 2232 2251 sprintf(msg[i ++], "triangles per virtual leaf: %5d", trianglesPerVirtualLeaf); 2233 2252 sprintf(msg[i ++], "assumed visible frames: %4d, max batch size: %4d", … … 2267 2286 sprintf(msg[i ++], "traversed: %5d, frustum culled: %5d, query culled: %5d", 2268 2287 traversedNodes, frustumCulledNodes, queryCulledNodes); 2269 sprintf(msg[i ++], "issued queries: %5d, render State changes: %5d, render batches: %5d",2288 sprintf(msg[i ++], "issued queries: %5d, renderstate changes: %5d, render batches: %5d", 2270 2289 issuedQueries, stateChanges, numBatches); 2271 2290 … … 2531 2550 tech.Init(); 2532 2551 2533 //tech.SetLightingEnabled(false);2534 //tech.SetDepthWriteEnabled(false);2535 2536 2552 tech.SetEmmisive(RgbaColor(1.0f, 1.0f, 1.0f, 1.0f)); 2537 2553 tech.SetDiffuse(RgbaColor(1.0f, 1.0f, 1.0f, 1.0f)); … … 2542 2558 2543 2559 2544 void RenderPvs()2560 void LoadPvs() 2545 2561 { 2546 2562 viewCell = viewCellsTree->GetViewCell(camera->GetPosition()); … … 2551 2567 { 2552 2568 SceneEntity *ent = viewCell->mPvs.GetEntry(i); 2553 //ent->Render(&renderState);2554 2569 ent->SetVisibleId(globalVisibleId); 2555 2570 … … 2558 2573 2559 2574 SceneEntity::SetGlobalVisibleId(globalVisibleId ++); 2560 2575 } 2576 2577 2578 void LoadVisibilitySolution() 2579 { 2580 /////////// 2581 //-- load the visibility solution 2582 2583 const string vis_filename = 2584 string(model_path + visibilitySolution + ".vis"); 2585 2586 VisibilitySolutionLoader visLoader; 2587 2588 viewCellsTree = visLoader.Load(vis_filename, bvh); 2589 } 2590 2591 2592 void RenderViewCell() 2593 { 2561 2594 // render current view cell 2562 2595 static Technique vcTechnique = GetVizTechnique(); … … 2564 2597 vcTechnique.Render(&renderState); 2565 2598 Visualization::RenderBoxForViz(viewCell->GetBox()); 2566 2567 visualization->SetViewCell(viewCell); 2568 2569 //cout << "pvs: " << vc->mPvs.Size() << " triangles: " << numTriangles << endl; 2570 } 2599 }
Note: See TracChangeset
for help on using the changeset viewer.