- Timestamp:
- 02/17/07 22:48:12 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/Lib/Vis/OnlineCullingCHC/OGRE/src/OgreOcclusionCullingSceneManager.cpp
r2122 r2123 78 78 // TODO: set maxdepth to reasonable value 79 79 mMaxDepth = 50; 80 81 mObjReader = new ObjReader(this); 80 82 } 81 83 //----------------------------------------------------------------------- … … 107 109 CLEAR_CONTAINER(mObjects); 108 110 OGRE_DELETE(mCurrentViewCell); 111 112 OGRE_DELETE(mObjReader); 109 113 } 110 114 //----------------------------------------------------------------------- … … 379 383 selectPageSource(pageSourceName, optlist); 380 384 } 385 386 387 void OcclusionCullingSceneManager::MailPvsObjects() 388 { 389 GtpVisibilityPreprocessor::ObjectPvsIterator pit = 390 mCurrentViewCell->GetPvs().GetIterator(); 391 392 while (pit.HasMoreEntries()) 393 { 394 GtpVisibilityPreprocessor::Intersectable *obj = pit.Next(); 395 396 if (obj->Type() != 397 GtpVisibilityPreprocessor::Intersectable::ENGINE_INTERSECTABLE) 398 continue; 399 400 EngineIntersectable *oi = static_cast<EngineIntersectable *>(obj); 401 402 EntityContainer *entries = oi->GetItem(); 403 EntityContainer::const_iterator eit, eit_end = entries->end(); 404 405 for (eit = entries->begin(); eit != eit_end; ++ eit) 406 { 407 (*eit)->setUserAny(Any((int)0)); 408 } 409 } 410 } 411 //----------------------------------------------------------------------- 412 void OcclusionCullingSceneManager::ShowViewCellsGeometry() 413 {/* 414 // show only current view cell 415 if (!mShowViewCells) 416 { 417 const int id = mCurrentViewCell->GetId(); 418 419 MovableMap::iterator fit = mViewCellsGeometry.find(id); 420 421 if ((fit != mViewCellsGeometry.end()) && (*fit).second) 422 (*fit).second->_updateRenderQueue(getRenderQueue()); 423 } 424 else 425 { 426 MovableMap::const_iterator mit, mit_end = mViewCellsGeometry.end(); 427 428 for (mit = mViewCellsGeometry.begin(); mit != mit_end; ++ mit) 429 { 430 if ((*mit).second) 431 (*mit).second->_updateRenderQueue(getRenderQueue()); 432 } 433 }*/ 434 } 435 436 437 void OcclusionCullingSceneManager::RenderPvsEntry(GtpVisibilityPreprocessor::Intersectable *obj) 438 { 439 switch (obj->Type()) 440 { 441 case GtpVisibilityPreprocessor::Intersectable::OGRE_MESH_INSTANCE: 442 { 443 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(obj); 444 omi->GetEntity()->_updateRenderQueue(getRenderQueue()); 445 } 446 break; 447 448 case GtpVisibilityPreprocessor::Intersectable::ENGINE_INTERSECTABLE: 449 { 450 EngineIntersectable *oi = static_cast<EngineIntersectable *>(obj); 451 452 EntityContainer *entries = oi->GetItem(); 453 EntityContainer::const_iterator eit, eit_end = entries->end(); 454 455 for (eit = entries->begin(); eit != eit_end; ++ eit) 456 { 457 Entity *ent = *eit; 458 // mailing hack 459 Any newAny = ent->getUserAny(); 460 int flt = any_cast<int>(newAny); 461 462 if (any_cast<int>(newAny) == 0) 463 { 464 ent->setUserAny(Any((int)1)); 465 ent->_updateRenderQueue(getRenderQueue()); 466 } 467 } 468 } 469 break; 470 default: 471 break; 472 } 473 } 474 //----------------------------------------------------------------------- 475 void OcclusionCullingSceneManager::SetObjectVisible(GtpVisibilityPreprocessor::Intersectable *entry, 476 const bool visible) 477 { 478 switch (entry->Type()) 479 { 480 case GtpVisibilityPreprocessor::Intersectable::OGRE_MESH_INSTANCE: 481 { 482 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(entry); 483 omi->GetEntity()->setVisible(visible); 484 //GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl; 485 } 486 break; 487 case GtpVisibilityPreprocessor::Intersectable::ENGINE_INTERSECTABLE: 488 { 489 EngineIntersectable *oi = static_cast<EngineIntersectable *>(entry); 490 491 EntityContainer *entries = oi->GetItem(); 492 EntityContainer::const_iterator eit, eit_end = entries->end(); 493 for (eit = entries->begin(); eit != eit_end; ++ eit) 494 { 495 Entity *ent = *eit; 496 ent->setVisible(visible); 497 } 498 } 499 break; 500 default: 501 break; 502 } 503 } 381 504 //----------------------------------------------------------------------- 382 505 void OcclusionCullingSceneManager::PrepareVisualization(Camera *cam) … … 404 527 405 528 // show current view cell geometry 406 if (mCurrentViewCell && mCurrentViewCell->GetMesh())407 { /*529 if (mCurrentViewCell)// && mCurrentViewCell->GetMesh()) 530 { 408 531 //const bool showSingleViewCell = true; 409 532 if (mViewCellsGeometryLoaded) 410 533 { 411 if (!mShowViewCells) 412 { 413 const int id = mCurrentViewCell->GetId(); 414 415 MovableMap::iterator fit = mViewCellsGeometry.find(id); 416 417 if ((fit != mViewCellsGeometry.end()) && (*fit).second) 418 (*fit).second->_updateRenderQueue(getRenderQueue()); 419 } 420 else 421 { 422 MovableMap::const_iterator mit, mit_end = mViewCellsGeometry.end(); 423 424 for (mit = mViewCellsGeometry.begin(); mit != mit_end; ++ mit) 425 { 426 if ((*mit).second) 427 (*mit).second->_updateRenderQueue(getRenderQueue()); 428 } 429 } 430 } 431 */ 534 ShowViewCellsGeometry(); 535 } 536 432 537 ////////// 433 538 //-- set PVS of view cell visible 434 539 435 GtpVisibilityPreprocessor::ObjectPvsIterator pit = mCurrentViewCell->GetPvs().GetIterator(); 540 GtpVisibilityPreprocessor::ObjectPvsIterator pit = 541 mCurrentViewCell->GetPvs().GetIterator(); 542 543 MailPvsObjects(); 436 544 437 545 while (pit.HasMoreEntries()) 438 { 439 GtpVisibilityPreprocessor::ObjectPvsEntry entry = pit.Next(); 440 GtpVisibilityPreprocessor::Intersectable *obj = entry.mObject; 441 442 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(obj); 443 omi->GetEntity()->_updateRenderQueue(getRenderQueue()); 444 } 445 446 } 447 /* 546 { 547 RenderPvsEntry(pit.Next()); 548 } 549 } 550 #if 0 448 551 if (mRenderNodesForViz || mRenderNodesContentForViz) 449 552 { … … 479 582 } 480 583 } 481 }*/ 584 } 585 #endif 482 586 } 483 587 //----------------------------------------------------------------------- … … 601 705 { 602 706 // $$matt temp: Remove this!! 603 if ( 1)707 if (0) 604 708 { 605 709 getDestinationRenderSystem()->_setCullingMode(CULL_NONE); 606 LogManager::getSingleton().logMessage("warning: culling mode");710 //LogManager::getSingleton().logMessage("warning: culling mode"); 607 711 } 608 712 … … 1367 1471 GtpVisibilityPreprocessor::Intersectable *entry = *it; 1368 1472 1369 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(entry); 1370 omi->GetEntity()->setVisible(visible); 1371 //GtpVisibilityPreprocessor::Debug << "assigned id " << omi->GetId() << endl; 1473 SetObjectVisible(entry, visible); 1372 1474 } 1373 1475 } … … 1421 1523 } 1422 1524 1423 GtpVisibilityPreprocessor::ObjectPvsIterator pit = vc->GetPvs().GetIterator();1424 1425 1525 //////////// 1426 1526 //-- set PVS of view cell to visible … … 1429 1529 //LogManager::getSingleton().logMessage(d.str()); 1430 1530 1531 GtpVisibilityPreprocessor::ObjectPvsIterator pit = vc->GetPvs().GetIterator(); 1532 1431 1533 while (pit.HasMoreEntries()) 1432 1534 { 1433 GtpVisibilityPreprocessor::ObjectPvsEntry entry = pit.Next(); 1434 GtpVisibilityPreprocessor::Intersectable *obj = entry.mObject; 1535 GtpVisibilityPreprocessor::Intersectable *obj = pit.Next(); 1435 1536 1436 1537 // no associated geometry found 1437 1538 if (!obj) continue; 1438 1539 1439 OgreMeshInstance *omi = static_cast<OgreMeshInstance *>(obj); 1440 omi->GetEntity()->setVisible(load); 1540 SetObjectVisible(obj, load); 1441 1541 } 1442 1542 } … … 1706 1806 SceneNode *root) 1707 1807 { 1708 ObjReader objReader(this);1709 1710 1808 Timer *timer = PlatformManager::getSingleton().createTimer(); 1711 1809 timer->reset(); 1712 1810 1713 if (! objReader.LoadFile(filename.c_str(), viewCellsFile, root))1811 if (!mObjReader->LoadFile(filename.c_str(), viewCellsFile, root)) 1714 1812 { 1715 1813 PlatformManager::getSingleton().destroyTimer(timer);
Note: See TracChangeset
for help on using the changeset viewer.