Changeset 156 for trunk/VUT/Ogre


Ignore:
Timestamp:
07/06/05 02:36:16 (19 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/Ogre
Files:
7 edited

Legend:

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

    r155 r156  
    106106    bool IsBoundingBoxQuery(); 
    107107 
    108         /** Finds visible objects of hierarchy node using occlusion queries 
    109         @param node the current scene node 
    110         @param objs the visible objects 
    111         @param includeChildren if the children of current scene nodes should also be traversed 
    112         */ 
    113         /*virtual bool FindVisibleObjects(GtpVisibility::HierarchyNode *node,    
    114                                                                         InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry,  
    115                                                                         bool includeChildren = false) = 0;*/ 
     108 
    116109protected: 
    117110        /** Renders geometry  
     
    126119        */ 
    127120        void DeleteQueries(); 
    128          
    129         /** Renders bounding box of specified node. 
    130                 @param box the bounding box of the scene node to be rendered  
    131         */ 
    132         void RenderBoundingBox(AxisAlignedBox *box); 
    133121 
    134122        /** Returns pointer to current renderable bounding box geometry. 
     
    138126        /** A pass that prepares an occlusion query. 
    139127                @remark disables depth write, colour write, lighting, 
    140                 vertex and fragment program. 
    141         */ 
     128                vertex and fragment program.*/ 
    142129        //void SetOcclusionPass(); 
    143130 
    144         /** Returns pointer to current renderable half bounding box geometry.*/ 
    145         //SolidHalfBoundingBox *GetSolidHalfBoundingBox(); 
     131        /** Renders given bounding box. 
     132                @param box the bounding box of the scene node to be rendered  
     133        */ 
     134        void RenderBoundingBox(AxisAlignedBox *box); 
    146135 
    147136        /** Renderable of an aabb. 
  • trunk/VUT/Ogre/include/OgreSolidBoundingBox.h

    r117 r156  
    99        no colors, and no lighting. 
    1010*/ 
    11 class SolidBoundingBox : public SimpleRenderable 
     11class __declspec(dllexport) SolidBoundingBox : public SimpleRenderable 
    1212{ 
    1313public: 
     
    3030 
    3131protected: 
    32                 /**  
    33                         Sets the material used for occlusion queries.  
    34                         @remark the material is called "Visibility/QueryMaterial" and 
    35                         uses no lighting, no depth write, and no colours 
    36                 */ 
    37                 void SetOcclusionQueryMaterial(); 
    38         /** Override this method to prevent parent transforms (rotation,translation,scale) 
    39         */ 
    40                 void getWorldTransforms( Matrix4* xform ) const; 
    41         /** @copydoc Renderable::getWorldOrientation */ 
    42         const Quaternion& getWorldOrientation(void) const; 
    43         /** @copydoc Renderable::getWorldPosition */ 
    44         const Vector3& getWorldPosition(void) const; 
     32        /**  
     33                Sets the material used for occlusion queries.  
     34                @remark the material is called "Visibility/QueryMaterial" and 
     35                uses no lighting, no depth write, and no colours 
     36        */ 
     37        void SetOcclusionQueryMaterial(); 
     38 
     39        /** Override this method to prevent parent transforms (rotation,translation,scale) 
     40    */ 
     41        void getWorldTransforms( Matrix4* xform ) const; 
     42    /** @copydoc Renderable::getWorldOrientation */ 
     43    const Quaternion& getWorldOrientation(void) const; 
     44    /** @copydoc Renderable::getWorldPosition */ 
     45    const Vector3& getWorldPosition(void) const; 
    4546                 
    46         /** Builds the wireframe line list. 
    47         */ 
    48                 void setupBoundingBoxVertices(const AxisAlignedBox& aab); 
     47    /** Builds the wireframe line list. 
     48    */ 
     49        void setupBoundingBoxVertices(const AxisAlignedBox& aab); 
    4950 
    50         Real mRadius; 
     51    Real mRadius; 
    5152}; 
    5253 
  • trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h

    r155 r156  
    1111#include "OgrePlatformQueryManager.h" 
    1212#include "VisibilityManager.h" 
     13#include <OgreSolidBoundingBox.h> 
     14 
    1315 
    1416namespace Ogre { 
     
    123125        ShadowTechnique mSavedShadowTechnique; 
    124126 
    125         bool mRenderOnlyBoundingBoxes; 
     127        bool mRenderHierarchyNodes; 
     128 
     129        std::vector<SolidBoundingBox *> mSolidBoxes; 
    126130}; 
    127131 
  • trunk/VUT/Ogre/src/OgreItemBufferQueryManager.cpp

    r155 r156  
    3232        SceneManager *sm = pfHierarchyInterface->GetSceneManager(); 
    3333 
    34         // ---- Render scene as item buffer (i.e., objects with their id as color codes) 
     34        // ---- Render scene with item buffer (i.e., objects with their id as color codes) 
    3535 
    3636        // const_cast allowed because camera is not changed in renderScene 
     
    5252        // --- render item buffer 
    5353        pfHierarchyInterface->GetSceneManager()->_renderScene(pCam, mViewport, false); 
    54          
    55  
    56  
    57         // reset old overlay status 
    58         mViewport->setOverlaysEnabled(overlayEnabled); 
    59          
    60         mViewport->setBackgroundColour(bg); 
    61  
    62         // don't need item buffer anymore 
    63         useItemBuffer = false; 
    64         sm->setOption("UseItemBuffer", &useItemBuffer); 
    6554 
    6655 
     
    8877        } 
    8978 
     79        delete [] buf; 
     80 
     81        // ---- render visible nodes and collect node visibility 
     82        bool renderBoxes = true; 
     83        sm->setOption("RenderHierarchyNodes", &renderBoxes); 
     84 
     85 
     86        // --- render item buffer for visible nodes only 
     87        pfHierarchyInterface->GetSceneManager()->_renderScene(pCam, mViewport, false); 
     88 
     89 
     90        // get frame buffer for node visibility 
     91        buf = mViewport->getTarget()->getBufferContents(dimx, dimy); 
     92 
     93         
     94        // loop through frame buffer & collect visible pixels 
     95        for (int idx = 0; idx < dimy * dimx * 3; idx += 3) 
     96        { 
     97                // -- decode color code to receive id 
     98                int id = buf[idx] << 16; 
     99                id += buf[idx + 1] << 8; 
     100                id += buf[idx + 2]; 
     101 
     102                // if valid id <= add visibility (id values start at 1 
     103                if ((id > 0) && (id < (int)visibleNodes->size())) 
     104                { 
     105                        ((*visibleNodes)[id]).AddVisibility(1, 1); 
     106                } 
     107        } 
     108 
     109        // don't need item buffer anymore 
     110        useItemBuffer = false; 
     111        //sm->setOption("UseItemBuffer", &useItemBuffer); 
     112 
     113        renderBoxes = false; 
     114        //sm->setOption("RenderHierarchyNodes", &renderBoxes); 
     115 
    90116        // reset initialised - flag 
    91117        mWasInitialised = false; 
     118 
     119        // reset old overlay status 
     120        mViewport->setOverlaysEnabled(overlayEnabled); 
     121         
     122        mViewport->setBackgroundColour(bg); 
    92123 
    93124        delete [] buf; 
     
    99130        if (mWasInitialised) 
    100131                return; 
    101  
    102132 
    103133        mWasInitialised = true; 
     
    122152        GtpVisibility::HierarchyNode *node = NULL; 
    123153         
     154        int i = 1; 
     155 
    124156        while (node = mHierarchyInterface->GetNextNode()) 
    125157        { 
     158                mHierarchyInterface->SetNodeId(node, i++); 
    126159                visibleNodes->push_back(GtpVisibility::NodeInfo(node, 0, 0)); 
    127160        } 
  • trunk/VUT/Ogre/src/OgrePlatformQueryManager.cpp

    r154 r156  
    5757                // prevent from initialising geometry / node array again 
    5858                if (i > 0) 
     59                { 
    5960                        mWasInitialised = true; 
     61                } 
    6062 
    6163                ComputeCameraVisibility(*cam, visibleNodes, visibleGeometry, relativeVisibility); 
    6264                 
    63                 //mViewport->getTarget()->update(); for(int j=0; j<10000000; j++)       printf("wait"); 
     65                mViewport->getTarget()->update(); for(int j=0; j<10000000; j++) printf("wait"); 
    6466 
    6567                // permute directions 
  • trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp

    r155 r156  
    4141        if (depthMat.isNull()) 
    4242    { 
    43                 // Init 
    4443                depthMat = MaterialManager::getSingleton().create( 
    4544                "Visibility/DepthPass", 
  • trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp

    r155 r156  
    99#include <OgreEntity.h> 
    1010#include <OgreSubEntity.h> 
     11 
    1112 
    1213namespace Ogre { 
     
    3132mSkipTransparents(false), 
    3233mSavedShadowTechnique(SHADOWTYPE_NONE), 
    33 mRenderOnlyBoundingBoxes(false) 
     34mRenderHierarchyNodes(false) 
     35//mRenderHierarchyNodes(true) 
    3436{ 
    3537        mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); 
     
    147149        //Pass *usedPass = ((mRenderDepthPass && !pass->hasVertexProgram()) ? mDepthPass : pass);  
    148150         
    149         // set depth fill pass only if depth write enabled 
     151        // set depth fill pass if we currently do not make an aabb occlusion query 
    150152        Pass *usedPass = (mRenderDepthPass && !mHierarchyInterface->IsBoundingBoxQuery() ?  
    151153                                          mDepthPass : pass); 
     
    208210void VisibilityTerrainSceneManager::_findVisibleObjects(Camera* cam, bool onlyShadowCasters) 
    209211{ 
     212        // clear list of solid boxes (used for item buffer hierarchy node rendering) 
     213        /*for (int i=0; i<(int)mSolidBoxes.size(); ++i) 
     214                delete mSolidBoxes[i]; 
     215 
     216        mSolidBoxes.clear();*/ 
     217 
    210218        //-- show visible scene nodes and octree bounding boxes from last frame 
    211219        if (mShowVisualization) 
     
    213221                PrepareVisualization(cam); 
    214222        } 
    215         else if (mRenderOnlyBoundingBoxes) 
    216         { 
     223        else if (mRenderHierarchyNodes) 
     224        { 
     225                AxisAlignedBox aab; 
     226                 
     227 
     228                // get rendered hierarchy nodes from last frame 
     229                GtpVisibility::HierarchyNodeList *nodeList = mHierarchyInterface->GetRenderedNodes(); 
     230                GtpVisibility::HierarchyNodeList::iterator nodeIt, nodeIt_end = nodeList->end(); 
     231 
     232                for (nodeIt = nodeList->begin(); nodeIt != nodeIt_end; ++nodeIt)                 
     233                { 
     234                        SolidBoundingBox *solidBox = new SolidBoundingBox(); 
     235                        solidBox->SetupBoundingBox(aab); 
     236 
     237                        Octree *octree = static_cast<Octree *>(*nodeIt); 
     238                        solidBox->setId(octree->getId()); 
     239                        mSolidBoxes.push_back(solidBox); 
     240 
     241                        aab = octree->_getWorldAABB(); 
     242                        std::stringstream d; d << "bounding box with id: " << octree->getId() << ", " << aab << "\n"; 
     243                        LogManager::getSingleton().logMessage(d.str()); 
     244 
     245                        getRenderQueue()->addRenderable(solidBox);       
     246                } 
    217247        } 
    218248        else  
     
    233263        //TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
    234264         
     265        // -- delete lists stored for visualization 
    235266        mVisible.clear(); 
    236267        mBoxes.clear(); 
    237  
    238268} 
    239269//----------------------------------------------------------------------- 
     
    246276    // e.g., visualization, shadow pass 
    247277 
    248         if (mShowVisualization || mRenderOnlyBoundingBoxes || 
    249            (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE && mIlluminationStage == IRS_RENDER_TO_TEXTURE)) 
     278        if (mShowVisualization || mRenderHierarchyNodes || 
     279           (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE &&  
     280            mIlluminationStage == IRS_RENDER_TO_TEXTURE)) 
    250281        {        
    251282                IlluminationRenderStage savedStage = mIlluminationStage;  
    252283         
    253                 if (mShowVisualization)  
    254                         // disable illumination stage because we want no shadows in visualization 
     284                if (mShowVisualization || mRenderHierarchyNodes)  
     285                        // disable illumination stage because we want no shadows 
    255286                        mIlluminationStage = IRS_NONE; 
    256287 
     
    416447                mUseItemBuffer = (*static_cast<const bool *>(val)); 
    417448                return true; 
     449        } 
     450        if (key == "RenderHierarchyNodes") 
     451        { 
     452                mRenderHierarchyNodes = (*static_cast<const bool *>(val)); 
    418453        } 
    419454        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 
     
    503538        } 
    504539 
    505         //--- item buffer 
     540        // --- item buffer 
     541 
    506542    // Iterate through priorities 
    507543    RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator(); 
     
    604640 
    605641        Pass *usedPass = setPass(mItemBufferPass);  
    606          
    607         /*if (rend->getId() > 0) 
    608         { 
    609                 std::stringstream d; d << "item buffer id: " << rend->getId() << ", col: " << col[0] << 
    610                         " " << col[1] << " " << col[2] << " " << col[3]; 
    611                 LogManager::getSingleton().logMessage(d.str()); 
    612         }*/ 
     642 
    613643 
    614644        // Render a single object, this will set up auto params if required 
Note: See TracChangeset for help on using the changeset viewer.