Changeset 1271 for GTP/trunk/App/Demos/Vis
- Timestamp:
- 08/24/06 08:55:05 (18 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.cpp
r1268 r1271 83 83 // if we are recording a demo 84 84 static const bool DEMO_HACK = false; 85 86 //using namespace GtpVisibility; 85 87 86 88 //----------------------------------------------------------------------- … … 109 111 mVisibilityThreshold(0), 110 112 mAssumedVisibility(0), 111 #if 1112 113 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING), 113 #else114 mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING),115 //mCurrentAlgorithm(GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING),116 #endif117 114 mNodeVizMode(NODEVIZ_NONE), 118 115 mVizCameraHeight(Real(4000.0)), … … 181 178 mRayQueryExecutor = new RayQueryExecutor(mSceneMgr); 182 179 180 183 181 //-- overlays 184 182 … … 217 215 } 218 216 219 // loading overlay 220 217 // loading view cells overlay 221 218 mLoadingOverlay = OverlayManager::getSingleton().getByName("Example/Visibility/LoadingOverlay"); 222 219 mMyLoadingInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Loading/MyLoadingInfo"); 223 220 mMyLoadingInfo->setCaption("loading view cells ..."); 224 225 /*const int top = 10; 226 mMyStatsAlgorithmInfo->setTop(top); 227 228 char str[100]; sprintf(str,": %d", 0); 229 mMyStatsFpsInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/MyFpsInfo"); 230 mMyStatsFpsInfo->setCaption(str);*/ 221 231 222 232 223 mLoadingOverlay->hide(); … … 241 232 mSceneMgr->setOption("NodeVizScale", &mVizScale); 242 233 243 //-- set culling algorithm type244 setAlgorithm(m CurrentAlgorithm);234 //-- set the current culling algorithm type 235 setAlgorithm(mApplication->mAlgorithm); 245 236 246 237 // set scene manager options … … 253 244 mSceneMgr->setOption("PrepareVisualization", &mShowVisualization); 254 245 255 setObjectType(mCurrentObjectType);246 applyObjectType(); 256 247 257 248 // initialise timer … … 983 974 mCurrentAlgorithm = (mCurrentAlgorithm + 1) % 984 975 GtpVisibility::VisibilityEnvironment::NUM_CULLING_MANAGERS; 985 setAlgorithm(mCurrentAlgorithm);986 } 987 //----------------------------------------------------------------------- 988 void TerrainFrameListener:: setObjectType(int objectType)976 applyCurrentAlgorithm(); 977 } 978 //----------------------------------------------------------------------- 979 void TerrainFrameListener::applyObjectType() 989 980 { 990 981 if (mCurrentObjectType >= 3) // TODO: define a constant … … 999 990 } 1000 991 //----------------------------------------------------------------------- 1001 void TerrainFrameListener:: setAlgorithm(int algorithm)992 void TerrainFrameListener::applyCurrentAlgorithm() 1002 993 { 1003 994 mAlgorithmInfo->setCaption(": " + msAlgorithmCaptions[mCurrentAlgorithm]); … … 1184 1175 //----------------------------------------------------------------------- 1185 1176 void TerrainFrameListener::toggleUseViewCells() 1186 { LogManager::getSingleton().logMessage("here52");1177 { 1187 1178 // HACK: no view cells for hilly terrain 1188 1179 if (mApplication->msShowHillyTerrain) … … 1409 1400 1410 1401 case KC_F7: 1411 setObjectType(++ mCurrentObjectType); 1402 ++ mCurrentObjectType; 1403 applyObjectType(); 1412 1404 break; 1413 1405 #endif … … 1849 1841 int top = border_height + 25; 1850 1842 1851 String ext = "Example/Visibility/Query/";1843 const String ext = "Example/Visibility/Query/"; 1852 1844 1853 1845 initOverlayElement(&mQueryTypeInfo , ext, "QueryType", top, ": 0"); top += vert_space; … … 1867 1859 queryPanel->setHeight(top + border_height); 1868 1860 } 1861 //----------------------------------------------------------------------- 1862 void TerrainFrameListener::setAlgorithm(const int algorithm) 1863 { 1864 mCurrentAlgorithm = algorithm; 1865 applyCurrentAlgorithm(); 1866 } -
GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TerrainFrameListener.h
r945 r1271 164 164 void setCurrentFrameInfo(Real timeElapsed); 165 165 166 void setAlgorithm(int algorithm);166 void applyCurrentAlgorithm(); 167 167 168 168 void moveCamera(); … … 244 244 /** Sets the type of the objects generated in the scene. 245 245 */ 246 void setObjectType(int objectType); 246 void applyObjectType(); 247 248 void setAlgorithm(const int algorithm); 249 247 250 248 251 static String msAlgorithmCaptions[]; -
GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp
r1268 r1271 25 25 26 26 27 //using namespace GtpVisibility; 27 28 28 29 /*************************************************************/ … … 165 166 mIVReader(NULL), 166 167 mFilename("terrain"), 167 mEnvironmentFilename("generate_viewcells.env") 168 mViewCellsFilename(""), 169 mAlgorithm(GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING) 168 170 { 169 171 } … … 191 193 192 194 193 /*val = config.getSetting("ViewCells"); 195 val = config.getSetting("ViewCells"); 196 194 197 if (!val.empty()) 195 { mViewCellsFilename = val.c_str();}*/ 196 197 val = config.getSetting("VisibilityEnvironment"); 198 199 if (!val.empty()) 200 { 201 mEnvironmentFilename = val.c_str(); 202 std::stringstream d; d << "loading environment from file: " << mEnvironmentFilename; 198 { 199 mViewCellsFilename = val.c_str(); 200 std::stringstream d; d << "view cells file name: " << mViewCellsFilename; 203 201 LogManager::getSingleton().logMessage(d.str()); 204 202 } … … 222 220 223 221 222 val = config.getSetting("OnlineCullingAlgorithm"); 223 224 if (!val.empty()) 225 { 226 if (val == "CHC") 227 { 228 mAlgorithm = 229 GtpVisibility::VisibilityEnvironment::COHERENT_HIERARCHICAL_CULLING; 230 } 231 else if (val == "SWC") 232 { 233 mAlgorithm = 234 GtpVisibility::VisibilityEnvironment::STOP_AND_WAIT_CULLING; 235 } 236 else if (val == "VFC") 237 { 238 mAlgorithm = 239 GtpVisibility::VisibilityEnvironment::FRUSTUM_CULLING; 240 } 241 } 242 224 243 ///////////////////////// 225 244 // setup scene 226 245 227 246 //-- load the scene from specified file 228 LogManager::getSingleton().logMessage("here5112");229 247 if (!LoadScene(mFilename)) 230 LogManager::getSingleton().logMessage("error loading scene"); 231 232 LogManager::getSingleton().logMessage("here6"); 233 GtpVisibility::VisibilityManager *mVisManager = NULL; 234 235 //-- load the environment from file 236 if (mSceneMgr->getOption("VisibilityManager", &mVisManager)) 237 { 238 LogManager::getSingleton().logMessage("here7"); 239 GtpVisibility::VisibilityEnvironment *visEnv = mVisManager->GetVisibilityEnvironment(); 240 LogManager::getSingleton().logMessage("here7.04"); 241 if (!visEnv->LoadEnvironment(mEnvironmentFilename)) 242 {LogManager::getSingleton().logMessage("here7.l2"); 243 std::stringstream d; d << "failed loading environment from " << mEnvironmentFilename; 244 LogManager::getSingleton().logMessage(d.str()); 245 } 246 else //-- load environment options 247 {LogManager::getSingleton().logMessage("here8"); 248 //-- get view cells file name, load view cells only on demand 249 mViewCellsFilename = visEnv->getViewCellsFileName(); 250 251 std::stringstream d; d << "view cells file name: " << mViewCellsFilename; 252 LogManager::getSingleton().logMessage(d.str()); 253 } 254 } 255 else 256 { 257 LogManager::getSingleton().logMessage("error: no visibility scenemanager available"); 258 } 259 LogManager::getSingleton().logMessage("here9"); 248 { 249 LogManager::getSingleton().logMessage("error loading scene"); 250 } 251 260 252 // set camera position accordingly 261 253 mCamNode->setPosition(v); … … 477 469 mSunLight->setCastShadows(true); 478 470 479 // set light angle not too small over the surface, otherwise shadows textures will be broken 471 // set light angle not too small over the surface, 472 // otherwise shadows textures will be broken 480 473 Vector3 dir(0.5, 1, 0.5); 481 474 dir.normalise(); … … 490 483 ColourValue fadeColour(0.93, 0.86, 0.76); 491 484 mWindow->getViewport(0)->setBackgroundColour(fadeColour); 492 //mSceneMgr->setFog( 485 //mSceneMgr->setFog(FOG_LINEAR, fadeColour, .001, 500, 1000); 493 486 494 487 // Create a skybox 495 488 mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 5000, true); 496 489 490 // terrain creation 497 491 if (msShowHillyTerrain) 498 492 { … … 505 499 506 500 507 //-- CEGUI setup 508 setupGui(); 501 setupGui(); //-- CEGUI setup 509 502 510 503 // occluder plane to test visibility … … 530 523 mSceneMgr->setShadowColour(ColourValue(0.5, 0.5, 0.5)); 531 524 525 532 526 //-- terrain content setup 533 527 534 // HACK: necessary to call once before the content creation for 535 // terrain initialisation 528 // HACK: necessary to call once here for terrain initialisation 536 529 mSceneMgr->_renderScene(mCamera, mWindow->getViewport(0), true); 537 530 … … 634 627 void TestCullingTerrainApplication::createFrameListener() 635 628 { 636 mTerrainFrameListener = new TerrainFrameListener(mWindow, mCamera, mSceneMgr, 637 mGUIRenderer, mTerrainContentGenerator, mVizCamera, mCamNode, mSunLight, this); 629 mTerrainFrameListener = 630 new TerrainFrameListener(mWindow, 631 mCamera, 632 mSceneMgr, 633 mGUIRenderer, 634 mTerrainContentGenerator, 635 mVizCamera, 636 mCamNode, 637 mSunLight, 638 this); 638 639 639 640 mRoot->addFrameListener(mTerrainFrameListener); … … 655 656 if (msShowHillyTerrain) 656 657 { 658 mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager"); 657 659 //mSceneMgr = mRoot->createSceneManager("TerrainSceneManager"); 658 mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager");659 660 //mSceneMgr = mRoot->createSceneManager("KdTreeSceneManager"); 660 661 } 661 662 else 662 663 { 664 mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager"); 663 665 //mSceneMgr = mRoot->createSceneManager("OctreeSceneManager"); 664 mSceneMgr = mRoot->createSceneManager("OcclusionCullingSceneManager");665 666 //mSceneMgr = mRoot->createSceneManager("KdTreeSceneManager"); 666 667 } … … 741 742 return (int)filenames.size(); 742 743 } 743 744 744 //----------------------------------------------------------------------- 745 745 bool TestCullingTerrainApplication::LoadScene(const String &filename) … … 757 757 vector<string>::const_iterator fit, fit_end = filenames.end(); 758 758 int i = 0; 759 // root for different files 759 760 760 for (fit = filenames.begin(); fit != fit_end; ++ fit, ++ i) 761 761 { … … 764 764 if (strstr(fn.c_str(), ".iv") || strstr(fn.c_str(), ".wrl")) 765 765 { 766 // hack: set postion manually for vienna767 //mCamNode->setPosition(Vector3(830, 300, -540));768 //mCamNode->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329));769 770 766 // load iv files 771 767 if (!LoadSceneIV(fn, mSceneMgr->getRootSceneNode(), i)) … … 773 769 // terrain hack 774 770 msShowHillyTerrain = true; 775 LogManager::getSingleton().logMessage("error loading scene . loading terrain instead");771 LogManager::getSingleton().logMessage("error loading scene => load terrain"); 776 772 } 777 LogManager::getSingleton().logMessage("here521");778 773 } 779 774 else if (strstr(filename.c_str(), ".dae")) … … 793 788 } 794 789 795 796 /*797 if (result)798 {799 int intersectables, faces;800 801 std::stringstream d;802 d << filename << " parsed successfully.\n"803 << "#NUM_OBJECTS (Total numner of objects)\n" << intersectables << "\n"804 << "#NUM_FACES (Total numner of faces)\n" << faces << "\n";805 }806 */807 808 790 return result; 809 791 } … … 847 829 mSceneMgr->setOption("PrepareVisualization", &showViz); 848 830 mSceneMgr->setOption("SkyBoxEnabled", &nShowViz); 849 //mSceneMgr->setOption("SkyPlaneEnabled", &showViz);850 831 851 832 RenderTargetListener::preViewportUpdate(evt); -
GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.h
r1003 r1271 137 137 */ 138 138 void loadConfig(const String& filename); 139 139 140 140 141 /// if hilly terrain should be loaded 141 142 static bool msShowHillyTerrain; 142 143 143 144 144 String mFilename; … … 146 146 /// name of the visibility environment file 147 147 String mEnvironmentFilename; 148 149 int mAlgorithm; 150 148 151 149 152 protected: … … 192 195 193 196 StaticGeometry *mStaticGeometry; 194 195 197 196 198 197 199 private:
Note: See TracChangeset
for help on using the changeset viewer.