Changeset 866 for GTP/trunk/App/Demos/Vis
- Timestamp:
- 04/30/06 15:31:41 (19 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
r724 r866 207 207 } 208 208 209 // larger magnification for terrain 210 if (TestCullingTerrainApplication::msShowHillyTerrain) 211 mVizScale = 25; 212 else 213 mVizScale = 1; 214 209 215 // the scale factor for the visualized bounding boxes 210 216 mSceneMgr->setOption("NodeVizScale", &mVizScale); 217 211 218 212 219 // set culling algorithm type … … 478 485 479 486 // clamp camera so we always walk along the terrain 480 mApplication->Clamp2Terrain(mCamNode, 5); 487 if (TestCullingTerrainApplication::msShowHillyTerrain) 488 { 489 mApplication->Clamp2Terrain(mCamNode, 5); 490 } 491 else 492 { 493 mApplication->Clamp2FloorPlane(); 494 } 495 481 496 break; 482 497 -
GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrain.vcproj
r657 r866 73 73 <Tool 74 74 Name="VCCLCompilerTool" 75 AdditionalIncludeDirectories=""$(OGRE_PATH)\Dependencies\include";"$(OGRE_PATH)\OgreMain\include";"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\Dependencies\include\CEGUI";"$(OGRE_PATH)\PlugIns\OctreeSceneManager\include";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include";..\..\Ogre\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\include;..\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\include "75 AdditionalIncludeDirectories=""$(OGRE_PATH)\Dependencies\include";"$(OGRE_PATH)\OgreMain\include";"$(OGRE_PATH)\Samples\Common\include";"$(OGRE_PATH)\Dependencies\include\CEGUI";"$(OGRE_PATH)\PlugIns\OctreeSceneManager\include";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\include";..\..\Ogre\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\include;..\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\include;..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\include" 76 76 PreprocessorDefinitions="_WINDOWS;_STLP_USE_DYNAMIC_LIB;OGRE_LIBRARY_IMPORTS;_RELEASE;WIN32;_STLP_RELEASE;GTP_VISIBILITY_MODIFIED_OGRE" 77 77 RuntimeLibrary="2" … … 85 85 <Tool 86 86 Name="VCLinkerTool" 87 AdditionalDependencies="OGREMain.LIB CEGUIBase.lib OgreGUIRenderer.lib Plugin_OctreeSceneManager.lib Plugin_VisibilitySceneManager.lib "87 AdditionalDependencies="OGREMain.LIB CEGUIBase.lib OgreGUIRenderer.lib Plugin_OctreeSceneManager.lib Plugin_VisibilitySceneManager.lib IVReader.lib" 88 88 OutputFile="$(OGRE_PATH)/Samples/Common/bin/Release/TestCullingTerrain.exe" 89 89 LinkIncremental="1" 90 AdditionalLibraryDirectories=""$(OGRE_PATH)\Dependencies\Lib\$(ConfigurationName)";"$(OGRE_PATH)\OgreMain\Lib\$(ConfigurationName)";"$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib";"..\..\Ogre\lib\$(ConfigurationName)";..\..\..\..\..\Lib\Vis\OnlineCullingCHC\lib;"..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\lib\$(ConfigurationName)" "90 AdditionalLibraryDirectories=""$(OGRE_PATH)\Dependencies\Lib\$(ConfigurationName)";"$(OGRE_PATH)\OgreMain\Lib\$(ConfigurationName)";"$(OGRE_PATH)\PlugIns\OctreeSceneManager\bin\$(ConfigurationName)";"$(OGRE_PATH)\Samples\Common\CEGUIRenderer\lib";"..\..\Ogre\lib\$(ConfigurationName)";..\..\..\..\..\Lib\Vis\OnlineCullingCHC\lib;"..\..\..\..\..\Lib\Vis\OnlineCullingCHC\OGRE\lib\$(ConfigurationName)";"..\..\..\..\..\Lib\Vis\OnlineCullingCHC\IVReader\lib\$(ConfigurationName)"" 91 91 GenerateDebugInformation="TRUE" 92 92 SubSystem="2" -
GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp
r723 r866 7 7 8 8 #include <Ogre.h> 9 9 #include <direct.h> // for getcwd 10 10 //#include "OgreReferenceAppLayer.h" 11 11 //#include "OgreRefAppWorld.h" … … 13 13 #include "TerrainFrameListener.h" 14 14 15 #include "IVReader.h" 16 15 17 #define WIN32_LEAN_AND_MEAN 16 18 #include <windows.h> 17 19 18 20 19 /**********************************************/ 20 /* EntityState implementation */ 21 /**********************************************/ 21 bool TestCullingTerrainApplication::msShowHillyTerrain = false; 22 23 /******************************************************/ 24 /* EntityState implementation */ 25 /******************************************************/ 22 26 23 27 … … 159 163 OGRE_DELETE(mTerrainContentGenerator); 160 164 OGRE_DELETE(mRayQueryExecutor); 165 OGRE_DELETE(mIVReader); 161 166 162 167 deleteEntityStates(); … … 183 188 * because then the camera is displayed correctly in the visualization 184 189 */ 185 mCamNode = mSceneMgr->getRootSceneNode()-> 190 if (msShowHillyTerrain) 191 { 192 mCamNode = mSceneMgr->getRootSceneNode()-> 186 193 createChildSceneNode("CamNode1", Vector3(707, 5000, 528)); 187 //mCamera->setPosition(707, 5000, 528); 194 } 195 else 196 { 197 mCamNode = mSceneMgr->getRootSceneNode()-> 198 createChildSceneNode("CamNode1", Vector3(0, -100, -200)); 199 } 200 188 201 mCamNode->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 189 202 mCamNode->attachObject(mCamera); … … 225 238 } 226 239 //----------------------------------------------------------------------- 240 void TestCullingTerrainApplication::LoadWorldGeometry() 241 { 242 mIVReader = new IVReader(); 243 244 // _MAX_PATH is the maximum length allowed for a path 245 char currentPath[_MAX_PATH]; 246 // use the function to get the path 247 getcwd(currentPath, _MAX_PATH); 248 std::stringstream d; 249 d << "current path: " << currentPath; 250 //E:\ogre_versions\ogre-win32-v1-0-3p1\ogrenew\Samples\Common\bin\Release 251 Ogre::LogManager::getSingleton().logMessage(d.str()); 252 //String path = "E:/svn/gametools/trunk/VUT/Ogre/resources/"; 253 String path = "E:/svn/gametools/OGRE/trunk/resources/"; 254 255 SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node1"); 256 SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node2"); 257 SceneNode *node3 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node3"); 258 SceneNode *node4 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node4"); 259 SceneNode *node5 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node5"); 260 SceneNode *node6 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node6"); 261 SceneNode *node7 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node7"); 262 SceneNode *node8 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node8"); 263 SceneNode *node9 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node9"); 264 265 266 node1->translate(Vector3(-500, 0, 750)); 267 node2->translate(Vector3(-400, 0, 750)); 268 node3->scale(Vector3(100, 100 ,100)); 269 node3->pitch(Radian(3 * Math::HALF_PI)); 270 node4->translate(Vector3(-100, 0, 0)); 271 node5->translate(Vector3(0, 300, 0)); 272 273 node6->scale(Vector3(100, 100 ,100)); 274 node6->pitch(Radian(3 * Math::HALF_PI)); 275 node6->roll(Radian(Math::HALF_PI)); 276 node6->translate(Vector3(0, -100, 0)); 277 278 node7->scale(Vector3(100, 100 ,100)); 279 node7->pitch(Radian(3 * Math::HALF_PI)); 280 node7->roll(Radian(Math::HALF_PI)); 281 node7->translate(Vector3(100, 0, 0)); 282 283 node8->translate(Vector3(-300, -300, 0)); 284 285 Log *log = LogManager::getSingleton().createLog("IVLog.log"); 286 mIVReader->setLog(log); 287 #if 1 288 String fileName = path + "media\\house_test1.iv"; 289 290 if (mIVReader->loadFile(fileName.c_str())) 291 { 292 mIVReader->buildTree(mSceneMgr, node1); 293 mIVReader->buildTree(mSceneMgr, node2); 294 } 295 296 /*if (mIVReader->loadFile("media\\anhk.wrl")) 297 { 298 mIVReader->buildTree(mSceneMgr, node3); 299 } 300 if (mIVReader->loadFile("media\\ant.wrl")) 301 { 302 mIVReader->buildTree(mSceneMgr, node4); 303 } 304 if (mIVReader->loadFile("media\\zepplin0.wrl")) 305 { 306 mIVReader->buildTree(mSceneMgr, node5); 307 } 308 if (mIVReader->loadFile("media\\warbird.wrl")) 309 { 310 mIVReader->buildTree(mSceneMgr, node6); 311 } 312 if (mIVReader->loadFile("media\\z_wing.wrl")) 313 { 314 mIVReader->buildTree(mSceneMgr, node7); 315 }*/ 316 #else 317 318 String fileName = path + "media\\city1500_flat_1.iv"; 319 320 if (mIVReader->loadFile(fileName.c_str())) 321 { 322 mIVReader->buildTree(mSceneMgr, node8); 323 } 324 325 fileName = path + "media\\roofs_1500.iv"; 326 if (mIVReader->loadFile(fileName.c_str())) 327 { 328 mIVReader->buildTree(mSceneMgr, node8); 329 } 330 331 fileName = path + "media\\CityRoads60.iv"; 332 if (mIVReader->loadFile(fileName.c_str())) 333 { 334 mIVReader->buildTree(mSceneMgr, node8); 335 } 336 337 fileName = path + "media\\CityPlane60.iv"; 338 if (mIVReader->loadFile(fileName.c_str())) 339 { 340 mIVReader->buildTree(mSceneMgr, node8); 341 } 342 343 fileName = path + "media\\test.iv"; 344 if (mIVReader->loadFile(fileName.c_str())) 345 { 346 mIVReader->buildTree(mSceneMgr, node9); 347 } 348 #endif 349 mIVReader->collapse(); 350 } 351 352 //----------------------------------------------------------------------- 227 353 void TestCullingTerrainApplication::createScene() 228 354 { 355 if (!msShowHillyTerrain) 356 LoadWorldGeometry(); 357 229 358 // Set ambient light 230 359 mAmbientLight = ColourValue(0.5, 0.5, 0.5); … … 258 387 mSceneMgr->setSkyBox(true, "Examples/CloudyNoonSkyBox", 5000, true); 259 388 260 std::string terrain_cfg("terrain.cfg"); 389 if (msShowHillyTerrain) 390 { 391 std::string terrain_cfg("terrain.cfg"); 261 392 #if OGRE_PLATFORM == OGRE_PLATFORM_APPLE 262 terrain_cfg = mResourcePath + terrain_cfg;393 terrain_cfg = mResourcePath + terrain_cfg; 263 394 #endif 264 mSceneMgr->setWorldGeometry(terrain_cfg); 395 mSceneMgr->setWorldGeometry(terrain_cfg); 396 } 265 397 266 398 … … 278 410 mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt); */ 279 411 280 // Use 512x512 texture in GL since we can't go higher than the window res412 // Warning: In GL since we can't go higher than the window res 281 413 mSceneMgr->setShadowTextureSettings(1024, 2); 282 414 … … 298 430 mTerrainContentGenerator = new TerrainContentGenerator(mSceneMgr); 299 431 432 300 433 // if no objects in file, we generate new objects 301 if ( !mTerrainContentGenerator->LoadObjects("objects.out"))434 if (msShowHillyTerrain && !mTerrainContentGenerator->LoadObjects("objects.out")) 302 435 { 303 436 // the objects are generated randomly distributed over the terrain … … 388 521 void TestCullingTerrainApplication::chooseSceneManager() 389 522 { 390 mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_CLOSE); 523 if (msShowHillyTerrain) 524 { 525 // Terrain scene manager 526 mSceneMgr = mRoot->getSceneManager(ST_EXTERIOR_CLOSE); 527 } 528 else 529 { // octree scene manager 530 mSceneMgr = mRoot->getSceneManager(ST_GENERIC); 531 } 391 532 } 392 533 //----------------------------------------------------------------------- … … 407 548 } 408 549 409 410 /**************************************************************/ 411 /* VisualizationRenderTargetListener implementation */ 412 /**************************************************************/ 550 //----------------------------------------------------------------------- 551 bool TestCullingTerrainApplication::Clamp2FloorPlane() 552 { 553 // clamp to floor plane 554 RaySceneQuery *raySceneQuery = mSceneMgr->createRayQuery( 555 Ray(mCamNode->getPosition(), Vector3::NEGATIVE_UNIT_Y)); 556 557 RaySceneQueryResult& qryResult = raySceneQuery->execute(); 558 559 RaySceneQueryResult::iterator rit = qryResult.begin(); 560 561 while (rit != qryResult.end() && rit->movable) 562 { 563 if (rit->movable->getName() != "PlayerCam") 564 { 565 mCamNode->setPosition(mCamNode->getPosition().x, 566 rit->movable->getWorldBoundingBox().getCenter().y + 2, 567 mCamNode->getPosition().z); 568 569 /*std::stringstream d; 570 d << "World: " << it->movable->getWorldBoundingBox().getCenter().y << 571 ", Object: " << it->movable->getBoundingBox().getCenter().y << 572 ", Camera: " << mCamera->getDerivedPosition(); 573 574 LogManager::getSingleton().logMessage(d.str());*/ 575 576 return true; 577 } 578 579 ++ rit; 580 } 581 582 OGRE_DELETE(raySceneQuery); 583 return false; 584 } 585 586 587 588 /**********************************************************************/ 589 /* VisualizationRenderTargetListener implementation */ 590 /**********************************************************************/ 591 592 413 593 //----------------------------------------------------------------------- 414 594 VisualizationRenderTargetListener::VisualizationRenderTargetListener(SceneManager *sceneMgr) -
GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.h
r723 r866 15 15 #define VIZ_VIEWPORT_Z_ORDER 10 16 16 17 class IVReader; 17 18 18 19 //-- constants for animation … … 119 120 bool Clamp2Terrain(SceneNode *node, int terrainOffs); 120 121 122 /** Clamps camera to floor plane: used for vienna set. 123 */ 124 bool Clamp2FloorPlane(); 125 126 /** Loads world geometry. 127 */ 128 void LoadWorldGeometry(); 129 130 // if hilly terrain should be loaded 131 static bool msShowHillyTerrain; 132 121 133 protected: 122 134 … … 158 170 Vector3 mTerrainMaxPos; 159 171 172 IVReader *mIVReader; 173 160 174 private: 161 175 void chooseSceneManager(void);
Note: See TracChangeset
for help on using the changeset viewer.