Ignore:
Timestamp:
06/20/05 08:13:57 (20 years ago)
Author:
mattausch
Message:

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

Location:
trunk/VUT/work/TestCullingTerrain
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp

    r137 r139  
    7575mCullCamera(false), 
    7676mRecord(false), 
    77 mUseShadows(false), 
     77mShowShadows(false), 
    7878mShowHelp(false), 
    7979mDisplayCameraDetails(false), 
     
    159159        mSceneMgr->setOption("ShowOctree", &mShowOctree); 
    160160        mSceneMgr->setOption("CullCamera", &mCullCamera); 
    161         mSceneMgr->setOption("ShowVisualization", &mShowVisualization); 
     161        mSceneMgr->setOption("PrepareVisualization", &mShowVisualization); 
    162162 
    163163        // TODO: change this (does not work with other scene manager plugins) 
     
    257257        } 
    258258 
    259 //      mInputDevice->capture(); 
     259        if (mDisplayCameraDetails) 
     260    { 
     261        // Print camera details 
     262        mWindow->setDebugText("P: " + StringConverter::toString(mCamera->getDerivedPosition()) +  
     263                        " " + "O: " + StringConverter::toString(mCamera->getDerivedOrientation())); 
     264    } 
    260265 
    261266        //-- IMPORTANT: must be set, otherwise terrain is not rendered correctly 
     
    706711void TerrainFrameListener::toggleShowViz() 
    707712{ 
    708         mShowVisualization = !mShowVisualization; 
    709         mVisualizeCulledNodes = !mVisualizeCulledNodes; 
    710  
     713        mVisualizeCulledNodes = mShowVisualization = !mShowVisualization; 
     714         
    711715        // create viewport with priority VIZ_VIEWPORT_Z_ORDER:  
    712716        // will be rendered over standard viewport 
     
    721725                // Alter the camera aspect ratio to match the viewport 
    722726        mVizCamera->setAspectRatio(Real(vizvp->getActualWidth()) /  
    723                         Real(vizvp->getActualHeight())); 
     727                                                                   Real(vizvp->getActualHeight())); 
    724728                 
    725729                mSceneMgr->setOption("VisualizeCulledNodes", &mVisualizeCulledNodes); 
     
    733737                mSceneMgr->setSkyPlane(true, plane, "Examples/TransparentTest", 4000, 75, false); 
    734738                */ 
    735                  
    736739        } 
    737740        else 
    738741        { 
     742                // remove visualization viewport 
    739743                mWindow->removeViewport(VIZ_VIEWPORT_Z_ORDER); 
    740                 // if octree was enabled for visualization purpose, reset now 
     744 
     745                // octree bounding boxes are shown for visualization purpose, reset now 
    741746                mSceneMgr->setOption("ShowOctree", &mShowOctree); 
    742747        } 
    743748} 
    744749//----------------------------------------------------------------------- 
    745 void TerrainFrameListener::toggleUseShadows() 
    746 { 
    747         mUseShadows = !mUseShadows; 
    748  
    749         mSunLight->setCastShadows(mUseShadows); 
    750  
    751         if (mUseShadows) 
     750void TerrainFrameListener::toggleShowShadows() 
     751{ 
     752        mShowShadows = !mShowShadows; 
     753 
     754        mSunLight->setCastShadows(mShowShadows); 
     755 
     756        if (mShowShadows) 
    752757        { 
    753758                mSceneMgr->setShadowTechnique(SHADOWTYPE_TEXTURE_MODULATIVE); 
     759                //mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_MODULATIVE); 
     760                //mSceneMgr->setShadowTechnique(SHADOWTYPE_STENCIL_ADDITIVE);            
    754761        } 
    755762        else 
     
    805812                break; 
    806813        case KC_S: 
    807                 toggleUseShadows(); 
     814                toggleShowShadows(); 
    808815                break; 
    809816 
     
    857864                break; 
    858865        } 
    859  
    860         if (mDisplayCameraDetails) 
    861     { 
    862         // Print camera details 
    863         mWindow->setDebugText("P: " + StringConverter::toString(mCamera->getDerivedPosition()) +  
    864                         " " + "O: " + StringConverter::toString(mCamera->getDerivedOrientation())); 
    865     } 
    866866 
    867867        CEGUI::System::getSingleton().injectKeyDown(e->getKey()); 
  • trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h

    r135 r139  
    9898        void toggleShowStats(); 
    9999 
    100         void toggleUseShadows(); 
     100        void toggleShowShadows(); 
    101101        void toggleDisplayCameraDetails(); 
    102102        void takeScreenShot(); 
     
    175175        bool mCullCamera; 
    176176        bool mRecord; 
    177         bool mUseShadows; 
     177        bool mShowShadows; 
    178178        bool mVisualizeCulledNodes; 
    179179        bool mShowHelp; 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp

    r137 r139  
    8484{ 
    8585        // Set ambient light 
    86         mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); 
     86        mAmbientLight = ColourValue(0.5, 0.5, 0.5); 
     87        mSceneMgr->setAmbientLight(mAmbientLight); 
    8788         
    8889        //-- create light 
     
    100101        mSunLight->setDirection(dir); 
    101102        //mSunLight->setDirection(Vector3::NEGATIVE_UNIT_Y); 
    102  
    103103        mSunLight->setDiffuseColour(1, 1, 1); 
    104104        mSunLight->setSpecularColour(1, 1, 1); 
     
    137137        */ 
    138138        mSceneMgr->setShadowTextureSettings(1024, 2); 
    139 /*      if (mRoot->getRenderSystem()->getCapabilities()->hasCapability(RSC_HWRENDER_TO_TEXTURE)) 
    140     {   // In D3D, use a 1024x1024 shadow texture 
    141                 mSceneMgr->setShadowTextureSettings(1024, 2);   }       else    { 
    142                 // Use 512x512 texture in GL since we can't go higher than the window res 
    143                 mSceneMgr->setShadowTextureSettings(512, 2);} 
    144                 */ 
    145  
    146         //mSceneMgr->setShadowColour(ColourValue(0, 0, 0)); 
    147139        mSceneMgr->setShadowColour(ColourValue(0.5, 0.5, 0.5)); 
    148     // mSceneMgr->setShowDebugShadows(true); 
     140    //mSceneMgr->setShowDebugShadows(true); 
    149141 
    150142 
     
    220212        const bool nShowViz = !showViz; 
    221213 
    222         // ambient light must be full for visualization 
     214        mSavedShadowTechnique = mSceneMgr->getShadowTechnique(); 
     215        mSavedAmbientLight = mSceneMgr->getAmbientLight(); 
     216 
     217        // -- ambient light must be full for visualization, shadows disabled 
    223218    if (showViz) 
    224219        { 
    225220                mSceneMgr->setAmbientLight(ColourValue(1, 1, 1)); 
    226         } 
    227         else 
    228         { 
    229                 mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); 
    230         } 
    231  
    232     mSceneMgr->setOption("ShowVisualization", &showViz); 
     221                mSceneMgr->setShadowTechnique(SHADOWTYPE_NONE); 
     222        } 
     223         
     224    mSceneMgr->setOption("PrepareVisualization", &showViz); 
    233225        mSceneMgr->setOption("SkyBoxEnabled", &nShowViz); 
    234226        //mSceneMgr->setOption("SkyPlaneEnabled", &showViz); 
     
    239231void VisualizationRenderTargetListener::postRenderTargetUpdate(const RenderTargetEvent &evt) 
    240232{ 
     233        // reset values 
     234        mSceneMgr->setShadowTechnique(mSavedShadowTechnique); 
     235        mSceneMgr->setAmbientLight(mSavedAmbientLight); 
     236         
    241237        RenderTargetListener::postRenderTargetUpdate(evt); 
    242238} 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h

    r133 r139  
    33 
    44#include "CEGUIForwardRefs.h" 
     5#include <OgreRenderTargetListener.h> 
    56#include "ExampleApplication.h" 
     7 
    68#include "OgreTerrainContentGenerator.h" 
    7  
    8 #include <OgreRenderTargetListener.h> 
    99#include "TerrainFrameListener.h" 
    1010 
     
    1919 
    2020        SceneManager *mSceneMgr; 
     21         
     22        ShadowTechnique mSavedShadowTechnique; 
     23        ColourValue mSavedAmbientLight; 
    2124}; 
    2225 
     
    5457        SceneNode *mCamNode; 
    5558        Light *mSunLight; 
    56         VisualizationRenderTargetListener *mRenderTargetListener; 
    5759 
    5860        TerrainFrameListener *mTerrainFrameListener; 
     61        ColourValue mAmbientLight; 
     62        //VisualizationRenderTargetListener *mVizRenderTargetListener; 
    5963         
    6064private: 
Note: See TracChangeset for help on using the changeset viewer.