Changeset 118 for trunk/VUT/Ogre


Ignore:
Timestamp:
05/30/05 18:40:33 (19 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/Ogre
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h

    r115 r118  
    2828 
    2929        /** Sets the given option for the SceneManager 
    30                             @remarks 
    31                 Options are: 
    32                 "Algorithm", int *;                      
     30                @remarks Options are: "Algorithm", int *;                        
    3331        */ 
     32         
    3433        virtual bool setOption(const String &, const void *); 
    3534        /** Gets the given option for the Scene VisibilityManager. 
     
    4847        /** See set. 
    4948        */ 
    50         GtpVisibility::VisibilityManager *getVisibilityManager( void ); 
    51  
    52         /** Writes out stats into the Ogre log file. 
    53         */ 
    54         void WriteLog(); 
     49        GtpVisibility::VisibilityManager *getVisibilityManager(); 
    5550         
    5651        /** Render a set of objects, see renderSingleObject for param definitions  
     
    5954        virtual void renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs,  
    6055            bool doLightIteration, const LightList* manualLightList = 0); 
     56 
     57        /** Writes out stats into the Ogre log file. 
     58        */ 
     59        void WriteLog(); 
     60 
     61        /** Override pass so we can do the z-fail pass */ 
     62        Pass* setPass(Pass* pass); 
     63 
    6164protected: 
    62  
     65        /** Creates material for depth pass, e.g., a pass that only fills the depth buffer */ 
    6366        void CreateDepthPass(); 
    64  
     67        void ShowVisualization(Camera *cam); 
    6568        OctreeHierarchyInterface *mHierarchyInterface; 
    6669        GtpVisibility::VisibilityManager *mVisibilityManager; 
     
    7477        bool mDelayRenderTransparents; 
    7578        bool mUseDepthPass; 
     79        bool mIsDepthPass; 
    7680 
    7781        Pass *mDepthPass; 
  • trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h

    r115 r118  
    33 
    44#include <OgreSceneNode.h> 
    5 #include <OgreOctreeSceneManager.h> 
    65#include <OgreTerrainSceneManager.h> 
    7 #include <OgreOctreeSceneQuery.h> 
    86#include <OgreOctreeNode.h> 
    97#include <OgreOctreeCamera.h> 
     
    2523        ~VisibilityTerrainSceneManager(); 
    2624 
    27         void _renderVisibleObjects(void); 
     25        void _renderVisibleObjects(); 
    2826        void _findVisibleObjects(Camera* cam, bool onlyShadowCasters); 
    2927        void _updateSceneGraph(Camera* cam); 
     
    4341        bool getOptionKeys( StringVector &refKeys ); 
    4442 
    45         /** Sets the visibility manager 
     43        /** Sets the visibility manager. 
    4644                @param visManager the visibility manager 
    4745        */ 
    4846        void setVisibilityManager(GtpVisibility::VisibilityManager *visManager); 
    49         /** See set 
     47        /** See set. 
    5048        */ 
    5149        GtpVisibility::VisibilityManager *getVisibilityManager(); 
  • trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp

    r115 r118  
    8686         
    8787        // set no depth write, no color, no lighting material 
    88         //mSceneManager->setPass(solidBox->getTechnique()->getPass(0)); 
    89         SetOcclusionPass(); 
     88        mSceneManager->setPass(solidBox->getTechnique()->getPass(0)); 
     89        //SetOcclusionPass(); 
    9090 
    9191        solidBox->SetupBoundingBoxVertices(*box); 
  • trunk/VUT/Ogre/src/OgreSolidBoundingBox.cpp

    r117 r118  
    22#include "OgreSolidBoundingBox.h" 
    33 
    4 #include "OgreSimpleRenderable.h" 
    5 #include "OgreHardwareBufferManager.h" 
    6 #include "OgreCamera.h" 
    7 #include "OgreMaterialManager.h" 
    8  
     4#include <OgreSimpleRenderable.h> 
     5#include <OgreHardwareBufferManager.h> 
     6#include <OgreCamera.h> 
     7#include <OgreMaterialManager.h> 
     8#include <OgreMaterial.h> 
     9#include <OgrePass.h> 
     10#include <OgreTechnique.h> 
    911 
    1012namespace Ogre { 
  • trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp

    r115 r118  
    66#include <OgreCamera.h> 
    77#include <OgreLogManager.h> 
     8#include <OgreStringConverter.h> 
     9 
    810 
    911namespace Ogre { 
     
    1517mVisibilityManager(visManager),  
    1618mUseDepthPass(false), 
     19mIsDepthPass(false), 
    1720mShowVisualization(false), 
    1821mRenderNodesForViz(false), 
     22mRenderNodesContentForViz(false), 
    1923mVisualizeCulledNodes(false), 
    2024mSkipTransparents(false), 
     
    4549                ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 
    4650 
    47                 depthMat->createTechnique()->createPass(); 
    48         mDepthPass = depthMat->getTechnique(0)->getPass(0); 
     51                mDepthPass = depthMat->getTechnique(0)->getPass(0); 
    4952                mDepthPass->setColourWriteEnabled(false); 
    5053                mDepthPass->setDepthWriteEnabled(true); 
     
    6265} 
    6366//----------------------------------------------------------------------- 
     67Pass *VisibilityOctreeSceneManager::setPass(Pass* pass) 
     68{ 
     69        // setting vertex program is not efficient 
     70        //Pass *usedPass = ((mIsDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass);            
     71        Pass *usedPass = (mIsDepthPass ? mDepthPass : pass);     
     72 
     73        if (mIsDepthPass) 
     74        { 
     75                // set vertex program of current pass 
     76        if (pass->hasVertexProgram()) 
     77                { 
     78                        mDepthPass->setVertexProgram(pass->getVertexProgramName()); 
     79 
     80                        if (mDepthPass->hasVertexProgram()) 
     81                        { 
     82                                const GpuProgramPtr& prg = mDepthPass->getVertexProgram(); 
     83                                // Load this program if not done already 
     84                                if (!prg->isLoaded()) 
     85                                        prg->load(); 
     86                                // Copy params 
     87                                mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters()); 
     88                        } 
     89                } 
     90                else if (mDepthPass->hasVertexProgram()) 
     91                { 
     92                        mDepthPass->setVertexProgram(""); 
     93                } 
     94        } 
     95 
     96        OctreeSceneManager::setPass(usedPass); 
     97 
     98        return usedPass; 
     99} 
     100//----------------------------------------------------------------------- 
     101void VisibilityOctreeSceneManager::ShowVisualization(Camera *cam) 
     102{ 
     103        // add player camera for visualization purpose 
     104        try { 
     105                Camera *c; 
     106                if ((c = getCamera("PlayerCam")) != NULL) 
     107                { 
     108                        getRenderQueue()->addRenderable(c); 
     109                }    
     110    } 
     111    catch(...) 
     112    { 
     113        // ignore 
     114    } 
     115        for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 
     116{ 
     117                getRenderQueue()->addRenderable(*it); 
     118        } 
     119        if (mRenderNodesForViz || mRenderNodesContentForViz) 
     120        { 
     121                // change node material so it is better suited for visualization 
     122                MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial"); 
     123                nodeMat->setAmbient(1, 1, 0); 
     124                nodeMat->setLightingEnabled(true); 
     125                nodeMat->getTechnique(0)->getPass(0)->removeAllTextureUnitStates(); 
     126 
     127                for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 
     128        { 
     129 
     130                        if (mRenderNodesForViz) 
     131                        { 
     132                                getRenderQueue()->addRenderable(*it); 
     133                                // addbounding boxes instead of node itself 
     134                                //(*it)->_addBoundingBoxToQueue(getRenderQueue()); 
     135                        } 
     136                        if (mRenderNodesContentForViz)  
     137                        { 
     138                                (*it)->_addToRenderQueue(cam, getRenderQueue(), false); 
     139                        } 
     140                } 
     141        } 
     142         
     143} 
     144//----------------------------------------------------------------------- 
     145void VisibilityOctreeSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 
     146{ 
     147        //-- show visible scene nodes and octree bounding boxes from last frame 
     148        if (mShowVisualization) 
     149    { 
     150                ShowVisualization(cam); 
     151        } 
     152        else  
     153        {        
     154                mVisible.clear(); 
     155            mBoxes.clear(); 
     156         
     157                // if there is no depth pass => 
     158                // we interleave identification and rendering of objects  
     159                // in _renderVisibibleObjects 
     160 
     161                // only shadow casters will be rendered in shadow texture pass 
     162                mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 
     163        } 
     164} 
     165//----------------------------------------------------------------------- 
    64166void VisibilityOctreeSceneManager::_renderVisibleObjects() 
    65167{ 
    66                 if (!mShowVisualization) 
    67         { 
    68                 // two cameras (one for culling, one for rendering) 
    69                 mHierarchyInterface->InitFrame(mOctree, mCameraInProgress,  
    70                                                                 mCullCamera ? getCamera("CullCamera") : NULL, mDelayRenderTransparents); 
    71  
    72                 // call initframe to reset culling manager stats 
    73                 mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 
    74         } 
    75          
    76         // standard terrain scenemanager rendering without hierarchical culling 
    77         if (!mUseDepthPass || mShowVisualization) 
     168        // visualization: apply standard rendering 
     169        if (mShowVisualization) 
    78170        {        
    79171                OctreeSceneManager::_renderVisibleObjects(); 
    80          
    81172                return; 
    82173        }  
    83174         
     175 
    84176        //-- hierarchical culling 
    85177        // the objects of different layers (e.g., background, scene,  
    86178        // overlay) must be identified and rendered one after another 
    87179 
     180        bool leaveTransparentsInQueue = mDelayRenderTransparents && !mUseDepthPass; 
     181 
     182        // possible two cameras (one for culling, one for rendering) 
     183        mHierarchyInterface->InitFrame(mOctree, mCameraInProgress,  
     184                                                        mCullCamera ? getCamera("CullCamera") : NULL, 
     185                                                        leaveTransparentsInQueue); 
     186 
     187        // call initframe to reset culling manager stats 
     188        mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 
     189         
    88190        mSkipTransparents = false; 
    89191 
    90         //-- render background 
     192        //-- render background, in case there is one 
    91193        clearSpecialCaseRenderQueues(); 
    92194        addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND); 
    93195        addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY); 
    94  
    95196        setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 
     197 
    96198        SceneManager::_renderVisibleObjects(); 
     199 
    97200 
    98201#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
     
    102205        //-- render visible objects (i.e., all but overlay) 
    103206        clearSpecialCaseRenderQueues(); 
     207        addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE); 
    104208        addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY); 
    105209        setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 
    106210         
    107         // render only solids in hierarchical algorithm.  
    108         // Transparents need sorting, thus we render them afterwards 
     211        // transparents are skipped from hierarchical rendering 
     212        // => they need sorting, thus we render them afterwards 
    109213        mSkipTransparents = mDelayRenderTransparents; 
    110214 
     215        // set state for depth pass 
     216    mIsDepthPass = mUseDepthPass; 
     217         
    111218        /**  
    112219        * the hierarchical culling algorithm 
     220          * for depth pass: will just find objects and update depth buffer 
     221          * for delayed rendering: will render all but transparents 
    113222        **/ 
    114223         
     
    121230        SceneManager::_renderVisibleObjects(); 
    122231 
     232        // for depth pass: add visible nodes found with the visibility culling 
     233        if (mUseDepthPass) 
     234{ 
     235                for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 
     236        { 
     237                        (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 
     238        } 
     239                mIsDepthPass = false; 
     240        } 
     241        mSkipTransparents = false; 
     242                 
     243        //-- now we can render all remaining queue objects 
     244        // for depth pass: all 
     245        // for delayed rendering: transparents, overlay  
     246        clearSpecialCaseRenderQueues(); 
     247        SceneManager::_renderVisibleObjects(); 
     248         
    123249        //WriteLog(); // write out stats 
    124 } 
    125 //----------------------------------------------------------------------- 
    126 void VisibilityOctreeSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 
    127 { 
    128         // only shadow casters will be rendered in shadow texture pass 
    129         mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 
    130  
    131         // does nothing if hierarchical culling is used => 
    132         // we interleave identification and rendering of objects  
    133         // in _renderVisibibleObjects 
    134         if (!mUseDepthPass) 
    135         { 
    136                 OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
    137                 return;  
    138         } 
    139  
    140         //-- show visibile scene nodes and octree bounding boxes from last frame 
    141         if (mShowVisualization) 
    142     { 
    143                 // add player camera for visualization purpose 
    144                 try { 
    145                         Camera *c; 
    146                         if ((c = getCamera("PlayerCam")) != NULL) 
    147                         { 
    148                                 getRenderQueue()->addRenderable(c); 
    149                         }    
    150         } 
    151         catch(...) 
    152         { 
    153             // ignore 
    154         } 
    155                  
    156                 if (mRenderNodesForViz || mRenderNodesContentForViz) 
    157                 { 
    158                 /*      // change node material so it is better suited for visualization 
    159                         MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial"); 
    160                         nodeMat->setAmbient(1, 1, 0); 
    161                         nodeMat->setLightingEnabled(true); 
    162                         nodeMat->getTechnique(0)->getPass(0)->removeAllTextureUnitStates();*/ 
    163  
    164                         for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 
    165                         { 
    166                                 if (mRenderNodesForViz) 
    167                                 { 
    168                                         getRenderQueue()->addRenderable(*it); 
    169                                 } 
    170                                 if (mRenderNodesContentForViz)  
    171                                 { 
    172                                         (*it)->_addToRenderQueue(cam, getRenderQueue(), false); 
    173                                 } 
    174                         } 
    175                 } 
    176                 for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 
    177                 { 
    178                         getRenderQueue()->addRenderable(*it); 
    179                 } 
    180         } 
    181          
    182         mVisible.clear(); 
    183     mBoxes.clear(); 
    184250} 
    185251//----------------------------------------------------------------------- 
     
    212278                return true; 
    213279        } 
     280        if (key == "RenderNodesContentForViz") 
     281        { 
     282                mRenderNodesContentForViz = (*static_cast<const bool *>(val)); 
     283                return true; 
     284        } 
    214285        if (key == "SkyBoxEnabled") 
    215286        { 
     
    274345} 
    275346//----------------------------------------------------------------------- 
    276 void VisibilityOctreeSceneManager::renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs,  
    277             bool doLightIteration, const LightList* manualLightList) 
    278 { 
    279         if (!mSkipTransparents) 
    280         { 
    281                 OctreeSceneManager::renderObjects(objs, doLightIteration, manualLightList); 
    282         } 
    283 } 
    284 //----------------------------------------------------------------------- 
    285347void VisibilityOctreeSceneManager::WriteLog() 
    286348{ 
    287349        std::stringstream d; 
    288350 
    289         d << "Algorithm: " << mVisibilityManager->GetCullingManagerType() << ", " 
    290           << "Hierarchy nodes: " << mNumOctreeNodes << ", " << "Traversed nodes: " 
    291           << mHierarchyInterface->GetNumTraversedNodes() << ", " 
     351        d << "Algorithm type: " << mVisibilityManager->GetCullingManagerType() << ", " 
     352          << "Hierarchy nodes: " << mNumOctreeNodes << ", "  
     353          << "Traversed nodes: " << mHierarchyInterface->GetNumTraversedNodes() << ", " 
    292354          << "Rendered nodes: " << mHierarchyInterface->GetNumRenderedNodes() << ", " 
    293355          << "Query culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumQueryCulledNodes() << ", " 
     
    297359        LogManager::getSingleton().logMessage(d.str()); 
    298360} 
     361//----------------------------------------------------------------------- 
     362void VisibilityOctreeSceneManager::renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs,  
     363            bool doLightIteration, const LightList* manualLightList) 
     364{ 
     365        if (!mSkipTransparents) 
     366        { 
     367                OctreeSceneManager::renderObjects(objs, doLightIteration, manualLightList); 
     368        } 
     369} 
     370 
    299371}   // namespace Ogre 
  • trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp

    r117 r118  
    11#include "OgreVisibilityTerrainSceneManager.h" 
    2 #include "OgreOctreeHierarchyInterface.h" 
    32#include "OgreVisibilityOptionsManager.h" 
    43#include <OgreMath.h> 
     
    5150                mDepthPass->setDepthWriteEnabled(true); 
    5251                mDepthPass->setLightingEnabled(false); 
    53                 //depthMat->load(); 
    5452        } 
    5553        else 
     
    112110        // ignore 
    113111    } 
    114          
     112        for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 
     113        { 
     114                getRenderQueue()->addRenderable(*it); 
     115        } 
    115116        if (mRenderNodesForViz || mRenderNodesContentForViz) 
    116117        { 
     118                // change node material so it is better suited for visualization 
     119                MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial"); 
     120                nodeMat->setAmbient(1, 1, 0); 
     121                nodeMat->setLightingEnabled(true); 
     122                nodeMat->getTechnique(0)->getPass(0)->removeAllTextureUnitStates(); 
     123 
    117124                for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 
    118125                { 
     126                         
    119127                        if (mRenderNodesForViz) 
    120128                        { 
    121                                 //getRenderQueue()->addRenderable(*it); 
     129                                getRenderQueue()->addRenderable(*it); 
    122130                                // addbounding boxes instead of node itself 
    123                                 (*it)->_addBoundingBoxToQueue(getRenderQueue()); 
     131                                //(*it)->_addBoundingBoxToQueue(getRenderQueue()); 
    124132                        } 
    125133                        if (mRenderNodesContentForViz)  
     
    129137                } 
    130138        } 
    131         for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 
    132         { 
    133                 getRenderQueue()->addRenderable(*it); 
    134         } 
     139         
    135140} 
    136141//----------------------------------------------------------------------- 
Note: See TracChangeset for help on using the changeset viewer.