Changeset 139 for trunk/VUT/Ogre/src
- Timestamp:
- 06/20/05 08:13:57 (19 years ago)
- Location:
- trunk/VUT/Ogre/src
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp
r135 r139 16 16 void OctreeHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node) 17 17 { 18 mNumTraversedNodes ++;18 ++ mNumTraversedNodes; 19 19 20 20 Octree *octree = static_cast<Octree *>(node); … … 107 107 108 108 dynamic_cast<OctreeSceneManager *>(mSceneManager)->_renderOctant(mCamera, 109 octant, mOnlyShadowCasters, mLeave TransparentsInQueue);109 octant, mOnlyShadowCasters, mLeavePassesInQueue); 110 110 111 111 mRenderedNodes.push_back(node); … … 134 134 AxisAlignedBox *OctreeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node) 135 135 { 136 if (node != mPreviousNode)136 if (node != mPreviousNode) 137 137 { 138 138 mPreviousNode = node; 139 //static_cast<Octree *>(node)->_getCullBounds(&mBox);139 //static_cast<Octree *>(node)->_getCullBounds(&mBox); 140 140 mBox = static_cast<Octree *>(node)->_getWorldAABB(); 141 //std::stringstream d; d << mBox;LogManager::getSingleton().logMessage(d.str()); 141 142 } 142 143 -
trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp
r135 r139 13 13 PlatformHierarchyInterface::PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys): 14 14 mSceneManager(sm), mRenderSystem(rsys), mSolidBoundingBox(NULL), mCamera(NULL), 15 mCullCamera(NULL), mOnlyShadowCasters(false), mLeave TransparentsInQueue(false),15 mCullCamera(NULL), mOnlyShadowCasters(false), mLeavePassesInQueue(0), 16 16 mIsBoundingBoxQuery(false) 17 17 { … … 131 131 //----------------------------------------------------------------------- 132 132 void PlatformHierarchyInterface::InitFrame(GtpVisibility::HierarchyNode *root, 133 Camera *cam, Camera *cullCam, bool leaveTransparentsInQueue)133 Camera *cam, Camera *cullCam, int leavePassesInQueue) 134 134 { 135 135 GtpVisibility::HierarchyInterface::InitFrame(root); 136 136 137 137 mPreviousNode = NULL; 138 mLeave TransparentsInQueue = leaveTransparentsInQueue;138 mLeavePassesInQueue = leavePassesInQueue; 139 139 140 140 mCamera = cam; 141 141 mCullCamera = cullCam ? cullCam : cam; 142 143 //if (mCullCamera != mCamera)144 // LogManager::getSingleton().logMessage("cullcamera is not camera");145 142 146 143 // create materials for node visualization … … 268 265 void PlatformHierarchyInterface::RenderGeometry(GtpVisibility::Mesh *geom) 269 266 { 270 mSceneManager->_renderMovableObject(geom, mLeave TransparentsInQueue);267 mSceneManager->_renderMovableObject(geom, mLeavePassesInQueue); 271 268 } 272 269 //----------------------------------------------------------------------- -
trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp
r130 r139 19 19 void SceneNodeHierarchyInterface::TraverseNode(GtpVisibility::HierarchyNode *node) 20 20 { 21 mNumTraversedNodes ++;21 ++ mNumTraversedNodes; 22 22 23 23 SceneNode *sceneNode = static_cast<SceneNode *>(node); … … 47 47 mRenderedNodes.push_back(node); 48 48 49 mSceneManager->_renderSceneNode(mCamera, sceneNode, mLeave TransparentsInQueue);49 mSceneManager->_renderSceneNode(mCamera, sceneNode, mLeavePassesInQueue); 50 50 } 51 51 #endif … … 151 151 { 152 152 Entity *ent = static_cast<Entity *>(movable); 153 //std::stringstream d; d << "ent " << ent->getName(); 154 //LogManager::getSingleton().logMessage(d.str()); 153 //std::stringstream d; d << "ent " << ent->getName(); LogManager::getSingleton().logMessage(d.str()); 155 154 geometryList->push_back(ent); 156 155 } -
trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp
r122 r139 21 21 mRenderNodesContentForViz(false), 22 22 mVisualizeCulledNodes(false), 23 mSkipTransparents(false),24 23 mDelayRenderTransparents(true), 25 mUseDepthPass(true) 24 mUseDepthPass(true), 25 mSkipTransparents(false) 26 26 { 27 27 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); … … 101 101 } 102 102 //----------------------------------------------------------------------- 103 void VisibilityOctreeSceneManager:: ShowVisualization(Camera *cam)103 void VisibilityOctreeSceneManager::PrepareVisualization(Camera *cam) 104 104 { 105 105 // add player camera for visualization purpose 106 try { 106 try 107 { 107 108 Camera *c; 108 109 if ((c = getCamera("PlayerCam")) != NULL) … … 129 130 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 130 131 { 131 132 132 if (mRenderNodesForViz) 133 133 { … … 150 150 if (mShowVisualization) 151 151 { 152 ShowVisualization(cam);152 PrepareVisualization(cam); 153 153 } 154 154 else … … 189 189 leaveTransparentsInQueue); 190 190 191 // call initframe toreset culling manager stats191 // reset culling manager stats 192 192 mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 193 193 … … 204 204 205 205 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 206 _deleteRenderedQueueGroups( false);206 _deleteRenderedQueueGroups(); 207 207 #endif 208 208 … … 272 272 return true; 273 273 } 274 if (key == " ShowVisualization")274 if (key == "PrepareVisualization") 275 275 { 276 276 mShowVisualization = (*static_cast<const bool *>(val)); -
trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp
r115 r139 43 43 mHierarchyInterface->InitFrame(mSceneRoot, mCameraInProgress); 44 44 45 // call initframe toreset culling manager stats45 // reset culling manager stats 46 46 mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 47 47 } … … 68 68 69 69 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 70 _deleteRenderedQueueGroups( false);70 _deleteRenderedQueueGroups(); 71 71 #endif 72 72 … … 84 84 85 85 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 86 //_deleteRenderedQueueGroups();86 _deleteRenderedQueueGroups(); 87 87 #endif 88 88 -
trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp
r137 r139 21 21 mRenderNodesContentForViz(false), 22 22 mVisualizeCulledNodes(false), 23 m SkipTransparents(false),23 mLeavePassesInQueue(0), 24 24 mDelayRenderTransparents(true), 25 25 mUseDepthPass(false), 26 26 mRenderItemBuffer(false), 27 27 mCurrentEntityId(0), 28 mEnableDepthWrite(true) 28 mEnableDepthWrite(true), 29 mSkipTransparents(false), 30 mSavedShadowTechnique(SHADOWTYPE_NONE) 29 31 { 30 32 mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); … … 32 34 33 35 mVisibilityManager->SetQueryManager(mQueryManager); 36 34 37 //mDisplayNodes = true; 35 38 //mShowBoundingBoxes = true; … … 97 100 } 98 101 //----------------------------------------------------------------------- 99 void VisibilityTerrainSceneManager:: ShowVisualization(Camera *cam)102 void VisibilityTerrainSceneManager::PrepareVisualization(Camera *cam) 100 103 { 101 104 // add player camera for visualization purpose … … 128 131 if (mRenderNodesForViz) 129 132 { 130 //getRenderQueue()->addRenderable(*it); 133 OctreeNode *node = *it; 134 if ((node->numAttachedObjects() > 0) && (node->numChildren() == 0) 135 && node->getAttachedObject(0)->getMovableType() == "Entity") 136 getRenderQueue()->addRenderable(node); 131 137 132 138 // addbounding boxes instead of node itself 133 (*it)->_addBoundingBoxToQueue(getRenderQueue());139 //(*it)->_addBoundingBoxToQueue(getRenderQueue()); 134 140 } 135 141 if (mRenderNodesContentForViz) … … 143 149 Pass *VisibilityTerrainSceneManager::setPass(Pass* pass) 144 150 { 145 //Pass *usedPass = ((mRenderDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass); // setting vertex program is not efficient 151 // TODO: setting vertex program is not efficient 152 //Pass *usedPass = ((mRenderDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass); 146 153 147 154 // set depth fill pass only if depth write enabled … … 182 189 183 190 bool IsDepthWrite = usedPass->getDepthWriteEnabled(); 191 184 192 // global option which enables / disables depth writes 185 193 if (!mEnableDepthWrite) … … 187 195 usedPass->setDepthWriteEnabled(false); 188 196 } 189 190 197 //else if (mIsItemBufferPass) {usedPass = mItemBufferPass;} 191 198 … … 207 214 { 208 215 // needs full ambient lighting for item colors to be exact 209 /*if (mRenderItemBuffer) 210 { setAmbientLight(ColourValue(1,1,1,1)); }*/ 216 //if (mRenderItemBuffer) {setAmbientLight(ColourValue(1,1,1,1));} 211 217 212 218 //-- show visible scene nodes and octree bounding boxes from last frame 213 219 if (mShowVisualization) 214 220 { 215 ShowVisualization(cam); 216 } 217 221 PrepareVisualization(cam); 222 } 223 else 224 { 225 // we interleave identification and rendering of objects 226 // in _renderVisibibleObjects 227 228 // only shadow casters will be rendered in shadow texture pass 229 mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 230 //InitVisibilityCulling(cam); 231 } 218 232 //TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 219 233 220 234 mVisible.clear(); 221 235 mBoxes.clear(); 222 223 // if there is no depth pass => 224 // we interleave identification and rendering of objects 225 // in _renderVisibibleObjects 226 227 // only shadow casters will be rendered in shadow texture pass 228 mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 229 230 bool leaveTransparentsInQueue = mDelayRenderTransparents && !mUseDepthPass; 231 232 // possible two cameras (one for culling, one for rendering) 233 mHierarchyInterface->InitFrame(mOctree, cam, //mCameraInProgress, 234 mCullCamera ? getCamera("CullCamera") : NULL, 235 leaveTransparentsInQueue); 236 236 237 } 237 238 //----------------------------------------------------------------------- 238 239 void VisibilityTerrainSceneManager::_renderVisibleObjects() 239 240 { 240 // increase terrain renderlevel241 int renderLevel = TerrainRenderable::getCurrentRenderLevelIndex() + 1;242 243 if (TerrainRenderable::getCurrentRenderLevelIndex() >= 10)244 { // max. 10 different renderlevels245 renderLevel = 0;246 }247 248 241 // visualization: apply standard rendering 249 242 if (mShowVisualization) 250 243 { 244 IlluminationRenderStage savedStage = mIlluminationStage; 245 246 // disable illumination stage so we have no shadow rendering 247 mIlluminationStage = IRS_NONE; 248 251 249 TerrainSceneManager::_renderVisibleObjects(); 252 TerrainRenderable::setCurrentRenderLevelIndex(renderLevel); 253 return; 254 } 255 256 InitDepthPass(); // create material for depth pass 257 InitItemBufferPass(); // create material for item buffer pass 258 259 //-- hierarchical culling 260 // the objects of different layers (e.g., background, scene, 261 // overlay) must be identified and rendered one after another 262 263 // frame initialisation to reset culling manager stats 264 mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 265 266 mSkipTransparents = false; 267 268 //-- render background, in case there is one 269 clearSpecialCaseRenderQueues(); 270 addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND); 271 addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY); 272 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 273 274 TerrainSceneManager::_renderVisibleObjects(); 250 } 251 else 252 { 253 //-- hierarchical culling 254 // the objects of different layers (e.g., background, scene, 255 // overlay) must be identified and rendered one after another 256 257 //-- render all early skies 258 clearSpecialCaseRenderQueues(); 259 addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND); 260 addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY); 261 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 262 263 TerrainSceneManager::_renderVisibleObjects(); 275 264 276 265 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 277 _deleteRenderedQueueGroups(false);266 _deleteRenderedQueueGroups(); 278 267 #endif 279 268 280 //-- render visible objects (i.e., all but overlay and skies late) 281 clearSpecialCaseRenderQueues(); 282 addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE); 283 addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY); 284 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 285 286 // transparents are skipped from hierarchical rendering 287 // => they need sorting, thus we render them afterwards 288 mSkipTransparents = mDelayRenderTransparents; 289 290 // set state for depth pass 291 mRenderDepthPass = mUseDepthPass; 292 293 /** 294 * the hierarchical culling algorithm 295 * for depth pass: will just find objects and update depth buffer 296 * for delayed rendering: will render all but transparents 297 **/ 298 299 mVisibilityManager->ApplyVisibilityCulling(); 300 301 // delete remaining renderables from queue (or all but transparents) 269 //-- prepare queue for visible objects (i.e., all but overlay and skies late) 270 clearSpecialCaseRenderQueues(); 271 addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE); 272 addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY); 273 setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 274 275 276 //-- set all necessary parameters for hierarchical visibility culling and rendering 277 InitVisibilityCulling(mCameraInProgress); 278 279 /** 280 * the hierarchical culling algorithm 281 * if using depth pass: will just find objects and update depth buffer 282 * for "delayed" rendering: will render some passes afterwards, e.g. transparents 283 **/ 284 285 mVisibilityManager->ApplyVisibilityCulling(); 286 287 // delete remaining renderables from queue (all not in mLeavePassesInQueue) 302 288 #ifdef GTP_VISIBILITY_MODIFIED_OGRE 303 _deleteRenderedQueueGroups(mSkipTransparents);289 _deleteRenderedQueueGroups(mLeavePassesInQueue); 304 290 #endif 305 291 306 // for depth pass: add visible nodes found with the visibility culling 307 if (mUseDepthPass) 308 { 309 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 310 { 311 (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 312 } 292 //-- reset parameters 313 293 mRenderDepthPass = false; 314 } 315 316 mSkipTransparents = false; 317 318 //-- now we can render all remaining queue objects 319 // for depth pass: all 320 // for delayed rendering: transparents, overlay 321 clearSpecialCaseRenderQueues(); 322 TerrainSceneManager::_renderVisibleObjects(); 323 324 TerrainRenderable::setCurrentRenderLevelIndex(renderLevel); 294 mSkipTransparents = false; 295 mLeavePassesInQueue = 0; 296 mShadowTechnique = mSavedShadowTechnique; 297 298 299 // add visible nodes found by the visibility culling algorithm 300 if (mUseDepthPass) 301 { 302 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 303 { 304 (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 305 } 306 } 307 308 //-- now we can render all remaining queue objects 309 // for depth pass, transparents, overlay 310 clearSpecialCaseRenderQueues(); 311 TerrainSceneManager::_renderVisibleObjects(); 312 } 313 314 // set the new render level index afterwards => new level in the next frame 315 TerrainRenderable::setCurrentRenderLevelIndex( 316 (TerrainRenderable::getCurrentRenderLevelIndex() + 1) % 10); 317 325 318 getRenderQueue()->clear(); 326 319 //WriteLog(); // write out stats … … 346 339 return true; 347 340 } 348 if (key == " ShowVisualization")341 if (key == "PrepareVisualization") 349 342 { 350 343 mShowVisualization = (*static_cast<const bool *>(val)); … … 453 446 } 454 447 //----------------------------------------------------------------------- 455 void VisibilityTerrainSceneManager::renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs, 456 bool doLightIteration, const LightList* manualLightList) 448 void VisibilityTerrainSceneManager::renderObjects( 449 const RenderPriorityGroup::TransparentRenderablePassList& objs, 450 bool doLightIteration, const LightList* manualLightList) 457 451 { 458 452 // for correct rendering, transparents must be rendered after hierarchical culling … … 519 513 std::stringstream d; d << "itembuffer, pass name: " << 520 514 ipass->first->getParent()->getParent()->getName(); 521 //<< ", renderable name: " << irend-> 522 515 523 516 LogManager::getSingleton().logMessage(d.str()); 524 517 525 //if(ipass->first->getParent()->getParent()->getName() == "Examples/Athene") 526 //<< ", renderable name: " << irend-> 527 RenderSingleObjectForItemBuffer(*irend, ipass->first); 528 //RenderSingleObjectForOcclusionQuery( 518 RenderSingleObjectForItemBuffer(*irend, ipass->first); 529 519 } 530 520 } … … 556 546 mItemBufferPass->setAmbient(ColourValue(0, 1, 1)); 557 547 //mItemBufferPass->setDiffuse(ColourValue(0, col, 0)); 558 //mItemBufferPass->setSpecular(ColourValue(0, col, 0));559 //mItemBufferPass->_load();548 //mItemBufferPass->setSpecular(ColourValue(0, col, 0)); 549 //mItemBufferPass->_load(); 560 550 561 551 // set vertex program of current pass … … 579 569 } 580 570 581 //LogManager::getSingleton().logMessage("has vertex program");582 571 Pass *usedPass = setPass(mItemBufferPass); 583 572 //Pass *usedPass = setPass(pass); 584 std::stringstream d;585 d << "item buffer id: " << rend->getId() << ", col: " << col;573 574 std::stringstream d; d << "item buffer id: " << rend->getId() << ", col: " << col; 586 575 LogManager::getSingleton().logMessage(d.str()); 587 576 … … 607 596 return ent; 608 597 } 609 598 //----------------------------------------------------------------------- 599 void VisibilityTerrainSceneManager::InitVisibilityCulling(Camera *cam) 600 { 601 InitDepthPass(); // create material for depth pass 602 InitItemBufferPass(); // create material for item buffer pass 603 604 // save shadow technique so after first pass it can be reset 605 mSavedShadowTechnique = mShadowTechnique; 606 607 608 // set passes which should be stored in render queue for rendering afterwards 609 mLeavePassesInQueue = 0; 610 611 /* if (mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE) 612 { 613 mShadowTechnique = SHADOWTYPE_NONE; 614 615 if (!mUseDepthPass) 616 { 617 // TODO: remove this 618 mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_NOSHADOW; 619 620 mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_DECAL; 621 mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_DIFFUSE_SPECULAR; 622 mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES; 623 } 624 } 625 if (mShadowTechnique == SHADOWTYPE_STENCIL_MODULATIVE) 626 { 627 mShadowTechnique = SHADOWTYPE_NONE; 628 629 if (!mUseDepthPass) 630 { 631 mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_NOSHADOW; 632 mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES; 633 } 634 } 635 */ 636 if (mDelayRenderTransparents && (!mUseDepthPass)) 637 { 638 mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES; 639 } 640 std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue; 641 LogManager::getSingleton().logMessage(d.str()); 642 643 // possible two cameras (one for culling, one for rendering) 644 mHierarchyInterface->InitFrame(mOctree, cam, 645 mCullCamera ? getCamera("CullCamera") : NULL, 646 mLeavePassesInQueue); 647 648 649 // reset culling manager stats 650 mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 651 652 // set depth pass flag before rendering 653 mRenderDepthPass = mUseDepthPass; 654 655 // set flag for skipping transparents for this rendering pass 656 mSkipTransparents = mUseDepthPass || (mLeavePassesInQueue & 657 RenderPriorityGroup::TRANSPARENT_PASSES); 658 } 659 660 //----------------------------------------------------------------------- 661 /*void VisibilityTerrainSceneManager::renderBasicQueueGroupObjects(RenderQueueGroup* pGroup) 662 { 663 // Basic render loop 664 // Iterate through priorities 665 RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator(); 666 667 while (groupIt.hasMoreElements()) 668 { 669 RenderPriorityGroup* pPriorityGrp = groupIt.getNext(); 670 671 // Sort the queue first 672 pPriorityGrp->sort(mCameraInProgress); 673 674 //TODO: render other splid passes for shadows 675 // Do solids 676 renderObjects(pPriorityGrp->_getSolidPassesNoShadows(), true); 677 678 // do solid passes no shadows if addititive stencil shadows 679 if (mSavedShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE) 680 renderObjects(pPriorityGrp->_getSolidPassesNoShadows(), true); 681 682 // Do transparents 683 renderObjects(pPriorityGrp->_getTransparentPasses(), true); 684 685 686 }// for each priority 687 } 688 */ 610 689 } // namespace Ogre
Note: See TracChangeset
for help on using the changeset viewer.