- Timestamp:
- 05/04/06 23:25:04 (19 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/HillyTerrain/OGRE/TestCullingTerrainApplication.cpp
r866 r901 5 5 #include <../CEGUIRenderer/include/OgreCEGUITexture.h> 6 6 #include <OgreMemoryMacros.h> 7 7 #include <OgreIteratorWrappers.h> 8 8 #include <Ogre.h> 9 9 #include <direct.h> // for getcwd … … 12 12 #include "TestCullingTerrainApplication.h" 13 13 #include "TerrainFrameListener.h" 14 //#include "OgreVisibilityOctreeSceneManager.h" 14 15 15 16 #include "IVReader.h" … … 18 19 #include <windows.h> 19 20 20 21 const static bool USE_STATIC_GEOMETRY = false; 21 22 bool TestCullingTerrainApplication::msShowHillyTerrain = false; 23 //bool TestCullingTerrainApplication::msShowHillyTerrain = true; 22 24 23 25 /******************************************************/ … … 52 54 mAnimationState->setEnabled(true); 53 55 } 56 54 57 mTimeElapsed = Math::RangeRandom(1, 5); 55 58 } … … 155 158 156 159 TestCullingTerrainApplication::TestCullingTerrainApplication(): 157 mTerrainContentGenerator(NULL), mRayQueryExecutor(NULL) 160 mTerrainContentGenerator(NULL), 161 mRayQueryExecutor(NULL), 162 mIVReader(NULL) 158 163 { 159 164 } … … 188 193 * because then the camera is displayed correctly in the visualization 189 194 */ 190 if (msShowHillyTerrain) 191 { 192 mCamNode = mSceneMgr->getRootSceneNode()-> 195 mCamNode = mSceneMgr->getRootSceneNode()-> 193 196 createChildSceneNode("CamNode1", Vector3(707, 5000, 528)); 194 } 195 else 196 { 197 mCamNode = mSceneMgr->getRootSceneNode()-> 198 createChildSceneNode("CamNode1", Vector3(0, -100, -200)); 199 } 200 197 201 198 mCamNode->setOrientation(Quaternion(-0.3486, 0.0122, 0.9365, 0.0329)); 202 199 mCamNode->attachObject(mCamera); 203 200 204 201 //-- create visualization camera 205 202 mVizCamera = mSceneMgr->createCamera("VizCam"); … … 246 243 // use the function to get the path 247 244 getcwd(currentPath, _MAX_PATH); 245 246 247 // $$matt TODO; use relatrive path 248 248 std::stringstream d; 249 249 d << "current path: " << currentPath; 250 //E:\ogre_versions\ogre-win32-v1-0-3p1\ogrenew\Samples\Common\bin\Release251 250 Ogre::LogManager::getSingleton().logMessage(d.str()); 252 //String path = "E:/svn/gametools/trunk/VUT/Ogre/resources/"; 251 253 252 String path = "E:/svn/gametools/OGRE/trunk/resources/"; 254 253 255 SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node1"); 254 255 /* SceneNode *node1 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node1"); 256 256 257 SceneNode *node2 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node2"); 257 258 SceneNode *node3 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node3"); … … 260 261 SceneNode *node6 = mSceneMgr->getRootSceneNode()->createChildSceneNode("Node6"); 261 262 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)); 263 264 265 267 266 node2->translate(Vector3(-400, 0, 750)); 268 267 node3->scale(Vector3(100, 100 ,100)); … … 281 280 node7->translate(Vector3(100, 0, 0)); 282 281 283 node8->translate(Vector3(-300, -300, 0));282 */ 284 283 285 284 Log *log = LogManager::getSingleton().createLog("IVLog.log"); 286 285 mIVReader->setLog(log); 287 #if 1 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 288 302 String fileName = path + "media\\house_test1.iv"; 289 303 290 if ( mIVReader->loadFile(fileName.c_str()))304 if (0 && mIVReader->loadFile(fileName.c_str())) 291 305 { 292 306 mIVReader->buildTree(mSceneMgr, node1); … … 294 308 } 295 309 296 /*if (mIVReader->loadFile("media\\anhk.wrl"))310 if (0 && mIVReader->loadFile("media\\anhk.wrl")) 297 311 { 298 312 mIVReader->buildTree(mSceneMgr, node3); 299 313 } 300 if ( mIVReader->loadFile("media\\ant.wrl"))314 if (0 && mIVReader->loadFile("media\\ant.wrl")) 301 315 { 302 316 mIVReader->buildTree(mSceneMgr, node4); 303 317 } 304 if ( mIVReader->loadFile("media\\zepplin0.wrl"))318 if (0 && mIVReader->loadFile("media\\zepplin0.wrl")) 305 319 { 306 320 mIVReader->buildTree(mSceneMgr, node5); 307 321 } 308 if ( mIVReader->loadFile("media\\warbird.wrl"))322 if (0 && mIVReader->loadFile("media\\warbird.wrl")) 309 323 { 310 324 mIVReader->buildTree(mSceneMgr, node6); 311 325 } 312 if ( mIVReader->loadFile("media\\z_wing.wrl"))326 if (0 && mIVReader->loadFile("media\\z_wing.wrl")) 313 327 { 314 328 mIVReader->buildTree(mSceneMgr, node7); 315 }*/ 316 #else 317 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)); 346 347 //viennaNode->translate(Vector3(-300, -300, 0)); 348 318 349 String fileName = path + "media\\city1500_flat_1.iv"; 319 320 if (mIVReader->loadFile(fileName.c_str())) 321 { 322 mIVReader->buildTree(mSceneMgr, node8); 323 } 350 351 if (0 && mIVReader->loadFile(fileName.c_str())) 352 { 353 wallsNode = viennaNode->createChildSceneNode("Walls"); 354 mIVReader->buildTree(mSceneMgr, wallsNode); 355 } 356 324 357 325 358 fileName = path + "media\\roofs_1500.iv"; 326 if (mIVReader->loadFile(fileName.c_str())) 327 { 328 mIVReader->buildTree(mSceneMgr, node8); 329 } 330 359 if (1 && mIVReader->loadFile(fileName.c_str())) 360 { 361 roofsNode = viennaNode->createChildSceneNode("Roofs"); 362 mIVReader->buildTree(mSceneMgr, roofsNode); 363 } 364 331 365 fileName = path + "media\\CityRoads60.iv"; 332 if (mIVReader->loadFile(fileName.c_str())) 333 { 334 mIVReader->buildTree(mSceneMgr, node8); 366 if (0 && mIVReader->loadFile(fileName.c_str())) 367 { 368 roadsNode = viennaNode->createChildSceneNode("Roads"); 369 mIVReader->buildTree(mSceneMgr, roadsNode); 335 370 } 336 371 337 372 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 } 373 if (0 && mIVReader->loadFile(fileName.c_str())) 374 { 375 planeNode = viennaNode->createChildSceneNode("Plane"); 376 mIVReader->buildTree(mSceneMgr, planeNode); 377 } 378 348 379 #endif 380 349 381 mIVReader->collapse(); 350 } 351 352 //----------------------------------------------------------------------- 382 383 //-- bake into static geometry 384 if (USE_STATIC_GEOMETRY) 385 { 386 BakeSceneIntoStaticGeometry("staticVienna", "Vienna"); 387 } 388 } 389 //-------------------------------------------------------- 390 void TestCullingTerrainApplication::BakeSceneIntoStaticGeometry(const String &staticGeomName, 391 const String &nodeName) 392 { 393 #if OGRE_103 394 // note: different static geom for roofs, roads, ..., becazse they have same material 395 StaticGeometry *staticGeom = mSceneMgr->createStaticGeometry(staticGeomName); 396 397 // note: looping over entities here. why does scene node not work? 398 SceneManager::EntityIterator it = mSceneMgr->getEntityIterator(); 399 while (it.hasMoreElements()) 400 { 401 Entity *ent = it.getNext(); 402 ent->setVisible(false); 403 staticGeom->addEntity(ent, ent->getParentSceneNode()->getPosition()); 404 } 405 406 staticGeom->setRegionDimensions(Vector3(100,100,100)); 407 staticGeom->build(); 408 409 // cleanup node 410 //wallsNode->detachAllObjects(); 411 412 //roofsNode->detachAllObjects(); 413 //roadsNode->detachAllObjects(); 414 // planeNode->detachAllObjects(); 415 416 //viennaNode->removeChild("Walls"); 417 mSceneMgr->destroySceneNode(nodeName); 418 #endif 419 } 420 //-------------------------------------------------------- 353 421 void TestCullingTerrainApplication::createScene() 354 422 { … … 400 468 setupGui(); 401 469 402 /* // occluder plane to test visibility 403 Plane plane; plane.normal = Vector3::UNIT_Y; plane.d = -60; 404 MeshManager::getSingleton().createPlane("Myplane", 405 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane, 406 5000,5000,100,100,true,1,5,5,Vector3::UNIT_Z); 407 Entity* pPlaneEnt = mSceneMgr->createEntity( "plane", "Myplane" ); 408 pPlaneEnt->setMaterialName("Examples/Rockwall"); 409 pPlaneEnt->setCastShadows(true); 410 mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt); */ 470 // occluder plane to test visibility 471 if (0) 472 { 473 Plane plane; plane.normal = Vector3::UNIT_Y; plane.d = -60; 474 MeshManager::getSingleton().createPlane("Myplane", 475 ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME, plane, 476 5000,5000,100,100,true,1,5,5,Vector3::UNIT_Z); 477 Entity* pPlaneEnt = mSceneMgr->createEntity( "plane", "Myplane" ); 478 pPlaneEnt->setMaterialName("Examples/Rockwall"); 479 pPlaneEnt->setCastShadows(true); 480 mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt); 481 } 411 482 412 483 // Warning: In GL since we can't go higher than the window res … … 439 510 if (0) generateScene(100, 2); // create ninjas 440 511 } 512 513 // HACK: load the view cells from the disc 514 //(dynamic_cast<VisibilityOctreeSceneManager *>(mSceneMgr))->LoadViewCells(""); 515 516 //std::string filename = "vienna_simple-21-04-avs2-viewCells.xml"; 517 //std::string filename = "vienna_simple-21-04-kdcasm-viewCells.xml"; 518 std::string filename = "vienna_simple-21-04-avs-viewCells.xml"; 519 520 mSceneMgr->setOption("LoadViewCells", filename.c_str()); 441 521 } 442 522 //----------------------------------------------------------------------- … … 498 578 void TestCullingTerrainApplication::setupGui() 499 579 { 580 #if OGRE103 500 581 mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, 501 582 false, 3000, ST_EXTERIOR_CLOSE); 583 #else 584 mGUIRenderer = new CEGUI::OgreCEGUIRenderer(mWindow, Ogre::RENDER_QUEUE_OVERLAY, 585 false, 3000, mSceneMgr); 586 #endif 502 587 mGUISystem = new CEGUI::System(mGUIRenderer); 503 588 … … 521 606 void TestCullingTerrainApplication::chooseSceneManager() 522 607 { 608 #ifdef OGRE_103 523 609 if (msShowHillyTerrain) 524 610 { … … 530 616 mSceneMgr = mRoot->getSceneManager(ST_GENERIC); 531 617 } 618 #else 619 if (msShowHillyTerrain) 620 { 621 //mSceneMgr = mRoot->createSceneManager("VisibilityTerrainSceneManager"); 622 mSceneMgr = mRoot->createSceneManager("TerrainSceneManager"); 623 } 624 else 625 { 626 mSceneMgr = mRoot->createSceneManager("VisibilityOctreeSceneManager"); 627 //mSceneMgr = mRoot->createSceneManager("OctreeSceneManager"); 628 } 629 630 #endif 532 631 } 533 632 //----------------------------------------------------------------------- … … 587 686 588 687 /**********************************************************************/ 589 /* VisualizationRenderTargetListener implementation*/688 /* VisualizationRenderTargetListener implementation */ 590 689 /**********************************************************************/ 591 690
Note: See TracChangeset
for help on using the changeset viewer.