Changeset 924 for GTP/trunk/App/Demos/Vis
- Timestamp:
- 05/08/06 06:52:15 (19 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp
r901 r924 81 81 82 82 std::ofstream video_out("video.lst"); 83 84 // if we are recording a demo 85 static const bool DEMO_HACK = false; 83 86 84 87 //----------------------------------------------------------------------- … … 111 114 #else 112 115 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING), 116 //mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING), 113 117 #endif 114 118 mNodeVizMode(NODEVIZ_NONE), … … 194 198 mMyStatsFpsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/MyFpsInfo"); 195 199 mMyStatsFpsInfo->setCaption(str); 200 196 201 //mMyStatsAlgorithmInfo->setTop(top); 197 198 //mMyStatsOverlay->show(); 199 200 if (1) 201 { 202 initVisStatsOverlay(); // visibility stats overlay 203 initHelpOverlay(); // help overlay 204 initQueryOverlay(); // visibility query stats overlay 205 206 // show stats overlays 202 203 initVisStatsOverlay(); // visibility stats overlay 204 initHelpOverlay(); // help overlay 205 initQueryOverlay(); // visibility query stats overlay 206 207 // show stats overlays 208 if (!DEMO_HACK) 207 209 showStats(true); 208 } 210 else 211 mMyStatsOverlay->show(); 212 209 213 210 214 // note: larger magnification for terrain to show single objects … … 216 220 // the scale factor for the visualized bounding boxes 217 221 mSceneMgr->setOption("NodeVizScale", &mVizScale); 218 219 220 // set culling algorithm type 222 223 //-- set culling algorithm type 221 224 setAlgorithm(mCurrentAlgorithm); 222 225 … … 236 239 mTimeFrameEnded = mTimeFrameStarted = mTimer->getMilliseconds(); 237 240 238 if (0 && (mSceneMgr->getSceneNode("robot Entity1Node")->getAttachedObject(0)->getMovableType() == "Entity")) 241 if (0 && (mSceneMgr->getSceneNode("robot Entity1Node")-> 242 getAttachedObject(0)->getMovableType() == "Entity")) 239 243 Ogre::LogManager::getSingleton().logMessage("found entity"); 240 244 245 // init view cell parameters 241 246 mSceneMgr->setOption("UseViewCells", &mUseViewCells); 242 247 mSceneMgr->setOption("UseVisibilityFilter", &mUseVisibilityFilter); … … 244 249 // reset statistics 245 250 mWalkthroughStats.Reset(); 251 246 252 } 247 253 //----------------------------------------------------------------------- … … 508 514 bool useItemBuffer) 509 515 { 510 // TODO: change this (does not work with other scene manager plugins)511 VisibilityTerrainSceneManager *sm =512 dynamic_cast<VisibilityTerrainSceneManager *>(mSceneMgr);513 514 516 int itemBufferMode = useItemBuffer ? mItemBufferMode : 0; 515 517 … … 518 520 queryModes |= GtpVisibility::QueryManager::GEOMETRY_VISIBILITY; 519 521 queryModes |= GtpVisibility::QueryManager::NODE_VISIBILITY; 520 521 mQueryManager = new OcclusionQueriesQueryManager(sm->GetHierarchyInterface(), 522 523 // no visibility manager available => no visibility scene manager, return 524 GtpVisibility::VisibilityManager *visManager; 525 526 if (!mSceneMgr->getOption("VisibilityManager", visManager)) 527 return; 528 529 GtpVisibility::HierarchyInterface *hierarchyInterface; 530 if (!mSceneMgr->getOption("HierarchyInterface", hierarchyInterface)) 531 return; 532 533 mQueryManager = new OcclusionQueriesQueryManager(hierarchyInterface, 522 534 mWindow->getViewport(0), queryModes, itemBufferMode); 523 535 524 536 //mQueryManager = new PlatformQueryManager(sm->GetHierarchyInterface(), mWindow->getViewport(0), false); 525 526 sm->GetVisibilityManager()->SetQueryManager(mQueryManager); 537 538 539 visManager->SetQueryManager(mQueryManager); 527 540 528 541 GtpVisibility::NodeInfoContainer visibleNodes; … … 553 566 float averageNodeVis = 0, averageGeometryVis = 0, averagePatchVis = 0; 554 567 int geomSize = 0, nodesSize = 0, patchSize = 0; 568 569 /////////////////////////////////////////////////////////////////////////// 570 //-- apply queries on geometry level 555 571 556 572 GtpVisibility::MeshInfoContainer::iterator geomIt, geomIt_end = visibleGeometry.end(); … … 574 590 } 575 591 592 593 594 /////////////////////////////////////////////////////////////////////////// 595 //-- apply queries on node level 596 597 576 598 GtpVisibility::NodeInfoContainer::iterator nodesIt, nodesIt_end = visibleNodes.end(); 577 599 … … 592 614 } 593 615 616 617 /////////////////////////////////////////////////////////////////////////// 618 //-- apply queries on patch level 619 620 594 621 GtpVisibility::PatchInfoContainer::iterator patchIt, patchIt_end = visiblePatches.end(); 595 622 … … 609 636 } 610 637 } 638 639 /////////////////////////////////////////////////////////////// 640 //-- update visibility queries stats 611 641 612 642 if (nodesSize) … … 617 647 averagePatchVis /= (float)patchSize; 618 648 619 //-- update visibility queries stats 649 620 650 try 621 651 { … … 955 985 mAlgorithmInfo->setCaption(": " + msAlgorithmCaptions[mCurrentAlgorithm]); 956 986 mSceneMgr->setOption("Algorithm", &mCurrentAlgorithm); 987 std::stringstream d; d << "algorithm: " << msAlgorithmCaptions[mCurrentAlgorithm]; 988 if (1) Ogre::LogManager::getSingleton().logMessage(d.str()); 957 989 } 958 990 //----------------------------------------------------------------------- … … 1029 1061 } 1030 1062 1031 /*std::stringstream d; 1032 d << "fps: " << StringConverter::toString(currentFps) << ", " 1033 << "avg fps: " << StringConverter::toString(avgFps); 1034 LogManager::getSingleton().logMessage(d.str());*/ 1063 if (0) 1064 { 1065 std::stringstream d; 1066 d << "fps: " << StringConverter::toString(currentFps) << ", " 1067 << "avg fps: " << StringConverter::toString(avgFps); 1068 LogManager::getSingleton().logMessage(d.str()); 1069 } 1035 1070 1036 1071 //guiAvg->setCaption(avgFps + StringConverter::toString(stats.avgFPS)); -
GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp
r901 r924 12 12 #include "TestCullingTerrainApplication.h" 13 13 #include "TerrainFrameListener.h" 14 //#include "Ogre VisibilityOctreeSceneManager.h"14 //#include "OgreOcclusionCullingSceneManager.h" 15 15 16 16 #include "IVReader.h" … … 21 21 const static bool USE_STATIC_GEOMETRY = false; 22 22 bool TestCullingTerrainApplication::msShowHillyTerrain = false; 23 //bool TestCullingTerrainApplication::msShowHillyTerrain = true; 23 24 24 25 25 26 /******************************************************/ … … 163 164 { 164 165 } 166 //------------------------------------------------------------------------- 167 void TestCullingTerrainApplication::loadConfig(const String& filename) 168 { 169 // TODO matt 170 // Set up the options 171 ConfigFile config; 172 String val; 173 174 config.load(filename); 175 176 std::stringstream d; d << "reading config from: " << filename; 177 LogManager::getSingleton().logMessage(d.str()); 178 179 val = config.getSetting("Scene"); 180 181 if (!val.empty()) 182 { 183 mFilename = val.c_str(); 184 185 std::stringstream d; d << "filename: " << mFilename; 186 LogManager::getSingleton().logMessage(d.str()); 187 } 188 189 /* val = config.getSetting("ViewCells"); 190 191 if (!val.empty()) 192 { 193 mViewCellsFilename = val.c_str(); 194 }*/ 195 } 165 196 //----------------------------------------------------------------------- 166 197 TestCullingTerrainApplication::~TestCullingTerrainApplication() … … 235 266 } 236 267 //----------------------------------------------------------------------- 237 void TestCullingTerrainApplication::LoadWorldGeometry() 268 bool TestCullingTerrainApplication::LoadSceneIV(const String &filename, 269 SceneNode *root, 270 const int index) 238 271 { 239 272 mIVReader = new IVReader(); 240 273 241 // _MAX_PATH is the maximum length allowed for a path 242 char currentPath[_MAX_PATH]; 243 // use the function to get the path 244 getcwd(currentPath, _MAX_PATH); 245 246 247 // $$matt TODO; use relatrive path 248 std::stringstream d; 249 d << "current path: " << currentPath; 250 Ogre::LogManager::getSingleton().logMessage(d.str()); 251 252 String path = "E:/svn/gametools/OGRE/trunk/resources/"; 253 254 255 /* SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node1"); 256 257 SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node2"); 258 SceneNode *node3 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node3"); 259 SceneNode *node4 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node4"); 260 SceneNode *node5 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node5"); 261 SceneNode *node6 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node6"); 262 SceneNode *node7 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node7"); 263 264 265 266 node2->translate(Vector3(-400, 0, 750)); 267 node3->scale(Vector3(100, 100 ,100)); 268 node3->pitch(Radian(3 * Math::HALF_PI)); 269 node4->translate(Vector3(-100, 0, 0)); 270 node5->translate(Vector3(0, 300, 0)); 271 272 node6->scale(Vector3(100, 100 ,100)); 273 node6->pitch(Radian(3 * Math::HALF_PI)); 274 node6->roll(Radian(Math::HALF_PI)); 275 node6->translate(Vector3(0, -100, 0)); 276 277 node7->scale(Vector3(100, 100 ,100)); 278 node7->pitch(Radian(3 * Math::HALF_PI)); 279 node7->roll(Radian(Math::HALF_PI)); 280 node7->translate(Vector3(100, 0, 0)); 281 282 */ 283 284 Log *log = LogManager::getSingleton().createLog("IVLog.log"); 285 mIVReader->setLog(log); 286 287 288 289 #if 0 290 //String fileName = path + "media\\simple_geom.wrl"; 291 String fileName = path + "media\\city.wrl"; 292 //String fileName = path + "media\\house_test1.iv"; 293 mCamNode->setPosition(Vector3(-6, 0.5, 10)); 294 //mCamNode->setPosition(Vector3(412, 7.4, -667)); 295 mCamNode->setOrientation(Quaternion(-0.95, 0, 0.3, 0)); 296 297 if (0 && mIVReader->loadFile(fileName.c_str())) 298 { 299 mIVReader->buildTree(mSceneMgr, node1); 300 } 301 302 String fileName = path + "media\\house_test1.iv"; 303 304 if (0 && mIVReader->loadFile(fileName.c_str())) 305 { 306 mIVReader->buildTree(mSceneMgr, node1); 307 mIVReader->buildTree(mSceneMgr, node2); 308 } 309 310 if (0 && mIVReader->loadFile("media\\anhk.wrl")) 311 { 312 mIVReader->buildTree(mSceneMgr, node3); 313 } 314 if (0 && mIVReader->loadFile("media\\ant.wrl")) 315 { 316 mIVReader->buildTree(mSceneMgr, node4); 317 } 318 if (0 && mIVReader->loadFile("media\\zepplin0.wrl")) 319 { 320 mIVReader->buildTree(mSceneMgr, node5); 321 } 322 if (0 && mIVReader->loadFile("media\\warbird.wrl")) 323 { 324 mIVReader->buildTree(mSceneMgr, node6); 325 } 326 if (0 && mIVReader->loadFile("media\\z_wing.wrl")) 327 { 328 mIVReader->buildTree(mSceneMgr, node7); 329 } 330 331 #endif 332 333 #if 1 334 //-- load vienna model 335 336 SceneNode *roofsNode = NULL; 337 SceneNode *viennaNode = NULL; 338 SceneNode *roadsNode = NULL; 339 SceneNode *planeNode = NULL; 340 SceneNode *wallsNode = NULL; 341 342 viennaNode = mSceneMgr->getRootSceneNode()->createChildSceneNode("Vienna"); 343 344 mCamNode->setPosition(Vector3(830, 300, -540)); 345 mCamNode->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 274 if (1) 275 { 276 std::string logFilename = "IVLog" + index; 277 logFilename += ".log"; 278 279 Log *log = LogManager::getSingleton().createLog(logFilename); 280 mIVReader->setLog(log); 281 } 346 282 347 283 //viennaNode->translate(Vector3(-300, -300, 0)); 348 284 349 String fileName = path + "media\\city1500_flat_1.iv"; 350 351 if (0 && mIVReader->loadFile(fileName.c_str())) 352 { 353 wallsNode = viennaNode->createChildSceneNode("Walls"); 354 mIVReader->buildTree(mSceneMgr, wallsNode); 355 } 356 357 358 fileName = path + "media\\roofs_1500.iv"; 359 if (1 && mIVReader->loadFile(fileName.c_str())) 360 { 361 roofsNode = viennaNode->createChildSceneNode("Roofs"); 362 mIVReader->buildTree(mSceneMgr, roofsNode); 363 } 364 365 fileName = path + "media\\CityRoads60.iv"; 366 if (0 && mIVReader->loadFile(fileName.c_str())) 367 { 368 roadsNode = viennaNode->createChildSceneNode("Roads"); 369 mIVReader->buildTree(mSceneMgr, roadsNode); 370 } 371 372 fileName = path + "media\\CityPlane60.iv"; 373 if (0 && mIVReader->loadFile(fileName.c_str())) 374 { 375 planeNode = viennaNode->createChildSceneNode("Plane"); 376 mIVReader->buildTree(mSceneMgr, planeNode); 377 } 378 379 #endif 285 if (mIVReader->loadFile(filename.c_str())) 286 { 287 SceneNode *node = root->createChildSceneNode("IVSceneNode" + index); 288 289 mIVReader->buildTree(mSceneMgr, node); 290 //OGRE_DELETE(mIVReader); 291 return true; 292 } 380 293 381 294 mIVReader->collapse(); … … 386 299 BakeSceneIntoStaticGeometry("staticVienna", "Vienna"); 387 300 } 301 302 OGRE_DELETE(mIVReader); 303 304 return false; 388 305 } 389 306 //-------------------------------------------------------- … … 411 328 412 329 //roofsNode->detachAllObjects(); 413 //roadsNode->detachAllObjects();414 // planeNode->detachAllObjects();330 //roadsNode->detachAllObjects(); 331 // planeNode->detachAllObjects(); 415 332 416 333 //viennaNode->removeChild("Walls"); … … 421 338 void TestCullingTerrainApplication::createScene() 422 339 { 423 if (!msShowHillyTerrain) 424 LoadWorldGeometry(); 340 //-- load scene 341 342 //GtpVisibility::VisibilityManager *mVisManager; 343 //if (!mSceneMgr->getOption("VisibilityManager", mVisManager)) return; 344 //const std::string filename = visEnv->getSceneFilename(); 345 loadConfig("test.cfg"); 346 LoadScene(mFilename); 347 348 349 350 ///////////////////////////////////// 425 351 426 352 // Set ambient light … … 471 397 if (0) 472 398 { 473 Plane plane; plane.normal = Vector3::UNIT_Y; plane.d = -60; 399 Plane plane; 400 plane.normal = Vector3::UNIT_Y; 401 plane.d = -60; 402 474 403 MeshManager::getSingleton().createPlane("Myplane", 475 404 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane, 476 405 5000,5000,100,100,true,1,5,5,Vector3::UNIT_Z); 406 477 407 Entity* pPlaneEnt = mSceneMgr->createEntity( "plane", "Myplane" ); 478 408 pPlaneEnt->setMaterialName("Examples/Rockwall"); … … 511 441 } 512 442 513 // HACK: load the view cells from the disc 514 //(dynamic_cast<VisibilityOctreeSceneManager *>(mSceneMgr))->LoadViewCells(""); 515 443 444 445 //-- HACK: load the view cells from the disc 446 516 447 //std::string filename = "vienna_simple-21-04-avs2-viewCells.xml"; 517 448 //std::string filename = "vienna_simple-21-04-kdcasm-viewCells.xml"; 518 449 std::string filename = "vienna_simple-21-04-avs-viewCells.xml"; 519 450 520 mSceneMgr->setOption("LoadViewCells", filename.c_str()); 451 //-- the actual loading happens here 452 if (0) mSceneMgr->setOption("LoadViewCells", filename.c_str()); 521 453 } 522 454 //----------------------------------------------------------------------- … … 620 552 { 621 553 //mSceneMgr = mRoot->createSceneManager("VisibilityTerrainSceneManager"); 622 mSceneMgr = mRoot->createSceneManager("TerrainSceneManager"); 554 //mSceneMgr = mRoot->createSceneManager("TerrainSceneManager"); 555 mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager"); 623 556 } 624 557 else 625 { 626 558 { //mSceneMgr = mRoot->createSceneManager("VisibilityTerrainSceneManager"); 559 //mSceneMgr = mRoot->createSceneManager("VisibilityOctreeSceneManager"); 627 560 //mSceneMgr = mRoot->createSceneManager("OctreeSceneManager"); 561 mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager"); 628 562 } 629 563 … … 666 600 mCamNode->getPosition().z); 667 601 668 /*std::stringstream d; 602 /* 603 std::stringstream d; 669 604 d << "World: " << it->movable->getWorldBoundingBox().getCenter().y << 670 605 ", Object: " << it->movable->getBoundingBox().getCenter().y << … … 683 618 } 684 619 620 //----------------------------------------------------------------------- 621 // splits strings containing multiple file names 622 static int SplitFilenames(const std::string str, std::vector<std::string> &filenames) 623 { 624 int pos = 0; 625 626 while(1) 627 { 628 int npos = (int)str.find(';', pos); 629 630 if (npos < 0 || npos - pos < 1) 631 break; 632 filenames.push_back(std::string(str, pos, npos - pos)); 633 pos = npos + 1; 634 } 635 636 filenames.push_back(std::string(str, pos, str.size() - pos)); 637 return (int)filenames.size(); 638 } 639 640 //----------------------------------------------------------------------- 641 bool TestCullingTerrainApplication::LoadScene(const std::string filename) 642 { 643 using namespace std; 644 // use leaf nodes of the original spatial hierarchy as occludees 645 vector<string> filenames; 646 int files = SplitFilenames(filename, filenames); 647 648 std::stringstream d; 649 d << "number of input files: " << files << "\n"; 650 LogManager::getSingleton().logMessage(d.str()); 651 652 bool result = false; 653 vector<string>::const_iterator fit, fit_end = filenames.end(); 654 int i = 0; 655 // root for different files 656 for (fit = filenames.begin(); fit != fit_end; ++ fit, ++ i) 657 { 658 const string fn = *fit; 659 660 if (strstr(fn.c_str(), ".iv") || strstr(fn.c_str(), ".wrl")) 661 { 662 // hack: set postion manually for vienna 663 mCamNode->setPosition(Vector3(830, 300, -540)); 664 mCamNode->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 665 666 // load iv files 667 LoadSceneIV(fn, mSceneMgr->getRootSceneNode(), i); 668 } 669 else if (strstr(filename.c_str(), ".collada")) 670 { 671 // load collada files 672 } 673 else if (filename == "terrain") 674 { 675 // terrain hack 676 msShowHillyTerrain = true; 677 LogManager::getSingleton().logMessage("loading terrain"); 678 } 679 680 result = true; 681 } 682 683 684 /* 685 if (result) 686 { 687 int intersectables, faces; 688 689 std::stringstream d; 690 d << filename << " parsed successfully.\n" 691 << "#NUM_OBJECTS (Total numner of objects)\n" << intersectables << "\n" 692 << "#NUM_FACES (Total numner of faces)\n" << faces << "\n"; 693 } 694 */ 695 696 return result; 697 } 698 //----------------------------------------------------------------------- 699 bool TestCullingTerrainApplication::LoadViewCells(const std::string filename) 700 { 701 702 return true; 703 } 685 704 686 705 -
GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.h
r915 r924 124 124 bool Clamp2FloorPlane(); 125 125 126 /** Loads worldgeometry.126 /** Loads iv geometry. 127 127 */ 128 void LoadWorldGeometry();128 bool LoadSceneIV(const String &filename, SceneNode *root, const int index); 129 129 130 bool LoadScene(const std::string filename); 131 132 bool LoadViewCells(const std::string filename); 133 134 /** Loads configuration from disc. 135 */ 136 void loadConfig(const String& filename); 130 137 // if hilly terrain should be loaded 131 138 static bool msShowHillyTerrain; … … 176 183 177 184 StaticGeometry *mStaticGeometry; 185 186 String mFilename; 187 //String mViewCellsFilename; 188 178 189 private: 179 190 void chooseSceneManager(void);
Note: See TracChangeset
for help on using the changeset viewer.