source: trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp @ 139

Revision 139, 22.3 KB checked in by mattausch, 19 years ago (diff)

fixed bug with tight octree boxes
added more flexible renderqueue (can delete per flag)
reordered functions in visibility terrain scene manager

Line 
1#include "OgreVisibilityTerrainSceneManager.h"
2#include "OgreVisibilityOptionsManager.h"
3#include <OgreMath.h>
4#include <OgreIteratorWrappers.h>
5#include <OgreRenderSystem.h>
6#include <OgreCamera.h>
7#include <OgreLogManager.h>
8#include <OgreStringConverter.h>
9#include <OgreEntity.h>
10#include <OgreSubEntity.h>
11
12namespace Ogre {
13
14//-----------------------------------------------------------------------
15VisibilityTerrainSceneManager::VisibilityTerrainSceneManager(
16        GtpVisibility::VisibilityManager *visManager):
17mVisibilityManager(visManager),
18mRenderDepthPass(false),
19mShowVisualization(false),
20mRenderNodesForViz(false),
21mRenderNodesContentForViz(false),
22mVisualizeCulledNodes(false),
23mLeavePassesInQueue(0),
24mDelayRenderTransparents(true),
25mUseDepthPass(false),
26mRenderItemBuffer(false),
27mCurrentEntityId(0),
28mEnableDepthWrite(true),
29mSkipTransparents(false),
30mSavedShadowTechnique(SHADOWTYPE_NONE)
31{
32        mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem);
33        mQueryManager = new PlatformQueryManager(mHierarchyInterface, mCurrentViewport);
34
35        mVisibilityManager->SetQueryManager(mQueryManager);
36       
37        //mDisplayNodes = true;
38        //mShowBoundingBoxes = true;
39
40        // TODO: set maxdepth to reasonable value
41        mMaxDepth = 50;
42}
43//-----------------------------------------------------------------------
44void VisibilityTerrainSceneManager::InitDepthPass()
45{
46        MaterialPtr depthMat = MaterialManager::getSingleton().getByName("Visibility/DepthPass");
47
48        if (depthMat.isNull())
49    {
50                // Init
51                depthMat = MaterialManager::getSingleton().create(
52                "Visibility/DepthPass",
53                ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
54        mDepthPass = depthMat->getTechnique(0)->getPass(0);
55                mDepthPass->setColourWriteEnabled(false);
56                mDepthPass->setDepthWriteEnabled(true);
57                mDepthPass->setLightingEnabled(false);
58        }
59        else
60        {
61                mDepthPass = depthMat->getTechnique(0)->getPass(0);
62        }
63}
64//-----------------------------------------------------------------------
65void VisibilityTerrainSceneManager::InitItemBufferPass()
66{
67        MaterialPtr itemBufferMat = MaterialManager::getSingleton().
68                getByName("Visibility/ItemBufferPass");
69
70        if (itemBufferMat.isNull())
71    {
72                // Init
73                itemBufferMat = MaterialManager::getSingleton().create("Visibility/ItemBufferPass",
74                ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME);
75
76                mItemBufferPass = itemBufferMat->getTechnique(0)->getPass(0);
77                mItemBufferPass->setColourWriteEnabled(true);
78                mItemBufferPass->setDepthWriteEnabled(true);
79                mItemBufferPass->setLightingEnabled(true);
80        }
81        else
82        {
83                mItemBufferPass = itemBufferMat->getTechnique(0)->getPass(0);
84        }
85        mItemBufferPass->setAmbient(1, 1, 0);
86}
87//-----------------------------------------------------------------------
88VisibilityTerrainSceneManager::~VisibilityTerrainSceneManager()
89{
90        if (mHierarchyInterface)
91        {
92                delete mHierarchyInterface;
93                mHierarchyInterface = NULL;
94        }
95        if (mQueryManager)
96        {
97                delete mQueryManager;
98                mQueryManager = NULL;
99        }
100}
101//-----------------------------------------------------------------------
102void VisibilityTerrainSceneManager::PrepareVisualization(Camera *cam)
103{
104        // add player camera for visualization purpose
105        try
106        {
107                Camera *c;
108                if ((c = getCamera("PlayerCam")) != NULL)
109                {
110                        getRenderQueue()->addRenderable(c);
111                }   
112    }
113    catch (...)
114    {
115        // ignore
116    }
117        for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it)
118        {
119                getRenderQueue()->addRenderable(*it);
120        }
121        if (mRenderNodesForViz || mRenderNodesContentForViz)
122        {
123                // change node material so it is better suited for visualization
124                MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial");
125                nodeMat->setAmbient(1, 1, 0);
126                nodeMat->setLightingEnabled(true);
127                nodeMat->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();
128
129                for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it)
130                {
131                        if (mRenderNodesForViz)
132                        {
133                                OctreeNode *node = *it;
134                                if ((node->numAttachedObjects() > 0) && (node->numChildren() == 0)
135                                        && node->getAttachedObject(0)->getMovableType() == "Entity")
136                                getRenderQueue()->addRenderable(node);
137
138                                // addbounding boxes instead of node itself
139                                //(*it)->_addBoundingBoxToQueue(getRenderQueue());
140                        }
141                        if (mRenderNodesContentForViz)
142                        {
143                                (*it)->_addToRenderQueue(cam, getRenderQueue(), false);
144                        }
145                }
146        }       
147}
148//-----------------------------------------------------------------------
149Pass *VisibilityTerrainSceneManager::setPass(Pass* pass)
150{
151        // TODO: setting vertex program is not efficient
152        //Pass *usedPass = ((mRenderDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass);
153       
154        // set depth fill pass only if depth write enabled
155        Pass *usedPass = (mRenderDepthPass && !mHierarchyInterface->IsBoundingBoxQuery() ?
156                                          mDepthPass : pass);
157               
158        IlluminationRenderStage savedStage = mIlluminationStage;
159       
160        // set illumination stage to NONE so no shadow material is used
161        // for depth pass or for occlusion query
162        if (mRenderDepthPass || mHierarchyInterface->IsBoundingBoxQuery())
163        {
164                mIlluminationStage = IRS_NONE;
165        }
166       
167        if (mRenderDepthPass)
168        {
169                // --- set vertex program of current pass so z-buffer is updated correctly
170        if (pass->hasVertexProgram())
171                {
172                        mDepthPass->setVertexProgram(pass->getVertexProgramName());
173
174                        if (mDepthPass->hasVertexProgram())
175                        {
176                                const GpuProgramPtr& prg = mDepthPass->getVertexProgram();
177                                // Load this program if not done already
178                                if (!prg->isLoaded())
179                                        prg->load();
180                                // Copy params
181                                mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters());
182                        }
183                }
184                else if (mDepthPass->hasVertexProgram())
185                {
186                        mDepthPass->setVertexProgram("");
187                }
188        }
189
190        bool IsDepthWrite = usedPass->getDepthWriteEnabled();
191
192        // global option which enables / disables depth writes
193        if (!mEnableDepthWrite)
194        {
195                usedPass->setDepthWriteEnabled(false);
196        }
197        //else if (mIsItemBufferPass) {usedPass = mItemBufferPass;}
198       
199        Pass *result = SceneManager::setPass(usedPass);
200
201        // reset depth write
202        if (!mEnableDepthWrite)
203        {
204                usedPass->setDepthWriteEnabled(IsDepthWrite);
205        }
206
207        // reset illumination stage
208        mIlluminationStage = savedStage;
209
210        return result;
211}
212//-----------------------------------------------------------------------
213void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters)
214{
215        // needs full ambient lighting for item colors to be exact
216        //if (mRenderItemBuffer) {setAmbientLight(ColourValue(1,1,1,1));}
217       
218        //-- show visible scene nodes and octree bounding boxes from last frame
219        if (mShowVisualization)
220    {
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        }
232        //TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters);
233       
234        mVisible.clear();
235        mBoxes.clear();
236
237}
238//-----------------------------------------------------------------------
239void VisibilityTerrainSceneManager::_renderVisibleObjects()
240{
241        // visualization: apply standard rendering
242        if (mShowVisualization)
243        {       
244                IlluminationRenderStage savedStage = mIlluminationStage;
245       
246                // disable illumination stage so we have no shadow rendering
247                mIlluminationStage = IRS_NONE;
248       
249                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();
264
265#ifdef GTP_VISIBILITY_MODIFIED_OGRE
266                _deleteRenderedQueueGroups();
267#endif
268
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)
288#ifdef GTP_VISIBILITY_MODIFIED_OGRE
289                _deleteRenderedQueueGroups(mLeavePassesInQueue);
290#endif
291
292                //-- reset parameters
293                mRenderDepthPass = false;
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
318        getRenderQueue()->clear();
319        //WriteLog(); // write out stats
320}
321
322//-----------------------------------------------------------------------
323void VisibilityTerrainSceneManager::_updateSceneGraph(Camera* cam)
324{
325        mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface);
326        mHierarchyInterface->SetRenderSystem(mDestRenderSystem);
327
328#ifdef GTP_VISIBILITY_MODIFIED_OGRE
329    mHierarchyInterface->SetNumOctreeNodes(mNumOctreeNodes);
330#endif
331        TerrainSceneManager::_updateSceneGraph(cam);
332}
333//-----------------------------------------------------------------------
334bool VisibilityTerrainSceneManager::setOption(const String & key, const void * val)
335{
336        if (key == "UseDepthPass")
337        {
338                mUseDepthPass = (*static_cast<const bool *>(val));
339                return true;
340        }
341        if (key == "PrepareVisualization")
342        {
343                mShowVisualization = (*static_cast<const bool *>(val));
344                return true;
345        }
346        if (key == "RenderNodesForViz")
347        {
348                mRenderNodesForViz = (*static_cast<const bool *>(val));
349                return true;
350        }
351        if (key == "RenderNodesContentForViz")
352        {
353                mRenderNodesContentForViz = (*static_cast<const bool *>(val));
354                return true;
355        }
356        if (key == "SkyBoxEnabled")
357        {
358                mSkyBoxEnabled = (*static_cast<const bool *>(val));
359                return true;
360        }
361        if (key == "SkyPlaneEnabled")
362        {
363                mSkyPlaneEnabled = (*static_cast<const bool *>(val));
364                return true;
365        }
366        if (key == "SkyDomeEnabled")
367        {
368                mSkyDomeEnabled = (*static_cast<const bool *>(val));
369                return true;
370        }
371        if (key == "VisualizeCulledNodes")
372        {
373                mVisualizeCulledNodes = (*static_cast<const bool *>(val));
374                return true;
375        }
376        if (key == "DelayRenderTransparents")
377        {
378                mDelayRenderTransparents = (*static_cast<const bool *>(val));
379                return true;
380        }
381        // notifiy that frame has ended so terrain render level can be reset for correct
382        // terrain rendering
383        if (key == "TerrainLevelIdx")
384        {
385                TerrainRenderable::setCurrentRenderLevelIndex((*static_cast<const int *>(val)));
386                return true;
387        }
388        if (key == "DepthWrite")
389        {
390                mEnableDepthWrite = (*static_cast<const bool *>(val));
391                return true;
392        }
393        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
394                setOption(key, val) || TerrainSceneManager::setOption(key, val);
395}
396//-----------------------------------------------------------------------
397bool VisibilityTerrainSceneManager::getOption(const String & key, void *val)
398{
399        if (key == "NumHierarchyNodes")
400        {
401                * static_cast<unsigned int *>(val) = (unsigned int)mNumOctreeNodes;
402                return true;
403        }
404       
405        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
406                getOption(key, val) && TerrainSceneManager::getOption(key, val);
407}
408//-----------------------------------------------------------------------
409bool VisibilityTerrainSceneManager::getOptionValues(const String & key, StringVector &refValueList)
410{
411        return TerrainSceneManager::getOptionValues( key, refValueList);
412}
413//-----------------------------------------------------------------------
414bool VisibilityTerrainSceneManager::getOptionKeys(StringVector & refKeys)
415{
416        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface).
417                getOptionKeys(refKeys) || TerrainSceneManager::getOptionKeys(refKeys);
418}
419//-----------------------------------------------------------------------
420void VisibilityTerrainSceneManager::setVisibilityManager(GtpVisibility::VisibilityManager *visManager)
421{
422        mVisibilityManager = visManager;
423}
424//-----------------------------------------------------------------------
425GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::getVisibilityManager( void )
426{
427        return mVisibilityManager;
428}
429//-----------------------------------------------------------------------
430void VisibilityTerrainSceneManager::WriteLog()
431{
432        std::stringstream d;
433
434        d << "Depth pass: " << StringConverter::toString(mUseDepthPass) << ", "
435          << "Delay transparents: " << StringConverter::toString(mDelayRenderTransparents) << ", "
436          << "Use optimization: " << StringConverter::toString(mHierarchyInterface->GetUseOptimization()) << ", "
437          << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", "
438          << "Hierarchy nodes: " << mNumOctreeNodes << ", "
439          << "Traversed nodes: " << mHierarchyInterface->GetNumTraversedNodes() << ", "
440          << "Rendered nodes: " << mHierarchyInterface->GetNumRenderedNodes() << ", "
441          << "Query culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumQueryCulledNodes() << ", "
442          << "Frustum culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumFrustumCulledNodes() << ", "
443      << "Queries issued: " << mVisibilityManager->GetCullingManager()->GetNumQueriesIssued() << "\n";
444
445        LogManager::getSingleton().logMessage(d.str());
446}
447//-----------------------------------------------------------------------
448void VisibilityTerrainSceneManager::renderObjects(
449        const RenderPriorityGroup::TransparentRenderablePassList& objs,
450    bool doLightIteration, const LightList* manualLightList)
451{
452        // for correct rendering, transparents must be rendered after hierarchical culling
453        if (!mSkipTransparents)
454        {
455                OctreeSceneManager::renderObjects(objs, doLightIteration, manualLightList);
456        }
457}
458//-----------------------------------------------------------------------
459bool VisibilityTerrainSceneManager::validatePassForRendering(Pass* pass)
460{
461        // skip all but first pass if we are doing the depth pass
462        if ((mRenderDepthPass || mRenderItemBuffer) && pass->getIndex() > 0)
463        {
464                return false;
465        }
466        return SceneManager::validatePassForRendering(pass);
467}
468//-----------------------------------------------------------------------
469void VisibilityTerrainSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup)
470{
471        if (!mRenderItemBuffer)
472        {
473                TerrainSceneManager::renderQueueGroupObjects(pGroup);
474                return;
475        }
476
477        //--- item buffer
478    // Iterate through priorities
479    RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator();
480
481        while (groupIt.hasMoreElements())
482    {
483                RenderItemBuffer(groupIt.getNext());
484        }
485}
486//-----------------------------------------------------------------------
487void VisibilityTerrainSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup)
488{
489        // Do solids
490        RenderPriorityGroup::SolidRenderablePassMap solidObjs = pGroup->_getSolidPasses();
491
492        // ----- SOLIDS LOOP -----
493        RenderPriorityGroup::SolidRenderablePassMap::const_iterator ipass, ipassend;
494        ipassend = solidObjs.end();
495
496        for (ipass = solidObjs.begin(); ipass != ipassend; ++ipass)
497        {
498                // Fast bypass if this group is now empty
499                if (ipass->second->empty())
500                        continue;
501
502                // Render only first pass
503                if (ipass->first->getIndex() > 0)
504                        continue;
505
506                RenderPriorityGroup::RenderableList* rendList = ipass->second;
507               
508                RenderPriorityGroup::RenderableList::const_iterator irend, irendend;
509                irendend = rendList->end();
510                       
511                for (irend = rendList->begin(); irend != irendend; ++irend)
512                {
513                        std::stringstream d; d << "itembuffer, pass name: " <<
514                                ipass->first->getParent()->getParent()->getName();
515                               
516                        LogManager::getSingleton().logMessage(d.str());
517                       
518                        RenderSingleObjectForItemBuffer(*irend, ipass->first);
519                }
520        }
521
522        // ----- TRANSPARENT LOOP: must be handled differently
523        // although we don't really     care about transparents for the item buffer
524        // TODO: HOW TO HANDLE OCCLUDED OBJECTS ????
525        RenderPriorityGroup::TransparentRenderablePassList
526                transpObjs = pGroup->_getTransparentPasses();
527        RenderPriorityGroup::TransparentRenderablePassList::const_iterator itrans, itransend;
528
529        itransend = transpObjs.end();
530        for (itrans = transpObjs.begin(); itrans != itransend; ++itrans)
531        {
532                // like for solids, render only first pass
533                if (itrans->pass->getIndex() == 0)
534                {       
535                        RenderSingleObjectForItemBuffer(itrans->renderable, itrans->pass);
536                }
537        }
538}
539//-----------------------------------------------------------------------
540void VisibilityTerrainSceneManager::RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass)
541{
542        static LightList nullLightList;
543
544        Real col = (Real)rend->getId() / (Real)mCurrentEntityId;
545
546        mItemBufferPass->setAmbient(ColourValue(0, 1, 1));
547        //mItemBufferPass->setDiffuse(ColourValue(0, col, 0));
548    //mItemBufferPass->setSpecular(ColourValue(0, col, 0));
549    //mItemBufferPass->_load();
550
551        // set vertex program of current pass
552        if (pass->hasVertexProgram())
553        {
554                mItemBufferPass->setVertexProgram(pass->getVertexProgramName());
555
556                if (mItemBufferPass->hasVertexProgram())
557                {
558                        const GpuProgramPtr& prg = mItemBufferPass->getVertexProgram();
559                        // Load this program if not done already
560                        if (!prg->isLoaded())
561                                prg->load();
562                        // Copy params
563                        mItemBufferPass->setVertexProgramParameters(pass->getVertexProgramParameters());
564                }
565        }
566        else if (mItemBufferPass->hasVertexProgram())
567        {
568                mItemBufferPass->setVertexProgram("");
569        }
570
571        Pass *usedPass = setPass(mItemBufferPass);
572        //Pass *usedPass = setPass(pass);
573       
574        std::stringstream d; d << "item buffer id: " << rend->getId() << ", col: " << col;
575        LogManager::getSingleton().logMessage(d.str());
576
577        // Render a single object, this will set up auto params if required
578        renderSingleObject(rend, usedPass, false, &nullLightList);
579}
580//-----------------------------------------------------------------------
581GtpVisibility::VisibilityManager *VisibilityTerrainSceneManager::GetVisibilityManager()
582{
583        return mVisibilityManager;
584}
585//-----------------------------------------------------------------------
586Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName,
587                                                                                                        const String& meshName)
588{
589        Entity *ent = SceneManager::createEntity(entityName, meshName);
590
591        for (int i = 0; i < (int)ent->getNumSubEntities(); ++i)
592        {
593                ent->getSubEntity(i)->setId(mCurrentEntityId ++);
594        }
595
596        return ent;
597}
598//-----------------------------------------------------------------------
599void 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*/
689} // namespace Ogre
Note: See TracBrowser for help on using the repository browser.