Changeset 103 for trunk/VUT/Ogre/src


Ignore:
Timestamp:
05/18/05 02:06:32 (20 years ago)
Author:
mattausch
Message:

fixed bug with shadow maps

Location:
trunk/VUT/Ogre/src
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp

    r101 r103  
    106106                octant->setLastRendered(mFrameId); 
    107107 
    108                 static_cast<OctreeSceneManager *>(mSceneManager)->_renderOctant(mCamera, octant); 
     108                static_cast<OctreeSceneManager *>(mSceneManager)->_renderOctant(mCamera,  
     109                        octant, mOnlyShadowCasters); 
    109110 
    110111                mNumRenderedNodes ++; 
  • trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp

    r100 r103  
    11#include <OgreCamera.h> 
    22#include <OgreLogManager.h> 
    3 //#include "OgreSolidHalfBoundingBox.h" 
    43#include "OgreSolidBoundingBox.h" 
    54#include "OgrePlatformHierarchyInterface.h" 
    65#include "OgrePlatformOcclusionQuery.h" 
    7 #include <windows.h> 
    86 
    97namespace Ogre { 
     
    1210PlatformHierarchyInterface::PlatformHierarchyInterface(SceneManager *sm, RenderSystem *rsys): 
    1311mSceneManager(sm), mRenderSystem(rsys), mSolidBoundingBox(NULL), 
    14 mCamera(NULL), mCullCamera(NULL) 
     12mCamera(NULL), mCullCamera(NULL), mOnlyShadowCasters(false) 
    1513{ 
    1614} 
     
    3634        static RenderOperation ro; 
    3735 
    38         //TODO: this should be the full bounding box 
    3936        SolidBoundingBox *solidBox = GetSolidBoundingBox(); 
    4037         
    4138        mRenderSystem->_setWorldMatrix(Ogre::Matrix4::IDENTITY); 
    4239        mSceneManager->useRenderableViewProjMode(solidBox); 
    43     mSceneManager->setPass(solidBox->getTechnique()->getPass(0)); 
     40        //mSceneManager->setOcclusionPass(solidBox->getTechnique()->getPass(0)); 
     41        SetOcclusionPass(); 
    4442 
    4543        solidBox->SetupBoundingBoxVertices(*box); 
     
    8078} 
    8179//----------------------------------------------------------------------- 
    82 void PlatformHierarchyInterface::InitFrame(GtpVisibility::HierarchyNode *root, Camera *cam, Camera *cullCam) 
     80void PlatformHierarchyInterface::InitFrame(GtpVisibility::HierarchyNode *root,  
     81                                                                                   Camera *cam, Camera *cullCam) 
    8382{ 
    8483        GtpVisibility::HierarchyInterface::InitFrame(root); 
     
    8887 
    8988        if (cullCam) 
     89        { 
    9090                SetCullCamera(cullCam); 
     91        } 
    9192        else 
     93        { 
    9294                SetCullCamera(cam); 
     95        } 
    9396} 
    9497//----------------------------------------------------------------------- 
     
    141144} 
    142145//----------------------------------------------------------------------- 
     146void PlatformHierarchyInterface::SetOcclusionPass() 
     147{ 
     148    // disable vertex and fragment program 
     149        mRenderSystem->unbindGpuProgram(GPT_VERTEX_PROGRAM); 
     150        mRenderSystem->unbindGpuProgram(GPT_FRAGMENT_PROGRAM); 
     151         
     152        // disable lighting 
     153        mRenderSystem->setLightingEnabled(false); 
     154 
     155    // Disable remaining texture units 
     156    mRenderSystem->_disableTextureUnitsFrom(0); 
     157 
     158    //--Set up non-texture related material settings 
     159    
     160        // Depth buffer settings 
     161        mRenderSystem->_setDepthBufferParams(true, false, CMPF_LESS_EQUAL); 
     162        // Set colour write mode off 
     163        mRenderSystem->_setColourBufferWriteEnabled(false, false, false, false); 
     164        // Set colour write mode pff 
     165    mRenderSystem->_setColourBufferWriteEnabled(false, false, false, false); 
     166} 
     167//----------------------------------------------------------------------- 
    143168SolidBoundingBox *PlatformHierarchyInterface::GetSolidBoundingBox() 
    144169{ 
     
    148173        return mSolidBoundingBox; 
    149174} 
    150  
     175//----------------------------------------------------------------------- 
     176void PlatformHierarchyInterface::SetOnlyShadowCasters(bool onlyShadowCasters) 
     177{ 
     178        mOnlyShadowCasters = onlyShadowCasters; 
     179} 
    151180} // namespace Ogre 
  • trunk/VUT/Ogre/src/OgreSceneNodeHierarchyInterface.cpp

    r100 r103  
    115115AxisAlignedBox *SceneNodeHierarchyInterface::GetBoundingBox(GtpVisibility::HierarchyNode *node) 
    116116{ 
     117        // only create renderable bounding box for new node 
    117118        if (node != mPreviousNode) 
    118119        { 
  • trunk/VUT/Ogre/src/OgreSolidBoundingBox.cpp

    r100 r103  
    7474         //setMaterial("BaseWhiteNoLighting"); 
    7575} 
     76//----------------------------------------------------------------------- 
    7677SolidBoundingBox::~SolidBoundingBox()  
    7778{ 
  • trunk/VUT/Ogre/src/OgreSolidHalfBoundingBox.cpp

    r100 r103  
    66#include "OgreCamera.h" 
    77#include "OgreMaterialManager.h" 
    8 //#include <windows.h> 
     8 
    99 
    1010namespace Ogre { 
  • trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp

    r100 r103  
    3636        mHierarchyInterface->InitFrame(mOctree, mCameraInProgress,  
    3737                                                        mCullCamera ? getCamera("CullCamera") : NULL); 
    38         //mVisibilityManager->GetCullingManager()->InitFrame(); 
    3938 
    40         // standard scenemanager rendering without hierarchical culling 
    41         if(!mUseVisibilityCulling) 
     39        // call initframe to reset culling manager stats 
     40        mVisibilityManager->GetCullingManager()->InitFrame(); 
     41 
     42        // standard terrain scenemanager rendering without hierarchical culling 
     43        if (!mUseVisibilityCulling || mShowVisualization) 
    4244        {        
    4345                OctreeSceneManager::_renderVisibleObjects(); 
    4446                return; 
    4547        }  
    46      
     48         
    4749        //-- hierarchical culling 
    4850        // the objects of different layers (e.g., background, scene,  
     
    7779#endif 
    7880 
    79         //-- render remaining objects, e.g., overlay 
     81        //-- render overlay 
    8082        clearSpecialCaseRenderQueues(); 
    8183        SceneManager::_renderVisibleObjects(); 
     
    8688void VisibilityOctreeSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 
    8789{ 
     90        // if shadow pass => render only shadow casters 
     91        mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 
     92 
    8893        // does nothing if hierarchical culling is used => 
    8994        // we interleave identification and rendering of objects  
     
    104109        } 
    105110 
    106         getRenderQueue()->clear(); 
    107     mBoxes.clear(); 
     111        mBoxes.clear(); 
    108112    mVisible.clear(); 
    109113} 
     
    156160{ 
    157161        return  VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 
    158                 getOptionKeys ( refKeys ) || OctreeSceneManager::getOptionKeys(refKeys); 
     162                getOptionKeys (refKeys) || OctreeSceneManager::getOptionKeys(refKeys); 
    159163} 
    160164//----------------------------------------------------------------------- 
     
    174178 
    175179        d << "Algorithm: " << mVisibilityManager->GetCullingManagerType() << ", " 
    176           << "Hierarchy nodes: " << mNumOctreeNodes << ", " << "Traversed nodes: " << mHierarchyInterface->GetNumTraversedNodes() << ", " 
     180          << "Hierarchy nodes: " << mNumOctreeNodes << ", " << "Traversed nodes: " 
     181          << mHierarchyInterface->GetNumTraversedNodes() << ", " 
    177182          << "Rendered nodes: " << mHierarchyInterface->GetNumRenderedNodes() << ", " 
    178183          << "Query culled nodes: " << mVisibilityManager->GetCullingManager()->GetNumQueryCulledNodes() << ", " 
  • trunk/VUT/Ogre/src/OgreVisibilitySceneManager.cpp

    r100 r103  
    1212//----------------------------------------------------------------------- 
    1313VisibilitySceneManager::VisibilitySceneManager(GtpVisibility::VisibilityManager *visManager) 
    14 :mVisibilityManager(visManager), mUseVisibilityCulling(true) 
     14:mVisibilityManager(visManager), mUseVisibilityCulling(true), mShowVisualization(false) 
    1515{ 
    16         mHierarchyInterface = new SceneNodeHierarchyInterface(this, mDestRenderSystem); 
     16        mHierarchyInterface =  
     17                new SceneNodeHierarchyInterface(this, mDestRenderSystem); 
    1718} 
    1819//----------------------------------------------------------------------- 
     
    2425void VisibilitySceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 
    2526{ 
    26         // empty if hierarchical culling is used => 
     27        // does nothing if hierarchical culling is used => 
    2728        // we interleave identification and rendering of objects  
    28         // in _renderVisibibleObjects  
     29        // in _renderVisibibleObjects 
    2930        if (!mUseVisibilityCulling) 
    3031        { 
    3132                SceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
     33                return;  
    3234        } 
    3335} 
     
    3537void VisibilitySceneManager::_renderVisibleObjects() 
    3638{ 
     39        // two cameras (one for culling, one for rendering) 
    3740        mHierarchyInterface->InitFrame(mSceneRoot, mCameraInProgress); 
     41 
     42        // call initframe to reset culling manager stats 
    3843        mVisibilityManager->GetCullingManager()->InitFrame(); 
    3944 
    40         if (!mUseVisibilityCulling) 
     45        // standard terrain scenemanager rendering without hierarchical culling 
     46        if (!mUseVisibilityCulling || mShowVisualization) 
    4147        {        
    4248                SceneManager::_renderVisibleObjects(); 
     
    5561        setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 
    5662        SceneManager::_renderVisibleObjects(); 
     63 
    5764#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    5865        _deleteRenderedQueueGroups(); 
     
    6471        setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 
    6572 
    66         //-- the hierarchical culling algorithm 
     73 
     74        /**  
     75        * the hierarchical culling algorithm 
     76        **/ 
    6777        mVisibilityManager->ApplyVisibilityCulling(); 
     78 
    6879 
    6980#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
     
    7485        clearSpecialCaseRenderQueues(); 
    7586        SceneManager::_renderVisibleObjects(); 
     87 
     88        //WriteLog(); // write out stats 
    7689} 
    7790//----------------------------------------------------------------------- 
     
    123136} 
    124137 
    125 //} // namespace GtpVisibility 
    126138} // namespace Ogre 
  • trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp

    r101 r103  
    1616VisibilityTerrainSceneManager::VisibilityTerrainSceneManager( 
    1717        GtpVisibility::VisibilityManager *visManager) 
    18 : mVisibilityManager(visManager), mUseVisibilityCulling(true), 
    19 mShowVisualization(false) 
     18: mVisibilityManager(visManager),  
     19mUseVisibilityCulling(true), 
     20mShowVisualization(false), 
     21mRenderNodesForViz(false) 
    2022{ 
    2123        mHierarchyInterface =  
     
    2426        //mDisplayNodes = true; 
    2527        //mShowBoundingBoxes = true; 
     28 
     29        // TODO: set maxdepth to reasonable value 
    2630        mMaxDepth = 50; 
    2731} 
     
    3236} 
    3337//----------------------------------------------------------------------- 
     38void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 
     39{ 
     40        mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 
     41        // does nothing if hierarchical culling is used => 
     42        // we interleave identification and rendering of objects  
     43        // in _renderVisibibleObjects 
     44        if (!mUseVisibilityCulling) 
     45        { 
     46                OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
     47                return;  
     48        } 
     49 
     50        //-- show visibile scene nodes and octree bounding boxes from last frame 
     51        if (mShowVisualization) 
     52    { 
     53                // add player camera for visualization purpose 
     54                Camera *c; 
     55                if ((c = getCamera("PlayerCam")) != NULL) 
     56                { 
     57                        getRenderQueue()->addRenderable(c); 
     58                } 
     59                 
     60                for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 
     61                { 
     62                        getRenderQueue()->addRenderable(*it); 
     63 
     64                        if (mRenderNodesForViz) 
     65                        { 
     66                                (*it)->_addToRenderQueue(cam, getRenderQueue(), false); 
     67                        } 
     68                } 
     69                for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 
     70                { 
     71                        getRenderQueue()->addRenderable(*it); 
     72                } 
     73        } 
     74         
     75        mVisible.clear(); 
     76    mBoxes.clear(); 
     77} 
     78//----------------------------------------------------------------------- 
    3479void VisibilityTerrainSceneManager::_renderVisibleObjects() 
    3580{ 
    36         // two cameras (one for culling, one for rendering) 
    37         mHierarchyInterface->InitFrame(mOctree, mCameraInProgress,  
    38                                                         mCullCamera ? getCamera("CullCamera") : NULL); 
    39         //mVisibilityManager->GetCullingManager()->InitFrame(); 
    40          
     81        if (!mShowVisualization) 
     82        { 
     83                // two cameras (one for culling, one for rendering) 
     84                mHierarchyInterface->InitFrame(mOctree, mCameraInProgress,  
     85                                                                mCullCamera ? getCamera("CullCamera") : NULL); 
     86 
     87                // call initframe to reset culling manager stats 
     88                mVisibilityManager->GetCullingManager()->InitFrame(); 
     89        } 
     90 
    4191        // standard terrain scenemanager rendering without hierarchical culling 
    42         if(!mUseVisibilityCulling || mShowVisualization) 
     92        if (!mUseVisibilityCulling || mShowVisualization) 
    4393        {        
    4494                TerrainSceneManager::_renderVisibleObjects(); 
     
    85135} 
    86136//----------------------------------------------------------------------- 
    87 void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 
    88 { 
    89         // does nothing if hierarchical culling is used => 
    90         // we interleave identification and rendering of objects  
    91         // in _renderVisibibleObjects 
    92         getRenderQueue()->clear(); 
    93          
    94         if (!mUseVisibilityCulling) 
    95         { 
    96                 OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
    97                 return;  
    98         } 
    99          
    100         //-- show visibile scene nodes and octree bounding boxes from last frame 
    101         if (mShowVisualization) 
    102     { 
    103                 // add cull camera for visualization purpose 
    104                 if (mCullCamera) 
    105                 { 
    106                         Camera *c; 
    107                         if ((c = getCamera("CullCamera")) != NULL) 
    108                         { 
    109                                 getRenderQueue()->addRenderable(c); 
    110                         } 
    111                 } 
    112  
    113                 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 
    114                 { 
    115                         getRenderQueue()->addRenderable(*it); 
    116                 } 
    117                 for (BoxList::iterator it = mBoxes.begin(); it != mBoxes.end(); ++it) 
    118                 { 
    119                         getRenderQueue()->addRenderable(*it); 
    120                 } 
    121         } 
    122          
    123         mVisible.clear(); 
    124     mBoxes.clear(); 
    125 } 
    126 //----------------------------------------------------------------------- 
    127137void VisibilityTerrainSceneManager::_updateSceneGraph(Camera* cam) 
    128138{ 
    129         // mHierarchyInterface->setNumSceneNodes((int)mSceneNodes.size()); 
    130139        mVisibilityManager->GetCullingManager()->SetHierarchyInterface(mHierarchyInterface); 
    131140        mHierarchyInterface->SetRenderSystem(mDestRenderSystem); 
     
    149158                return true; 
    150159        } 
     160        if (key == "RenderNodesForViz") 
     161        { 
     162                mRenderNodesForViz = (*static_cast<const bool *>(val)); 
     163                return true; 
     164        } 
    151165        if (key == "SkyBoxEnabled") 
    152166        { 
     
    180194} 
    181195//----------------------------------------------------------------------- 
    182 bool VisibilityTerrainSceneManager::getOptionValues(const String & key, StringVector  &refValueList) 
     196bool VisibilityTerrainSceneManager::getOptionValues(const String & key, StringVector &refValueList) 
    183197{ 
    184198        return TerrainSceneManager::getOptionValues( key, refValueList); 
     
    200214        return mVisibilityManager; 
    201215} 
    202 //----------------------------------------------------------------------- 
    203 void VisibilityTerrainSceneManager::SetShowVisualization(bool showViz) 
    204 { 
    205         mShowVisualization = showViz; 
    206 } 
    207 /* 
    208 //----------------------------------------------------------------------- 
    209 void SetSkyBoxEnabled(bool enabled) 
    210 { 
    211         mSkyBoxEnabled = enabled; 
    212 } 
    213 //----------------------------------------------------------------------- 
    214 void SetSkyPlaneEnabled(bool enabled) 
    215 { 
    216         mSkyPlaneEnabled = enabled; 
    217 } 
    218 //----------------------------------------------------------------------- 
    219 void SetSkyDomeEnabled(bool enabled) 
    220 { 
    221         mSkyDomeEnabled = enabled; 
    222 } */ 
     216 
    223217//----------------------------------------------------------------------- 
    224218void VisibilityTerrainSceneManager::WriteLog() 
     
    236230        LogManager::getSingleton().logMessage(d.str()); 
    237231} 
     232 
     233 
    238234} // namespace Ogre 
Note: See TracChangeset for help on using the changeset viewer.