Changeset 113


Ignore:
Timestamp:
05/27/05 11:56:51 (19 years ago)
Author:
mattausch
Message:

fixed problems with visualization

Location:
trunk/VUT
Files:
14 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibility/include/PreprocessingManager.h

    r71 r113  
    9090        @remark the scene traverser is dependent on the type of hierarchyInterface the scene consists of. 
    9191    */ 
    92     virtual void SetSceneTraverser( HierarchyInterface *hierarchyInterface ) { 
     92    virtual void SetSceneTraverser(HierarchyInterface *hierarchyInterface) { 
    9393      mSceneTraverser = hierarchyInterface; 
    9494    } 
  • trunk/VUT/GtpVisibility/include/QueryManager.h

    r71 r113  
    2525        onm different hierarchy types, while reusing the implementation of the query methods. 
    2626     */ 
    27     QueryManager( HierarchyInterface *hierarchyInterface ); 
     27    QueryManager(HierarchyInterface *hierarchyInterface); 
    2828     
    2929    /**  
     
    6464     
    6565  /**  
    66       Ray shooting intreface: finds an intersection with objects in the scene. 
     66      Ray shooting interface: finds an intersection with objects in the scene. 
    6767 
    6868      @param ray The given input ray (assuming the ray direction is normalized) 
     
    8484      @remark the scene traverser depends on the type of hierarchyInterface the scene consists of. 
    8585        */ 
    86         void SetSceneTraverser(HierarchyInterface *hierarchyInterface ); 
     86        void SetSceneTraverser(HierarchyInterface *hierarchyInterface); 
    8787 
    8888protected: 
  • trunk/VUT/GtpVisibility/src/CoherentHierarchicalCullingManager.cpp

    r112 r113  
    5353                                if(mVisualizeCulledNodes) 
    5454                                { 
    55                                         mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED); 
     55                                        mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED); 
    5656                                } 
    5757                        } 
  • trunk/VUT/GtpVisibility/src/FrustumCullingManager.cpp

    r112 r113  
    2121                {//if (mHierarchyInterface->mIsShadowPass) 
    2222                        mNumFrustumCulledNodes ++; 
     23 
     24                        if(mVisualizeCulledNodes) 
     25                        { 
     26                                mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED); 
     27                        } 
    2328                } 
    2429                else 
  • trunk/VUT/GtpVisibility/src/StopAndWaitCullingManager.cpp

    r112 r113  
    2323                {//if (mHierarchyInterface->mIsShadowPass) 
    2424                        mNumFrustumCulledNodes ++; 
     25                        if(mVisualizeCulledNodes) 
     26                        { 
     27                                mHierarchyInterface->VisualizeCulledNode(node, FRUSTUM_CULLED); 
     28                        } 
    2529                } 
    2630                else 
     
    4852                        {       //if (mHierarchyInterface->mIsShadowPass) 
    4953                                mNumQueryCulledNodes ++; 
     54                                if(mVisualizeCulledNodes) 
     55                                { 
     56                                        mHierarchyInterface->VisualizeCulledNode(node, QUERY_CULLED); 
     57                                } 
    5058                        } 
    5159                } 
  • trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h

    r112 r113  
    6060        bool mUseVisibilityCulling; 
    6161        bool mShowVisualization; 
    62         bool mRenderNodesForViz; 
    6362        bool mVisualizeCulledNodes; 
     63 
     64        int mRenderNodesForViz; 
    6465}; 
    6566 
  • trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h

    r112 r113  
    5050        */ 
    5151        GtpVisibility::VisibilityManager *getVisibilityManager(); 
    52          
     52 
    5353protected: 
    5454         
     
    6363        bool mShowVisualization; 
    6464        bool mRenderNodesForViz; 
     65        bool mRenderNodesContentForViz; 
    6566        bool mVisualizeCulledNodes; 
    6667}; 
  • trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp

    r112 r113  
    33#include <OgreOctree.h> 
    44#include <OgreLogManager.h> 
    5  
     5#include <OgreStringConverter.h> 
    66#include <windows.h> 
    77 
     
    156156                box->setMaterial("QueryCulledNodesMaterial"); 
    157157        } 
     158 
    158159        static_cast<OctreeSceneManager *>(mSceneManager)->getBoxes()->push_back(box); 
    159         //LogManager::getSingleton().logMessage("pushing box"); 
    160160} 
    161161} // namespace Ogre 
  • trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp

    r112 r113  
    1212mCamera(NULL), mCullCamera(NULL), mOnlyShadowCasters(false) 
    1313{ 
    14         CreateCulledNodeMaterials(); 
    15          
    1614} 
    1715//----------------------------------------------------------------------- 
     
    2018        // material for frustum culled nodes 
    2119        MaterialPtr mat = MaterialManager::getSingleton().getByName("FrustumCulledNodesMaterial"); 
    22         MaterialPtr baseWhite = MaterialManager::getSingleton().getByName("BaseWhiteNoLighting"); 
     20         
    2321        if (mat.isNull()) 
    2422        { 
    2523                mat = MaterialManager::getSingleton().create("FrustumCulledNodesMaterial",  
    2624                        ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 
    27  
    28                 //baseWhite.get()->copyDetailsTo(mat); 
    29                 //mat->setColourWriteEnabled(true); 
    30                 mat->setLightingEnabled(false); 
    31                 //mat->setAmbient(ColourValue(1,0,0)); 
     25                mat->createTechnique()->createPass(); 
     26                 
     27                mat->getTechnique(0)->getPass(0)->setAmbient(1,0,0); 
     28                mat->getTechnique(0)->getPass(0)->setLightingEnabled(true); 
     29                //mat->getTechnique(0)->getPass(0)->setDepthCheckEnabled(false); 
     30                 
     31                mat->load(); 
    3232        } 
    3333 
    3434        // material for query culled nodes 
    35         MaterialPtr mat2 = MaterialManager::getSingleton().getByName("QueryCulledNodesMaterial"); 
    36  
    37         if (mat2.isNull()) 
    38         { 
    39                 mat2 = MaterialManager::getSingleton().create("QueryCulledNodesMaterial",  
     35        mat = MaterialManager::getSingleton().getByName("QueryCulledNodesMaterial"); 
     36 
     37        if (mat.isNull()) 
     38        { 
     39                mat = MaterialManager::getSingleton().create("QueryCulledNodesMaterial",  
    4040                        ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 
    41                 //baseWhite.get()->copyDetailsTo(mat2); 
    42         //      mat2->setColourWriteEnabled(true); 
    43                 mat2->setLightingEnabled(false); 
    44                 //mat2->setAmbient(ColourValue(0,0,1));          
     41                mat->createTechnique()->createPass(); 
     42                 
     43                mat->getTechnique(0)->getPass(0)->setAmbient(0,0,1); 
     44                mat->getTechnique(0)->getPass(0)->setLightingEnabled(true); 
     45                mat->load(); 
    4546        } 
    4647} 
     
    126127                SetCullCamera(cam); 
    127128        } 
     129 
     130        CreateCulledNodeMaterials(); 
    128131} 
    129132//----------------------------------------------------------------------- 
  • trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp

    r112 r113  
    142142        if (key == "RenderNodesForViz") 
    143143        { 
    144                 mRenderNodesForViz = (*static_cast<const bool *>(val)); 
     144                mRenderNodesForViz = (*static_cast<const int *>(val)); 
    145145                return true; 
    146146        } 
  • trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp

    r112 r113  
    2020mShowVisualization(false), 
    2121mRenderNodesForViz(false), 
     22mRenderNodesContentForViz(false), 
    2223mVisualizeCulledNodes(false) 
    2324{ 
     
    3940void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 
    4041{ 
     42        // only shadow casters will be rendered in shadow texture pass 
    4143        mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 
     44 
    4245        // does nothing if hierarchical culling is used => 
    4346        // we interleave identification and rendering of objects  
     
    6467            // ignore 
    6568        } 
    66                                  
    67                 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 
     69                 
     70                if (mRenderNodesForViz || mRenderNodesContentForViz) 
    6871                { 
    69                         MaterialPtr mp = (*it)->getMaterial(); 
    70                          
    71                         mp.get()->setLightingEnabled(false); 
    72                         mp.get()->setAmbient(ColourValue(1,0,0)); 
    73                         mp.get()->setDiffuse(ColourValue(1,1,1)); 
    74                         mp.get()->setSpecular(ColourValue(1,1,1)); 
    75                          
    76                         mp.get()->getTechnique(0)->getPass(0)->removeAllTextureUnitStates(); 
    77                         //*mp = MaterialManager::getSingleton().getByName("BaseWhiteNoLighting"); 
    78                         //(*it)->setMaterialName("BaseWhiteNoLighting"); 
    79                         getRenderQueue()->addRenderable(*it); 
    80  
    81                         if (mRenderNodesForViz) 
     72                        // change node material so it is better suited for visualization 
     73                        MaterialPtr nodeMat = MaterialManager::getSingleton().getByName("Core/NodeMaterial"); 
     74                        nodeMat->setAmbient(1, 1, 0); 
     75                        nodeMat->setLightingEnabled(true); 
     76                        nodeMat->getTechnique(0)->getPass(0)->removeAllTextureUnitStates(); 
     77 
     78                        for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 
    8279                        { 
    83                                 (*it)->_addToRenderQueue(cam, getRenderQueue(), false); 
     80                                if (mRenderNodesForViz) 
     81                                { 
     82                                        getRenderQueue()->addRenderable(*it); 
     83                                } 
     84                                if (mRenderNodesContentForViz)  
     85                                { 
     86                                        (*it)->_addToRenderQueue(cam, getRenderQueue(), false); 
     87                                } 
    8488                        } 
    8589                } 
     
    109113        if (!mUseVisibilityCulling || mShowVisualization) 
    110114        {        
     115                //mDestRenderSystem->unbindGpuProgram(GPT_VERTEX_PROGRAM); 
     116                //mDestRenderSystem->unbindGpuProgram(GPT_FRAGMENT_PROGRAM); 
    111117                TerrainSceneManager::_renderVisibleObjects(); 
    112118         
     
    179185        { 
    180186                mRenderNodesForViz = (*static_cast<const bool *>(val)); 
     187                return true; 
     188        } 
     189        if (key == "RenderNodesContentForViz") 
     190        { 
     191                mRenderNodesContentForViz = (*static_cast<const bool *>(val)); 
    181192                return true; 
    182193        } 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp

    r112 r113  
    9292{ 
    9393        // Set ambient light 
    94         //mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); 
    9594        mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); 
    96  
     95         
    9796        //-- create light 
    9897        mSunLight = mSceneMgr->createLight("SunLight"); 
     
    104103        mSunLight->setCastShadows(true); 
    105104 
    106         Vector3 dir(0.5, 0.5, 0.5); 
     105        Vector3 dir(0.5, 1, 0.5); 
    107106        dir.normalise(); 
    108107        mSunLight->setDirection(dir); 
     
    237236mVizCamera(vizCamera), 
    238237mShowVisualization(false), 
    239 mRenderNodesForViz(false), 
     238mNodeVizMode(NODEVIZ_NONE), 
    240239mVizCameraHeight(Real(2500.0)), 
    241240mCamNode(camNode), 
     
    292291        mSceneMgr->setOption("CullCamera", &mCullCamera); 
    293292        mSceneMgr->setOption("ShowVisualization", &mShowVisualization); 
    294         mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz); 
    295  
     293         
    296294        pOver->show(); 
    297295}  
     
    403401                // important for visualization => draw octree bounding boxes 
    404402                mSceneMgr->setOption("ShowOctree", &mShowVisualization); 
    405                 // also render geometry? 
    406                 mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz); 
     403                // also render nodew content? 
     404                //mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz); 
    407405 
    408406                // -- setup visualization camera 
     
    454452        KEY_PRESSED(KC_C, 0.3, toggleUseVisibilityCulling()); 
    455453        KEY_PRESSED(KC_1, 0.3, toggleShowViz()); 
    456         KEY_PRESSED(KC_2, 0.3, toggleRenderNodesForViz()); 
     454        KEY_PRESSED(KC_2, 0.3, nextNodeVizMode()); 
    457455         
    458456        KEY_PRESSED(KC_SUBTRACT, 0, changeThreshold(-10)); 
    459457        KEY_PRESSED(KC_ADD, 0, changeThreshold(10)); 
    460458         
    461         KEY_PRESSED(KC_3, 0, zoomVizCamera(50)); 
    462         KEY_PRESSED(KC_4, 0, zoomVizCamera(-50)); 
     459        KEY_PRESSED(KC_4, 0, zoomVizCamera(50)); 
     460        KEY_PRESSED(KC_5, 0, zoomVizCamera(-50)); 
    463461 
    464462        KEY_PRESSED(KC_F1, 0.3, nextAppState()); 
     
    758756} 
    759757//----------------------------------------------------------------------- 
    760 void MouseQueryListener::toggleRenderNodesForViz() 
    761 { 
    762         mRenderNodesForViz = !mRenderNodesForViz; 
    763  
    764         mSceneMgr->setOption("RenderNodesForViz", &mRenderNodesForViz); 
     758void MouseQueryListener::nextNodeVizMode() 
     759{ 
     760        mNodeVizMode = (mNodeVizMode + 1) % NODEVIZ_MODES_NUM; 
     761 
     762        bool renderNodesForViz =  
     763                (mNodeVizMode == NODEVIZ_RENDER_NODES) ||  
     764                (mNodeVizMode == NODEVIZ_RENDER_NODES_AND_CONTENT); 
     765        bool renderNodesContentForViz = mNodeVizMode == NODEVIZ_RENDER_NODES_AND_CONTENT; 
     766 
     767        mSceneMgr->setOption("RenderNodesForViz", &renderNodesForViz); 
     768        mSceneMgr->setOption("RenderNodesContentForViz", &renderNodesContentForViz); 
    765769} 
    766770//----------------------------------------------------------------------- 
     
    848852        const bool nShowViz = !showViz; 
    849853 
     854        // ambient light must be full for visualization 
     855    if (showViz) 
     856        { 
     857                mSceneMgr->setAmbientLight(ColourValue(1, 1, 1)); 
     858        } 
     859        else 
     860        { 
     861                mSceneMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); 
     862        } 
     863 
    850864    mSceneMgr->setOption("ShowVisualization", &showViz); 
    851865        mSceneMgr->setOption("SkyBoxEnabled", &nShowViz); 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.h

    r112 r113  
    8787        enum  {WALKTHROUGH, REPLAY, STATE_NUM}; 
    8888 
     89        // visualization modes for scene nodes 
     90        enum {NODEVIZ_NONE, NODEVIZ_RENDER_NODES,  
     91                  NODEVIZ_RENDER_NODES_AND_CONTENT, NODEVIZ_MODES_NUM}; 
     92 
    8993        void nextAlgorithm(); 
    9094        void changeThreshold(int incr); 
     
    9599        void toggleUseVisibilityCulling(); 
    96100        void toggleShowViz(); 
    97         void toggleRenderNodesForViz(); 
     101        void nextNodeVizMode(); 
    98102        void toggleRecord(); 
    99103 
     
    148152        bool mUseVisibilityCulling; 
    149153        bool mShowVisualization; 
    150         bool mRenderNodesForViz; 
     154        int mNodeVizMode; 
    151155        bool mCullCamera; 
    152156 
Note: See TracChangeset for help on using the changeset viewer.