Changeset 54


Ignore:
Timestamp:
04/21/05 14:04:02 (19 years ago)
Author:
mattausch
Message:

fixed terrainscenemanager bug

Location:
trunk/VUT/OcclusionCullingSceneManager
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/OcclusionCullingSceneManager/include/OgreSolidHalfBoundingBox.h

    r51 r54  
    1717        public: 
    1818 
    19                 SolidHalfBoundingBox(bool isFirstHalf); 
    20                 void setupBoundingBox(const AxisAlignedBox& aabb); 
     19                SolidHalfBoundingBox( bool isFirstHalf ); 
     20                void setupBoundingBox( const AxisAlignedBox& aabb ); 
    2121                /** Override this method to prevent parent transforms (rotation,translation,scale) 
    2222                and to make it public. 
     
    2929                @param the axis aligned bounding box for setting up the list. 
    3030        */ 
    31                 void setupBoundingBoxVertices(const AxisAlignedBox& aab); 
    32  
     31                void setupBoundingBoxVertices( const AxisAlignedBox& aab ); 
     32                /**  
     33                        Sets the material used for occlusion queries.  
     34                        @remarks the material is called "OcclusionQuery" and 
     35                        uses no lighting, no depth write, and no colours 
     36                */ 
     37                void setOcclusionQueryMaterial( void ); 
     38                /** Whether this half box is the first or the second half of the bounding box.  
     39                */ 
    3340                bool mIsFirstHalf;       
    3441        }; 
  • trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingOctreeSceneTraverser.cpp

    r52 r54  
    2828                { 
    2929                        Octree *nextChild = octant->mChildren[(i & 4) >> 2][(i & 2) >> 1][i & 1]; 
    30  
    31                         /*char msg[100]; 
    32                         sprintf(msg, "node number: %d %d %d\n", (i & 4) >> 2, (i & 2) >> 1, i & 1); 
    33                         OutputDebugString(msg);*/ 
    3430 
    3531                        if(nextChild) 
     
    5955                        } 
    6056 
     57                        mRenderSystem->_setRasterisationMode(SDL_WIREFRAME); 
     58                        renderBoundingBox(&box); 
     59                        mRenderSystem->_setRasterisationMode(SDL_SOLID); 
    6160                        // update node's visited flag  
    6261                        octant->setLastVisited(mFrameId); 
     
    8685                        bool intersects = false; 
    8786 
    88                         /*char msg2[100]; 
    89                         Vector3 min = box.getMinimum(); 
    90                         Vector3 max = box.getMaximum(); 
    91  
    92                         sprintf(msg2, "culling box: %3.3f %3.3f %3.3f %3.3f %3.3f %3.3f\n", min.x, min.y, min.z, max.x, max.y, max.z); 
    93                         OutputDebugString(msg2);*/ 
    94  
    9587                        if(!cam->isVisible(box, intersects)) 
    9688                        { 
     
    10294                        { 
    10395                                octant->setOctreeVisible(true); 
    104                         //      char msg[100]; sprintf(msg, "intersecting\n"); 
    105                         //      OutputDebugString(msg); 
    10696                                traverseOctant(cam, octant); 
    10797                                continue; 
     
    114104                        query->pullOcclusionQuery(&visiblePixels); 
    115105 
    116                         char msg[100]; sprintf(msg, "visible pixels: %d\n", visiblePixels, intersects); 
    117                         OutputDebugString(msg); 
     106                        //char msg[100]; sprintf(msg, "visible pixels: %d\n", visiblePixels); 
     107                        //OutputDebugString(msg); 
    118108 
    119109                        // node visible 
     
    124114                        else 
    125115                        { 
     116                                /* 
     117                                char msg2[100]; 
     118                                Vector3 min = box.getMinimum(); 
     119                                Vector3 max = box.getMaximum(); 
     120 
     121                                sprintf(msg2, "culling box: %3.3f %3.3f %3.3f %3.3f %3.3f %3.3f\n", min.x, min.y, min.z, max.x, max.y, max.z); 
     122                                OutputDebugString(msg2); 
     123                                */ 
     124 
    126125                                mNumQueryCulledNodes ++; 
    127126                        } 
     
    192191                                bool wasVisible = octant->isOctreeVisible() && (octant->lastVisited() == mFrameId - 1); 
    193192                                 
    194                                 /*  
    195                                 char msg[100]; 
    196                                 if(wasVisible) sprintf(msg, "yes, was visible, %d\n", mFrameId); 
    197                                 else sprintf(msg, "no was invisible, %d\n", mFrameId); 
    198                                 OutputDebugString(msg); 
    199                                 */ 
    200  
    201193                                // identify nodes that we cannot skip queries for 
    202194                                bool mustQuery = !wasVisible || (octant->numNodes() > 0) || isLeaf(octant); 
     
    242234 
    243235                        //TODO: does nothing useful 
    244                         setRenderingMode(MODE_RENDER); 
     236                        //setRenderingMode(MODE_RENDER); 
    245237 
    246238                        ((OctreeSceneManager *)mSceneManager)->_renderOctant(cam, octant); 
  • trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingSceneTraverser.cpp

    r52 r54  
    4444 
    4545                initDistanceQueue(cam); 
    46  
    47                 //deleteQueries(); 
    48                 //char *msg = "deleting queries\n"; OutputDebugString(msg); 
    49         //for(unsigned int i=0; i < 1000; i++) 
    50                 //mOcclusionQueries.push_back(mRenderSystem->createHardwareOcclusionQuery()); 
    51  
    52             //mCurrentAlgorithm = RENDER_CULL_FRUSTUM; 
    5346 
    5447                switch(mCurrentAlgorithm) 
     
    235228                // TODO: in rendervisibleobjects, the rendermode is changed by ogre itself => change this!! 
    236229                 
    237                 setRenderingMode(MODE_QUERY); 
    238                 //mRenderSystem->_setRasterisationMode(SDL_SOLID);setRenderingMode(MODE_RENDER); 
     230                //setRenderingMode(MODE_QUERY); 
     231                //mRenderSystem->_setRasterisationMode(SDL_SOLID); setRenderingMode(MODE_RENDER); 
    239232 
    240233                // get next available test id 
     
    247240 
    248241                query->endOcclusionQuery(); 
    249  
    250                  
    251                 //mRenderSystem->_setRasterisationMode(SDL_WIREFRAME); 
     242         
     243                /*mRenderSystem->_setRasterisationMode(SDL_WIREFRAME); 
    252244                setRenderingMode(MODE_RENDER); 
    253245                renderBoundingBox(box); 
    254                 //mRenderSystem->_setRasterisationMode(SDL_SOLID); 
     246                mRenderSystem->_setRasterisationMode(SDL_SOLID);*/ 
    255247                 
    256248                return query; 
     
    278270                mRenderSystem->_setColourBufferWriteEnabled(enabled, enabled, enabled, enabled); 
    279271                        mRenderSystem->_setDepthBufferWriteEnabled(enabled); 
    280                         mRenderSystem->setLightingEnabled(enabled); 
     272                        //mRenderSystem->setLightingEnabled(enabled); 
    281273                } 
    282274        } 
     
    304296        { 
    305297                //TODO: does not do any changes 
    306                 setRenderingMode(MODE_RENDER); 
     298                //setRenderingMode(MODE_RENDER); 
    307299                 
    308300                if(node->lastRendered() != node->lastVisited()) 
     
    383375                        halfbox->setupBoundingBox(*box); 
    384376                         
    385                         mRenderSystem->_setWorldMatrix(Matrix4::IDENTITY); 
    386  
    387                         // Set world transformation 
    388                         /*halfbox->getWorldTransforms(xform); 
     377                        /*mRenderSystem->_setWorldMatrix(Matrix4::IDENTITY); 
     378 
     379                        halfbox->getWorldTransforms(xform); 
    389380 
    390381                        int numMatrices = halfbox->getNumWorldTransforms(); 
     
    397388                                mRenderSystem->_setWorldMatrix(*xform); 
    398389                        } 
    399                         mRenderSystem->setClipPlanes(halfbox->getClipPlanes());*/ 
     390                        mRenderSystem->setClipPlanes(halfbox->getClipPlanes()); 
    400391 
    401392                        static RenderOperation ro; 
     
    404395                        halfbox->getRenderOperation(ro); 
    405396                        ro.srcRenderable = halfbox;  
    406                         mRenderSystem->_render(ro); 
    407  
    408                         //mSceneManager->myrenderSingleObject(getSolidHalfBoundingBox(half), getSolidHalfBoundingBox(half)->getTechnique()->getPass(0), true); 
     397                        mRenderSystem->_render(ro);*/ 
     398                         
     399                        mSceneManager->myrenderSingleObject(getSolidHalfBoundingBox(half),  
     400                                getSolidHalfBoundingBox(half)->getTechnique()->getPass(0), true); 
    409401                } 
    410402        } 
     
    444436                { 
    445437                        mOcclusionQueries.push_back(mRenderSystem->createHardwareOcclusionQuery()); 
    446                         //char *msg = "creating query!!\n"; OutputDebugString(msg); 
    447438                } 
    448439                 
  • trunk/VUT/OcclusionCullingSceneManager/src/OgreOcclusionCullingTerrainSceneManager.cpp

    r52 r54  
    1818                mShowBoxes = true; 
    1919                //mDisplayNodes = true; 
    20                 //mShowBoundingBoxes = true; 
    21                 //mMaxDepth = 20; 
     20                mShowBoundingBoxes = true; 
     21                mMaxDepth = 20; 
    2222        } 
    2323        //----------------------------------------------------------------------- 
  • trunk/VUT/OcclusionCullingSceneManager/src/OgreSolidHalfBoundingBox.cpp

    r51 r54  
    55#include "OgreHardwareBufferManager.h" 
    66#include "OgreCamera.h" 
     7#include "OgreMaterialManager.h" 
    78//#include <windows.h> 
    89 
     
    1314                :WireBoundingBox(), mIsFirstHalf(isFirstHalf) 
    1415    { 
     16                setOcclusionQueryMaterial(); 
     17                 
    1518                mRenderOp.vertexData->vertexCount = 8; 
    1619        mRenderOp.operationType = RenderOperation::OT_TRIANGLE_FAN;  
     
    9598        *xform = Matrix4::IDENTITY; 
    9699    } 
     100 
     101        void SolidHalfBoundingBox::setOcclusionQueryMaterial( void ) 
     102        { 
     103                m_pMaterial = MaterialManager::getSingleton().getByName("OcclusionQuery"); 
     104 
     105                if(m_pMaterial.isNull()) 
     106                { 
     107                        m_pMaterial = MaterialManager::getSingleton(). 
     108                                create("OcclusionQuery", ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 
     109                } 
     110 
     111                m_pMaterial->setColourWriteEnabled(false); 
     112                m_pMaterial->setDepthWriteEnabled(false); 
     113                m_pMaterial->setLightingEnabled(false); 
     114 
     115                setMaterial("OcclusionQuery"); 
     116        } 
    97117} 
    98118 
Note: See TracChangeset for help on using the changeset viewer.