Changeset 159 for trunk


Ignore:
Timestamp:
07/06/05 17:52:44 (19 years ago)
Author:
mattausch
Message:

added flags for switching on/off transparents for item buffer and vertex programs for depth pass / item buffer

Location:
trunk/VUT
Files:
27 edited

Legend:

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

    r144 r159  
    2525                            InfoContainer<NodeInfo> *visibleNodes, 
    2626                            InfoContainer<MeshInfo> *visibleGeometry, 
     27                                InfoContainer<GtpVisibility::PatchInfo> *visiblePatches, 
    2728                            bool relativeVisibility = false ); 
    2829     
     
    3435                               InfoContainer<NodeInfo> *visibleNodes, 
    3536                               InfoContainer<MeshInfo> *visibleGeometry, 
     37                                        InfoContainer<GtpVisibility::PatchInfo> *visiblePatches, 
    3638                               bool relativeVisibility = false 
    3739                               ); 
  • trunk/VUT/GtpVisibility/include/QueryManager.h

    r144 r159  
    5151                            InfoContainer<NodeInfo> *visibleNodes, 
    5252                            InfoContainer<MeshInfo> *visibleGeometry, 
     53                                InfoContainer<GtpVisibility::PatchInfo> *visiblePatches, 
    5354                            bool relativeVisibility = false 
    5455                            ) = 0; 
     
    6263                               InfoContainer<NodeInfo> *visibleNodes, 
    6364                               InfoContainer<MeshInfo> *visibleGeometry, 
     65                                   InfoContainer<GtpVisibility::PatchInfo> *visiblePatches, 
    6466                               bool relativeVisibility = false 
    6567                               ) = 0; 
  • trunk/VUT/GtpVisibility/include/VisibilityInfo.h

    r150 r159  
    7777    Mesh *mMesh; 
    7878}; 
    79    
     79 
     80/** Class storing the visibility information of a patch, i.e., parts of meshes having the same material 
     81        properties. 
     82*/ 
     83class PatchInfo: public VisibilityInfo 
     84{ 
     85public: 
     86        PatchInfo(Patch *Patch, const int visiblePixels, const int projectedPixels); 
     87 
     88        Patch *GetPatch() const; 
     89        void SetPatch(Patch *patch); 
     90         
     91protected: 
     92 
     93    /** Pointer to the patch. 
     94        */ 
     95    Patch *mPatch; 
     96}; 
     97 
    8098//TODO: this define shall be replaced by template typedef 
    8199#define InfoContainer std::vector 
  • trunk/VUT/GtpVisibility/include/VisibilityMesh.h

    r130 r159  
    77namespace GtpVisibility { 
    88  typedef Ogre::Entity Mesh; 
     9  typedef Ogre::SubEntity Patch; 
    910} 
    1011 
  • trunk/VUT/GtpVisibility/src/DummyQueryManager.cpp

    r155 r159  
    1111                                             InfoContainer<NodeInfo> *visibleNodes, 
    1212                                             InfoContainer<MeshInfo> *visibleGeometry, 
     13                                                 InfoContainer<GtpVisibility::PatchInfo> *visiblePatches, 
    1314                                             bool relativeVisibility) 
    1415  { 
     
    2930                                                InfoContainer<NodeInfo> *visibleNodes, 
    3031                                                InfoContainer<MeshInfo> *visibleGeometry, 
     32                                                InfoContainer<GtpVisibility::PatchInfo> *visiblePatches, 
    3133                                                bool relativeVisibility) 
    3234  { 
  • trunk/VUT/GtpVisibility/src/VisibilityInfo.cpp

    r153 r159  
    8888        return mMesh; 
    8989} 
     90 
     91/****************************************************/ 
     92/*              PatchInfo implementation             */ 
     93/****************************************************/ 
     94//----------------------------------------------------------------------- 
     95PatchInfo::PatchInfo(Patch *patch, const int visiblePixels, const int projectedPixels):  
     96VisibilityInfo(visiblePixels, projectedPixels), mPatch(patch)  
     97{} 
     98//----------------------------------------------------------------------- 
     99void PatchInfo::SetPatch(Patch *patch)  
     100{ 
     101        mPatch = patch; 
     102} 
     103//-----------------------------------------------------------------------        
     104Patch *PatchInfo::GetPatch() const  
     105{ 
     106        return mPatch; 
     107} 
    90108}// namespace GtpVisibility 
  • trunk/VUT/Ogre/include/OgreItemBufferQueryManager.h

    r154 r159  
    77   
    88/** 
    9         Class which implements the QueryManager for Ogre scene queries. 
     9        Class which implements the QueryManager for Ogre scene queries using an item buffer, 
     10        i.e., the objects are rendered with their id used as unique color code. After reading 
     11        back the frame buffer, the visibility information can be established for each object. 
    1012*/ 
    1113class __declspec(dllexport) ItemBufferQueryManager: public PlatformQueryManager 
     
    1315public: 
    1416    /** Constructor taking a hierarchy interface as an argument. This allows to operate 
    15         onm different hierarchy types, while reusing the implementation of the query methods. 
     17                on different hierarchy types, while reusing the implementation of the query methods. 
     18                @param renderPatches determines if the visibility of either patches or meshes is computed. 
    1619    */ 
    17         ItemBufferQueryManager(PlatformHierarchyInterface *hierarchyInterface, Viewport *vp); 
     20        ItemBufferQueryManager(PlatformHierarchyInterface *hierarchyInterface, Viewport *vp, 
     21                                                   const bool renderPatches); 
    1822     
    1923    void ComputeCameraVisibility(const Camera &camera, 
    2024                            InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 
    2125                            InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 
     26                                InfoContainer<GtpVisibility::PatchInfo> *visiblePatches, 
    2227                            bool relativeVisibility = false); 
    2328     
     
    2530         
    2631protected: 
    27         void InitItemBuffer( InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 
    28                             InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry); 
     32        /** Helper function used to initialise item buffer. 
     33        */ 
     34        void InitItemBuffer(  
     35                                InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 
     36                            InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 
     37                                InfoContainer<GtpVisibility::PatchInfo> *visiblePatches); 
    2938         
     39        /// if patches are used instead of meshes (only one at a time) 
     40        bool mRenderPatchesForItemBuffer; 
    3041}; 
    3142 
  • trunk/VUT/Ogre/include/OgreOcclusionQueriesQueryManager.h

    r154 r159  
    77   
    88/** 
    9         Class which implements the QueryManager for Ogre scene queries. 
     9        Class which implements the QueryManager for Ogre scene queries using occlusion queries. 
    1010*/ 
    1111class __declspec(dllexport) OcclusionQueriesQueryManager: public PlatformQueryManager 
     
    1313public: 
    1414    /** Constructor taking a hierarchy interface as an argument. This allows to operate 
    15         onm different hierarchy types, while reusing the implementation of the query methods. 
     15                on different hierarchy types, while reusing the implementation of the query methods. 
    1616    */ 
    1717        OcclusionQueriesQueryManager(PlatformHierarchyInterface *hierarchyInterface, Viewport *vp); 
     
    2020                            InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 
    2121                            InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 
     22                                InfoContainer<GtpVisibility::PatchInfo> *visiblePatches, 
    2223                            bool relativeVisibility = false); 
    2324     
     
    2930                               InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 
    3031                               InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 
     32                                   InfoContainer<GtpVisibility::PatchInfo> *visiblePatches, 
    3133                               bool relativeVisibility = false); 
    3234     
  • trunk/VUT/Ogre/include/OgrePlatformQueryManager.h

    r154 r159  
    2626                               InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 
    2727                               InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 
     28                                   InfoContainer<GtpVisibility::PatchInfo> *visiblePatches, 
    2829                               bool relativeVisibility = false); 
    2930     
  • trunk/VUT/Ogre/include/OgreVisibilityOctreeSceneManager.h

    r139 r159  
    1717        occlusion queries for visibility culling. 
    1818*/ 
    19 class VisibilityOctreeSceneManager: public OctreeSceneManager 
     19class __declspec(dllexport) VisibilityOctreeSceneManager: public OctreeSceneManager 
    2020{ 
    2121public: 
     
    5959        void WriteLog(); 
    6060 
    61         /** Override pass so we can do the z-fail pass */ 
     61        /** Override pass so we can do the z-fail pass.  
     62        */ 
    6263        Pass* setPass(Pass* pass); 
    6364 
     65        /** Override from SceneManager so we can skip all but first pass for depth pass.  
     66        */ 
     67        bool validatePassForRendering(Pass* pass); 
     68 
     69        void RenderItemBuffer(RenderPriorityGroup* pGroup); 
     70        void RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass); 
     71        void renderQueueGroupObjects(RenderQueueGroup* pGroup); 
     72 
     73        /** Override from SceneManager so that sub entities can be assigned an id for item buffer. 
     74        */ 
     75        //Entity* createEntity(const String& entityName, const String& meshName); 
     76 
     77        /** Returns pointer to visibility manager. 
     78        */ 
     79        GtpVisibility::VisibilityManager *GetVisibilityManager(); 
     80 
     81        /** Returns hierarchy interface. 
     82        */ 
     83        OctreeHierarchyInterface *GetHierarchyInterface(); 
     84 
     85 
    6486protected: 
    65         /** Creates material for depth pass, e.g., a pass that only fills the depth buffer */ 
     87         
     88        /** Creates material for depth pass, e.g., a pass that only fills the depth buffer.  
     89        */ 
    6690        void InitDepthPass(); 
     91        /** Creates material for item buffer.  
     92        */ 
     93        void InitItemBufferPass(); 
     94        /** Fills render queue so that a visualization can be rendered.  
     95        */ 
     96        void PrepareVisualization(Camera *cam); 
     97        /** Initialises necessary parameters for hierarchical visibility culling. 
     98        */ 
     99        void InitVisibilityCulling(Camera *cam); 
    67100         
    68         /** Prepares visualization of hierarchical culling. */ 
    69         void PrepareVisualization(Camera *cam); 
     101        /// the interface to the scene hierarchy. 
    70102        OctreeHierarchyInterface *mHierarchyInterface; 
     103        /// manages all visibility options 
    71104        GtpVisibility::VisibilityManager *mVisibilityManager; 
    72105         
     106        /// if a visualization of the hierarchical culling is shown 
    73107        bool mShowVisualization; 
    74         bool mSkipTransparents; 
     108 
     109        /// if the culled nodes are indicated in the visualization 
    75110        bool mVisualizeCulledNodes; 
    76111 
     112        /// if symbols for the nodes are shown in the visualization 
    77113        bool mRenderNodesForViz; 
     114        /// if content of the nodes is shown in the visualization 
    78115        bool mRenderNodesContentForViz; 
     116 
     117        /// render transparents after the hierarchical traversal 
    79118        bool mDelayRenderTransparents; 
     119 
     120        /// use a depth pass (i.e., fill only the depth buffer in the first pass) 
    80121        bool mUseDepthPass; 
     122        /// flag indicating if we currently render the depth pass 
    81123        bool mRenderDepthPass; 
    82124 
     125        /// if we use an item buffer for rendering (i.e., object ids as color codes 
     126        bool mUseItemBuffer; 
     127        /// if we currently render the item buffer  
     128        bool mRenderItemBuffer; 
     129 
     130        /// if depth write should be enabled 
     131        bool mEnableDepthWrite; 
     132        /// if transparents are skipped during rendering 
     133        bool mSkipTransparents; 
     134 
     135        /// the depth pass (no lighting, just filling the depth buffer) 
    83136        Pass *mDepthPass; 
     137        Pass *mItemBufferPass; 
     138 
     139        int mCurrentEntityId; 
     140        /// flag for passes which should not be deleted from queue during first traversal 
     141        int mLeavePassesInQueue; 
     142        ShadowTechnique mSavedShadowTechnique; 
     143 
     144        /// if transparent object are considered for item buffer visibility 
     145        bool mRenderTransparentsForItemBuffer; 
     146        /// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer 
     147        bool mExecuteVertexProgramForAllPasses; 
    84148}; 
    85149 
  • trunk/VUT/Ogre/include/OgreVisibilityTerrainSceneManager.h

    r158 r159  
    7575        /** Override from SceneManager so that sub entities can be assigned an id for item buffer. 
    7676        */ 
    77         Entity* createEntity(const String& entityName, const String& meshName); 
     77        //Entity* createEntity(const String& entityName, const String& meshName); 
    7878 
    7979        /** Returns pointer to visibility manager. 
     
    8484        */ 
    8585        OctreeHierarchyInterface *GetHierarchyInterface(); 
     86 
     87        void endFrame(); 
     88 
    8689 
    8790protected: 
     
    142145        int mLeavePassesInQueue; 
    143146        ShadowTechnique mSavedShadowTechnique; 
     147 
     148        /// if transparent object are considered for item buffer visibility 
     149        bool mRenderTransparentsForItemBuffer; 
     150        /// Always execute the vertex program of a pass, e.g., for the depth pass or item buffer 
     151        bool mExecuteVertexProgramForAllPasses; 
    144152}; 
    145153 
  • trunk/VUT/Ogre/resources/VisibilityDemo.overlay

    r155 r159  
    452452                        caption [F] toggle filtering method (trilinear, anisotropic, bilinear) 
    453453                } 
     454                element TextArea(Example/Visibility/Help/FromCameraQueryInfo): Example/Visibility/Templates/BasicText 
     455                { 
     456                        left 5 
     457                        top 285 
     458                        width 180 
     459                        height 30 
     460                        caption [F5] From camera visible pixels (+ SHIFT: relative visibility) 
     461                } 
     462                element TextArea(Example/Visibility/Help/FromPointQueryInfo): Example/Visibility/Templates/BasicText 
     463                { 
     464                        left 5 
     465                        top 60 
     466                        width 300 
     467                        height 30 
     468                        caption [F6] From camera visible pixels (+ SHIFT: relative visibility) 
     469                } 
    454470        } 
    455471} 
     
    465481                vert_align top 
    466482                width 600 
    467                 height 120 
     483                height 145 
    468484                left 200 
    469485                top 300 
     
    558574                } 
    559575 
     576 
     577                element TextArea(Example/Visibility/Query/VisiblePatches): Example/Visibility/Templates/BasicText 
     578                { 
     579                        left 5 
     580                        top 75 
     581                        width 90 
     582                        height 30 
     583                        caption Visible patches 
     584                } 
     585                element TextArea(Example/Visibility/Query/VisiblePatchInfo): Example/Visibility/Templates/BasicText 
     586                { 
     587                        left 180 
     588                        top 75 
     589                        width 90 
     590                        height 30 
     591                        caption : 
     592                } 
     593 
    560594                element TextArea(Example/Visibility/Query/NodeVisibility): Example/Visibility/Templates/BasicText 
    561595                { 
    562596                        left 5 
    563                         top 75 
     597                        top 90 
    564598                        width 90 
    565599                        height 30 
     
    570604                { 
    571605                        left 180 
    572                         top 75 
    573                         width 90 
    574                         height 30 
    575                         caption: 
     606                        top 90 
     607                        width 90 
     608                        height 30 
     609                        caption : 
    576610                } 
    577611 
     
    579613                { 
    580614                        left 5 
    581                         top 90 
     615                        top 105 
    582616                        width 90 
    583617                        height 30 
     
    588622                { 
    589623                        left 180 
    590                         top 90 
    591                         width 90 
    592                         height 30 
    593                         caption: 
    594                 } 
     624                        top 105 
     625                        width 90 
     626                        height 30 
     627                        caption : 
     628                } 
     629                element TextArea(Example/Visibility/Query/PatchVisibility): Example/Visibility/Templates/BasicText 
     630                { 
     631                        left 5 
     632                        top 120 
     633                        width 90 
     634                        height 30 
     635                        caption Avg. patch visibility 
     636                } 
     637 
     638                element TextArea(Example/Visibility/Query/PatchVisibilityInfo): Example/Visibility/Templates/BasicText 
     639                { 
     640                        left 180 
     641                        top 120 
     642                        width 90 
     643                        height 30 
     644                        caption : 
     645                } 
     646                         
    595647 
    596648        } 
  • trunk/VUT/Ogre/src/OgreItemBufferQueryManager.cpp

    r158 r159  
    33#include <OgreStringConverter.h> 
    44#include <vector> 
    5  
     5#include <OgreSubEntity.h> 
    66 
    77namespace Ogre { 
    88//-----------------------------------------------------------------------  
    9 ItemBufferQueryManager::ItemBufferQueryManager(PlatformHierarchyInterface *hierarchyInterface, Viewport *vp): 
    10 PlatformQueryManager(hierarchyInterface, vp) 
     9ItemBufferQueryManager::ItemBufferQueryManager(PlatformHierarchyInterface *hierarchyInterface, Viewport *vp, 
     10                                                                                           const bool renderPatches): 
     11PlatformQueryManager(hierarchyInterface, vp), mRenderPatchesForItemBuffer(renderPatches) 
    1112{ 
    1213} 
     
    2122                            InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 
    2223                            InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 
     24                                InfoContainer<GtpVisibility::PatchInfo> *visiblePatches, 
    2325                            bool relativeVisibility) 
    2426{ 
    2527        // initialise item buffer (if not already initialised) 
    26         InitItemBuffer(visibleNodes, visibleGeometry); 
     28        InitItemBuffer(visibleNodes, visibleGeometry, visiblePatches); 
    2729 
    2830        // we need access to the scene manager and the rendersystem 
     
    3234        SceneManager *sm = pfHierarchyInterface->GetSceneManager(); 
    3335 
    34         // ---- Render scene with item buffer (i.e., objects with their id as color codes) 
     36        // --- Render scene with item buffer (i.e., objects with their id as color codes) 
    3537 
    3638        // const_cast allowed because camera is not changed in renderScene 
     
    6163        uchar *buf = mViewport->getTarget()->getBufferContents(dimx, dimy); 
    6264 
     65        int n = mRenderPatchesForItemBuffer ? (int)visiblePatches->size() : (int)visibleGeometry->size(); 
    6366         
    6467        // loop through frame buffer & collect visible pixels 
     
    7174 
    7275                // if valid id <= add visibility (id values start at 1 
    73                 if ((id > 0) && (id < (int)visibleGeometry->size())) 
     76                if ((id > 0) && (id < n)) 
    7477                { 
    75                         ((*visibleGeometry)[id]).AddVisibility(1, 1); 
     78                        if (mRenderPatchesForItemBuffer) 
     79                        { 
     80                                ((*visiblePatches)[id]).AddVisibility(1, 1); 
     81                        } 
     82                        else 
     83                        { 
     84                                ((*visibleGeometry)[id]).AddVisibility(1, 1); 
     85                        } 
    7686                } 
    7787        } 
     
    93103} 
    94104//----------------------------------------------------------------------- 
    95 void ItemBufferQueryManager::InitItemBuffer(InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 
    96                             InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry) 
     105void ItemBufferQueryManager::InitItemBuffer( 
     106                                InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 
     107                            InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 
     108                                InfoContainer<GtpVisibility::PatchInfo> *visiblePatches) 
    97109{ 
    98110        if (mWasInitialised) 
     
    109121        visibleGeometry->clear(); 
    110122        visibleNodes->clear(); 
     123        visiblePatches->clear(); 
    111124 
     125        int id = 0; 
     126 
     127        /* We can either use patches or meshes. If patches are used, an unique id must 
     128           be given each patch. Otherwise the same id must be given to all patches belonging 
     129           to the same mesh. 
     130    */ 
    112131        while (it.hasMoreElements()) 
    113132        { 
    114                 visibleGeometry->push_back(GtpVisibility::MeshInfo(it.getNext(), 0, 0)); 
     133                Entity *ent = it.getNext(); 
     134 
     135                for (int i = 0; i < (int)ent->getNumSubEntities(); ++i) 
     136                { 
     137                        SubEntity *subEnt = ent->getSubEntity(i); 
     138 
     139                        if (mRenderPatchesForItemBuffer) 
     140                        { 
     141                                ++ id; 
     142                                visiblePatches->push_back(GtpVisibility::PatchInfo(subEnt, 0, 0)); 
     143                        } 
     144                                 
     145                        subEnt->setId(id); 
     146                } 
     147                         
     148                if (!mRenderPatchesForItemBuffer) 
     149                { 
     150                        visibleGeometry->push_back(GtpVisibility::MeshInfo(ent, 0, 0)); 
     151                        ++ id; 
     152                } 
    115153        } 
    116154} 
    117155 
     156/* 
     157//----------------------------------------------------------------------- 
     158Entity* VisibilityOctreeSceneManager::createEntity(const String& entityName,  
     159                                                                                                        const String& meshName) 
     160{ 
     161        Entity *ent = SceneManager::createEntity(entityName, meshName); 
     162 
     163        for (int i = 0; i < (int)ent->getNumSubEntities(); ++i) 
     164        { 
     165                ent->getSubEntity(i)->setId(mCurrentEntityId); 
     166        } 
     167 
     168        // increase counter of entity id values 
     169        ++ mCurrentEntityId; 
     170 
     171        return ent; 
     172} 
     173*/ 
    118174} // namespace Ogre 
  • trunk/VUT/Ogre/src/OgreOcclusionQueriesQueryManager.cpp

    r155 r159  
    2121                            InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 
    2222                            InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 
     23                                InfoContainer<GtpVisibility::PatchInfo> *visiblePatches, 
    2324                            bool relativeVisibility) 
    2425{ 
     
    188189                               InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 
    189190                               InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 
     191                                   InfoContainer<GtpVisibility::PatchInfo> *visiblePatches, 
    190192                               bool relativeVisibility) 
    191193{ 
    192         PlatformQueryManager::ComputeFromPointVisibility(point, visibleNodes, visibleGeometry, relativeVisibility); 
     194        PlatformQueryManager::ComputeFromPointVisibility(point, visibleNodes,  
     195                visibleGeometry, visiblePatches, relativeVisibility); 
    193196 
    194197        // --- remove duplicates (duplicates occur if an object is on the edge of the viewport) 
  • trunk/VUT/Ogre/src/OgreOctreeHierarchyInterface.cpp

    r158 r159  
    2626        } 
    2727         
    28         // if not all subtrees are empty 
    29         //if (octree->numNodes() > (int)octree->mNodes.size()) 
     28        //if (octree->numNodes() > (int)octree->mNodes.size()) // if not all subtrees are empty 
    3029        if (!IsLeaf(node)) 
    3130        { 
  • trunk/VUT/Ogre/src/OgrePlatformHierarchyInterface.cpp

    r158 r159  
    200200} 
    201201//----------------------------------------------------------------------- 
    202 GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery(GtpVisibility::Mesh *mesh) 
     202GtpVisibility::OcclusionQuery *PlatformHierarchyInterface::IssueOcclusionQuery( 
     203        GtpVisibility::Mesh *mesh) 
    203204{ 
    204205        // get next available test id 
  • trunk/VUT/Ogre/src/OgrePlatformQueryManager.cpp

    r156 r159  
    2323                               InfoContainer<GtpVisibility::NodeInfo> *visibleNodes, 
    2424                               InfoContainer<GtpVisibility::MeshInfo> *visibleGeometry, 
     25                                   InfoContainer<GtpVisibility::PatchInfo> *visiblePatches, 
    2526                               bool relativeVisibility) 
    2627{ 
    27         SceneManager *sm = dynamic_cast<PlatformHierarchyInterface *>(mHierarchyInterface)->GetSceneManager(); 
     28        SceneManager *sm = dynamic_cast<PlatformHierarchyInterface *> 
     29                (mHierarchyInterface)->GetSceneManager(); 
     30 
     31        // create a camera for the point query 
    2832        Camera *cam = sm->createCamera("PointQueryCam");         
    2933 
     
    6165                } 
    6266 
    63                 ComputeCameraVisibility(*cam, visibleNodes, visibleGeometry, relativeVisibility); 
     67                ComputeCameraVisibility(*cam, visibleNodes, visibleGeometry, visiblePatches, relativeVisibility); 
    6468                 
    65                 mViewport->getTarget()->update(); for(int j=0; j<10000000; j++) printf("wait"); 
     69                //mViewport->getTarget()->update(); for(int j=0; j<10000000; j++)       printf("wait"); 
    6670 
    6771                // permute directions 
  • trunk/VUT/Ogre/src/OgreSceneContentGenerator.cpp

    r130 r159  
    6565{ 
    6666        char name[25]; 
     67 
    6768        sprintf(name, "%s Entity%d", objName.c_str(), GetObjectCount()); 
    6869                 
  • trunk/VUT/Ogre/src/OgreVisibilityOctreeSceneManager.cpp

    r156 r159  
    77#include <OgreLogManager.h> 
    88#include <OgreStringConverter.h> 
     9#include <OgreEntity.h> 
     10#include <OgreSubEntity.h> 
    911 
    1012 
     
    1618:  
    1719mVisibilityManager(visManager),  
    18 mRenderDepthPass(false), 
    1920mShowVisualization(false), 
    2021mRenderNodesForViz(false), 
    2122mRenderNodesContentForViz(false), 
    2223mVisualizeCulledNodes(false), 
     24mLeavePassesInQueue(0), 
    2325mDelayRenderTransparents(true), 
    24 mUseDepthPass(true), 
    25 mSkipTransparents(false) 
     26mUseDepthPass(false), 
     27mRenderDepthPass(false), 
     28mUseItemBuffer(false), 
     29//mUseItemBuffer(true), 
     30mRenderItemBuffer(false), 
     31mCurrentEntityId(1), 
     32mEnableDepthWrite(true), 
     33mSkipTransparents(false), 
     34mSavedShadowTechnique(SHADOWTYPE_NONE), 
     35mRenderTransparentsForItemBuffer(false), 
     36mExecuteVertexProgramForAllPasses(false) 
    2637{ 
    2738        mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); 
     
    3142        //mShowBoxes = true; 
    3243 
    33         // TODO: find reasonable value for max depth 
     44        // TODO: set maxdepth to reasonable value 
    3445        mMaxDepth = 50; 
    3546} 
     
    6576} 
    6677//----------------------------------------------------------------------- 
    67 Pass *VisibilityOctreeSceneManager::setPass(Pass* pass) 
    68 { 
    69         // setting vertex program is not efficient 
    70         Pass *usedPass = ((mRenderDepthPass && pass->getDepthWriteEnabled() &&  
    71                 !pass->hasVertexProgram()) ? mDepthPass : pass);                 
    72  
    73         /* 
    74         // set depth fill pass only if depth write enabled 
    75         Pass *usedPass = (mRenderDepthPass && pass->getDepthWriteEnabled() ? mDepthPass : pass); 
    76  
    77     if (mRenderDepthPass && pass->hasVertexProgram()) 
     78void VisibilityOctreeSceneManager::InitItemBufferPass() 
     79{ 
     80        MaterialPtr itemBufferMat = MaterialManager::getSingleton(). 
     81                getByName("Visibility/ItemBufferPass"); 
     82 
     83        if (itemBufferMat.isNull()) 
    7884    { 
    79                 // set vertex program of current pass to depth pass 
    80                 mDepthPass->setVertexProgram(pass->getVertexProgramName()); 
    81  
    82                 if (mDepthPass->hasVertexProgram()) 
    83                 { 
    84                         const GpuProgramPtr& prg = mDepthPass->getVertexProgram(); 
    85                         // Load this program if not done already 
    86                         if (!prg->isLoaded()) 
    87                                 prg->load(); 
    88                         // Copy params 
    89                         mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters()); 
    90                 } 
    91                 else if (mDepthPass->hasVertexProgram()) 
    92                 { 
    93                         mDepthPass->setVertexProgram(""); 
    94                 } 
    95         }*/ 
    96  
    97         SceneManager::setPass(usedPass); 
    98  
    99         return usedPass; 
     85                // Init 
     86                itemBufferMat = MaterialManager::getSingleton().create("Visibility/ItemBufferPass", 
     87                ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 
     88 
     89                mItemBufferPass = itemBufferMat->getTechnique(0)->getPass(0); 
     90                mItemBufferPass->setColourWriteEnabled(true); 
     91                mItemBufferPass->setDepthWriteEnabled(true); 
     92                mItemBufferPass->setLightingEnabled(true); 
     93                //mItemBufferPass->setLightingEnabled(false); 
     94        } 
     95        else 
     96        { 
     97                mItemBufferPass = itemBufferMat->getTechnique(0)->getPass(0); 
     98        } 
     99        //mItemBufferPass->setAmbient(1, 1, 0); 
    100100} 
    101101//----------------------------------------------------------------------- 
     
    131131                        if (mRenderNodesForViz) 
    132132                        { 
    133                                 getRenderQueue()->addRenderable(*it); 
     133                                if (((*it)->numAttachedObjects() > 0) && ((*it)->numChildren() == 0) 
     134                                        && (*it)->getAttachedObject(0)->getMovableType() == "Entity") 
     135                                getRenderQueue()->addRenderable((*it)); 
     136 
    134137                                // addbounding boxes instead of node itself 
    135138                                //(*it)->_addBoundingBoxToQueue(getRenderQueue()); 
     
    141144                } 
    142145        } 
    143          
     146} 
     147//----------------------------------------------------------------------- 
     148Pass *VisibilityOctreeSceneManager::setPass(Pass* pass) 
     149{ 
     150        // set depth fill pass if we currently do not make an aabb occlusion query 
     151        Pass *usedPass = (mRenderDepthPass && !mHierarchyInterface->IsBoundingBoxQuery() ?  
     152                                          mDepthPass : pass); 
     153 
     154        IlluminationRenderStage savedStage = mIlluminationStage;  
     155         
     156        // set illumination stage to NONE so no shadow material is used  
     157        // for depth pass or for occlusion query 
     158        if (mRenderDepthPass || mHierarchyInterface->IsBoundingBoxQuery()) 
     159        { 
     160                mIlluminationStage = IRS_NONE; 
     161        } 
     162 
     163        //-- set vertex program of current pass in order to set correct depth 
     164        if (mRenderDepthPass && mExecuteVertexProgramForAllPasses && pass->hasVertexProgram()) 
     165    { 
     166                // add vertex program of current pass to depth pass 
     167                mDepthPass->setVertexProgram(pass->getVertexProgramName()); 
     168 
     169                if (mDepthPass->hasVertexProgram()) 
     170                { 
     171                        const GpuProgramPtr& prg = mDepthPass->getVertexProgram(); 
     172                        // Load this program if not done already 
     173                        if (!prg->isLoaded()) 
     174                                prg->load(); 
     175                        // Copy params 
     176                        mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters()); 
     177                } 
     178        } 
     179        else if (mDepthPass->hasVertexProgram()) 
     180        { 
     181                mDepthPass->setVertexProgram(""); 
     182        } 
     183 
     184        // store depth write flag to reset later 
     185        bool IsDepthWrite = usedPass->getDepthWriteEnabled(); 
     186 
     187        // global option which enables / disables depth writes 
     188        if (!mEnableDepthWrite) 
     189        { 
     190                usedPass->setDepthWriteEnabled(false); 
     191        } 
     192        //else if (mIsItemBufferPass) {usedPass = mItemBufferPass;} 
     193 
     194        Pass *result = SceneManager::setPass(usedPass); 
     195 
     196        // reset depth write 
     197        if (!mEnableDepthWrite) 
     198        { 
     199                usedPass->setDepthWriteEnabled(IsDepthWrite); 
     200        } 
     201 
     202        // reset illumination stage 
     203        mIlluminationStage = savedStage; 
     204 
     205        return result; 
    144206} 
    145207//----------------------------------------------------------------------- 
     
    153215        else  
    154216        {        
    155                 mVisible.clear(); 
    156             mBoxes.clear(); 
    157          
    158                 // if there is no depth pass => 
    159                 // we interleave identification and rendering of objects  
    160                 // in _renderVisibibleObjects 
    161  
     217                // for hierarchical culling, we interleave identification  
     218                // and rendering of objects in _renderVisibibleObjects 
     219 
     220                // for the shadow pass we use only standard rendering 
     221                // because of low occlusion 
     222                if (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE &&  
     223                        mIlluminationStage == IRS_RENDER_TO_TEXTURE) 
     224                { 
     225                        OctreeSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
     226                } 
    162227                // only shadow casters will be rendered in shadow texture pass 
    163                 mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 
    164         } 
     228                // mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 
     229        } 
     230         
     231         
     232        // -- delete lists stored for visualization 
     233        mVisible.clear(); 
     234        mBoxes.clear(); 
    165235} 
    166236//----------------------------------------------------------------------- 
    167237void VisibilityOctreeSceneManager::_renderVisibleObjects() 
    168238{ 
    169         // create material for depth pass 
    170         InitDepthPass(); 
    171          
    172         // visualization: apply standard rendering 
    173         if (mShowVisualization) 
     239        // save ambient light to reset later 
     240        ColourValue savedAmbient = mAmbientLight; 
     241 
     242        //-- apply standard rendering for some modes (e.g., visualization, shadow pass) 
     243 
     244        if (mShowVisualization || 
     245           (mShadowTechnique == SHADOWTYPE_TEXTURE_MODULATIVE &&  
     246            mIlluminationStage == IRS_RENDER_TO_TEXTURE)) 
     247        { 
     248                IlluminationRenderStage savedStage = mIlluminationStage;  
     249         
     250                if (mShowVisualization) 
     251                { 
     252                        // disable illumination stage to prevent rendering shadows 
     253                        mIlluminationStage = IRS_NONE; 
     254                } 
     255 
     256                // standard rendering for shadow maps because of performance 
     257                OctreeSceneManager::_renderVisibleObjects(); 
     258 
     259                mIlluminationStage = savedStage; 
     260        } 
     261        else //-- the hierarchical culling algorithm 
    174262        {        
     263                // don't render backgrounds for item buffer 
     264                if (mUseItemBuffer) 
     265                { 
     266                        clearSpecialCaseRenderQueues(); 
     267                        getRenderQueue()->clear(); 
     268                }        
     269 
     270                //-- hierarchical culling 
     271                // the objects of different layers (e.g., background, scene,  
     272                // overlay) must be identified and rendered one after another 
     273 
     274                //-- render all early skies 
     275                clearSpecialCaseRenderQueues(); 
     276                addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND); 
     277                addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY); 
     278                setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 
     279 
    175280                OctreeSceneManager::_renderVisibleObjects(); 
    176                 return; 
    177         }        
    178  
    179         //-- hierarchical culling 
    180         // the objects of different layers (e.g., background, scene,  
    181         // overlay) must be identified and rendered one after another 
    182  
    183         bool leaveTransparentsInQueue = mDelayRenderTransparents && !mUseDepthPass; 
    184  
    185     // -- initialise interface for rendering traversal of the hierarchy 
    186         mHierarchyInterface->SetHierarchyRoot(mOctree); 
    187          
    188         // possible two cameras (one for culling, one for rendering) 
    189         mHierarchyInterface->InitTraversal(mCameraInProgress,  
    190                                                         mCullCamera ? getCamera("CullCamera") : NULL, 
    191                                                         leaveTransparentsInQueue); 
    192                  
    193  
    194         // reset culling manager stats 
    195         mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 
    196          
    197         mSkipTransparents = false; 
    198  
    199         //-- render background, in case there is one 
    200         clearSpecialCaseRenderQueues(); 
    201         addSpecialCaseRenderQueue(RENDER_QUEUE_BACKGROUND); 
    202         addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_EARLY); 
    203         setSpecialCaseRenderQueueMode(SceneManager::SCRQM_INCLUDE); 
    204  
    205         SceneManager::_renderVisibleObjects(); 
    206281 
    207282 
    208283#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    209         _deleteRenderedQueueGroups(); 
     284                // delete previously rendered content 
     285                _deleteRenderedQueueGroups(); 
    210286#endif 
    211287 
    212         //-- render visible objects (i.e., all but overlay) 
    213         clearSpecialCaseRenderQueues(); 
    214         addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE); 
    215         addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY); 
    216         setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 
    217          
    218         // transparents are skipped from hierarchical rendering 
    219         // => they need sorting, thus we render them afterwards 
    220         mSkipTransparents = mDelayRenderTransparents; 
    221  
    222         // set state for depth pass 
    223     mRenderDepthPass = mUseDepthPass; 
    224          
    225         /**  
    226         * the hierarchical culling algorithm 
    227           * for depth pass: will just find objects and update depth buffer 
    228           * for delayed rendering: will render all but transparents 
    229         **/ 
    230          
    231         mVisibilityManager->ApplyVisibilityCulling(); 
    232          
    233         //-- now we can savely render all remaining objects, e.g., transparents, overlay 
    234         mSkipTransparents = false; 
    235  
    236         clearSpecialCaseRenderQueues(); 
    237         SceneManager::_renderVisibleObjects(); 
    238  
    239         // for depth pass: add visible nodes found with the visibility culling 
    240         if (mUseDepthPass) 
    241         { 
    242                 for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 
    243                 { 
    244                         (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 
    245                 } 
     288                //-- prepare queue for visible objects (i.e., all but overlay and skies late) 
     289                clearSpecialCaseRenderQueues(); 
     290                addSpecialCaseRenderQueue(RENDER_QUEUE_SKIES_LATE); 
     291                addSpecialCaseRenderQueue(RENDER_QUEUE_OVERLAY); 
     292                setSpecialCaseRenderQueueMode(SceneManager::SCRQM_EXCLUDE); 
     293         
     294 
     295                // set all necessary parameters for  
     296                // hierarchical visibility culling and rendering 
     297                InitVisibilityCulling(mCameraInProgress); 
     298         
     299                /**  
     300                * the hierarchical culling algorithm 
     301                * for depth pass: we just find objects and update depth buffer 
     302                * for "delayed" rendering: we render some passes afterwards 
     303                * e.g., transparents, because they need front-to-back sorting 
     304                **/ 
     305         
     306                mVisibilityManager->ApplyVisibilityCulling(); 
     307         
     308                // delete remaining renderables from queue (all not in mLeavePassesInQueue) 
     309#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
     310                _deleteRenderedQueueGroups(mLeavePassesInQueue); 
     311#endif 
     312 
     313                //-- reset parameters 
    246314                mRenderDepthPass = false; 
    247     } 
    248         mSkipTransparents = false; 
    249                  
    250         //-- now we can render all remaining queue objects 
    251         // for depth pass: all 
    252         // for delayed rendering: transparents, overlay  
    253         clearSpecialCaseRenderQueues(); 
    254         OctreeSceneManager::_renderVisibleObjects(); 
    255          
    256         WriteLog(); // write out stats 
    257 } 
     315                mRenderItemBuffer = false; 
     316                mSkipTransparents = false; 
     317                mLeavePassesInQueue = 0; 
     318                mShadowTechnique = mSavedShadowTechnique; 
     319 
     320 
     321                // add visible nodes found by the visibility culling algorithm 
     322                if (mUseDepthPass) 
     323                { 
     324                        for (NodeList::iterator it = mVisible.begin(); it != mVisible.end(); ++it) 
     325                        { 
     326                                (*it)->_addToRenderQueue(mCameraInProgress, getRenderQueue(), false); 
     327                        } 
     328                } 
     329         
     330                //-- we render all remaining queue objects 
     331                // used for depth pass, transparents, overlay  
     332                clearSpecialCaseRenderQueues(); 
     333                OctreeSceneManager::_renderVisibleObjects(); 
     334         
     335        }   // hierarchical culling 
     336 
     337        // reset ambient light 
     338        setAmbientLight(savedAmbient); 
     339         
     340        getRenderQueue()->clear(); // finally clear render queue 
     341        //WriteLog(); // write out stats 
     342} 
     343 
    258344//----------------------------------------------------------------------- 
    259345void VisibilityOctreeSceneManager::_updateSceneGraph(Camera* cam) 
     
    312398                return true; 
    313399        } 
     400 
     401        if (key == "DepthWrite") 
     402        { 
     403                mEnableDepthWrite = (*static_cast<const bool *>(val)); 
     404                return true; 
     405        } 
     406        if (key == "UseItemBuffer") 
     407        { 
     408                mUseItemBuffer = (*static_cast<const bool *>(val)); 
     409                return true; 
     410        } 
     411        if (key == "ExecuteVertexProgramForAllPasses") 
     412        {  
     413                mExecuteVertexProgramForAllPasses  = (*static_cast<const bool *>(val)); 
     414                return true; 
     415        } 
     416        if (key == "RenderTransparentsForItemBuffer") 
     417        {  
     418                mRenderTransparentsForItemBuffer  = (*static_cast<const bool *>(val)); 
     419                return true; 
     420        } 
     421 
    314422        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 
    315423                setOption(key, val) || OctreeSceneManager::setOption(key, val); 
     
    372480} 
    373481//----------------------------------------------------------------------- 
    374 void VisibilityOctreeSceneManager::renderObjects(const RenderPriorityGroup::TransparentRenderablePassList& objs,  
     482void VisibilityOctreeSceneManager::renderObjects( 
     483        const RenderPriorityGroup::TransparentRenderablePassList& objs,  
    375484            bool doLightIteration, const LightList* manualLightList) 
    376485{ 
     486        // for correct rendering, transparents must be rendered after hierarchical culling 
    377487        if (!mSkipTransparents) 
    378488        { 
     
    380490        } 
    381491} 
    382  
     492//----------------------------------------------------------------------- 
     493bool VisibilityOctreeSceneManager::validatePassForRendering(Pass* pass) 
     494{ 
     495        // skip all but first pass if we are doing the depth pass 
     496        if ((mRenderDepthPass || mRenderItemBuffer) && pass->getIndex() > 0) 
     497        { 
     498                return false; 
     499        } 
     500        return SceneManager::validatePassForRendering(pass); 
     501} 
     502//----------------------------------------------------------------------- 
     503void VisibilityOctreeSceneManager::renderQueueGroupObjects(RenderQueueGroup* pGroup) 
     504{ 
     505        if (!mRenderItemBuffer) 
     506        { 
     507                OctreeSceneManager::renderQueueGroupObjects(pGroup); 
     508                return; 
     509        } 
     510 
     511        // --- item buffer 
     512 
     513    // Iterate through priorities 
     514    RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator(); 
     515 
     516        while (groupIt.hasMoreElements()) 
     517    { 
     518                RenderItemBuffer(groupIt.getNext()); 
     519        } 
     520} 
     521//----------------------------------------------------------------------- 
     522void VisibilityOctreeSceneManager::RenderItemBuffer(RenderPriorityGroup* pGroup) 
     523{ 
     524        // Do solids 
     525        RenderPriorityGroup::SolidRenderablePassMap solidObjs = pGroup->_getSolidPasses(); 
     526 
     527        // ----- SOLIDS LOOP ----- 
     528        RenderPriorityGroup::SolidRenderablePassMap::const_iterator ipass, ipassend; 
     529        ipassend = solidObjs.end(); 
     530 
     531        for (ipass = solidObjs.begin(); ipass != ipassend; ++ipass) 
     532        { 
     533                // Fast bypass if this group is now empty 
     534                if (ipass->second->empty())  
     535                        continue; 
     536 
     537                // Render only first pass 
     538                if (ipass->first->getIndex() > 0) 
     539                        continue; 
     540 
     541                RenderPriorityGroup::RenderableList* rendList = ipass->second; 
     542                 
     543                RenderPriorityGroup::RenderableList::const_iterator irend, irendend; 
     544                irendend = rendList->end(); 
     545                         
     546                for (irend = rendList->begin(); irend != irendend; ++irend) 
     547                { 
     548                        std::stringstream d; d << "itembuffer, pass name: " <<  
     549                                ipass->first->getParent()->getParent()->getName(); 
     550                                 
     551                        LogManager::getSingleton().logMessage(d.str()); 
     552                         
     553                        RenderSingleObjectForItemBuffer(*irend, ipass->first); 
     554                } 
     555        } 
     556 
     557        // -- TRANSPARENT LOOP: must be handled differently  
     558 
     559        // transparents are treated either as solids or completely discarded 
     560        if (mRenderTransparentsForItemBuffer) 
     561        { 
     562                RenderPriorityGroup::TransparentRenderablePassList transpObjs =  
     563                        pGroup->_getTransparentPasses(); 
     564                RenderPriorityGroup::TransparentRenderablePassList::const_iterator  
     565                        itrans, itransend; 
     566 
     567                itransend = transpObjs.end(); 
     568                for (itrans = transpObjs.begin(); itrans != itransend; ++itrans) 
     569                { 
     570                        // like for solids, render only first pass 
     571                        if (itrans->pass->getIndex() == 0) 
     572                        {        
     573                                RenderSingleObjectForItemBuffer(itrans->renderable, itrans->pass); 
     574                        } 
     575                }  
     576        } 
     577} 
     578//----------------------------------------------------------------------- 
     579void VisibilityOctreeSceneManager::RenderSingleObjectForItemBuffer(Renderable *rend, Pass *pass) 
     580{ 
     581        static LightList nullLightList; 
     582         
     583        int col[4]; 
     584         
     585        // -- create color code out of object id 
     586        col[0] = (rend->getId() >> 16) & 255; 
     587        col[1] = (rend->getId() >> 8) & 255; 
     588        col[2] = rend->getId() & 255; 
     589//      col[3] = 255; 
     590 
     591        //mDestRenderSystem->setColour(col[0], col[1], col[2], col[3]); 
     592     
     593        mItemBufferPass->setAmbient(ColourValue(col[0] / 255.0f, 
     594                                                                                    col[1] / 255.0f,  
     595                                                                                        col[2] / 255.0f, 1)); 
     596 
     597        // set vertex program of current pass 
     598        if (mExecuteVertexProgramForAllPasses && pass->hasVertexProgram()) 
     599        { 
     600                mItemBufferPass->setVertexProgram(pass->getVertexProgramName()); 
     601 
     602                if (mItemBufferPass->hasVertexProgram()) 
     603                { 
     604                        const GpuProgramPtr& prg = mItemBufferPass->getVertexProgram(); 
     605                        // Load this program if not done already 
     606                        if (!prg->isLoaded()) 
     607                                prg->load(); 
     608                        // Copy params 
     609                        mItemBufferPass->setVertexProgramParameters(pass->getVertexProgramParameters()); 
     610                } 
     611        } 
     612        else if (mItemBufferPass->hasVertexProgram()) 
     613        { 
     614                mItemBufferPass->setVertexProgram(""); 
     615        } 
     616 
     617        Pass *usedPass = setPass(mItemBufferPass);  
     618 
     619 
     620        // Render a single object, this will set up auto params if required 
     621        renderSingleObject(rend, usedPass, false, &nullLightList); 
     622} 
     623//----------------------------------------------------------------------- 
     624GtpVisibility::VisibilityManager *VisibilityOctreeSceneManager::GetVisibilityManager() 
     625{ 
     626        return mVisibilityManager; 
     627} 
     628//----------------------------------------------------------------------- 
     629void VisibilityOctreeSceneManager::InitVisibilityCulling(Camera *cam) 
     630{ 
     631        InitDepthPass();          // create material for depth pass 
     632        InitItemBufferPass(); // create material for item buffer pass 
     633 
     634        // reset culling manager stats 
     635        mVisibilityManager->GetCullingManager()->InitFrame(mVisualizeCulledNodes); 
     636 
     637        // save shadow technique. It will be reset after hierarchical culling 
     638        mSavedShadowTechnique = mShadowTechnique; 
     639 
     640        // render standard solids without shadows during hierarchical culling pass 
     641        if ((mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE) || 
     642            (mShadowTechnique == SHADOWTYPE_STENCIL_MODULATIVE)) 
     643        {        
     644                mShadowTechnique = SHADOWTYPE_NONE; 
     645        } 
     646 
     647        // set depth pass flag before rendering 
     648        mRenderDepthPass = mUseDepthPass; 
     649 
     650        // item buffer needs full ambient lighting to use item colors as unique id 
     651        if (mUseItemBuffer)  
     652        { 
     653                mRenderItemBuffer = true; 
     654                setAmbientLight(ColourValue(1,1,1,1)); 
     655        } 
     656 
     657 
     658        // set passes which are stored in render queue  
     659        // for rendering AFTER hierarchical culling, i.e., passes which need  
     660        // a special rendering order 
     661         
     662        mLeavePassesInQueue = 0; 
     663 
     664        if (!mUseDepthPass || !mUseItemBuffer) 
     665        { 
     666                if (mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE) 
     667                { 
     668                        // TODO: remove this pass because it should be processed during hierarchical culling 
     669                        mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_NOSHADOW; 
     670 
     671                        mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_DECAL; 
     672                        mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_DIFFUSE_SPECULAR; 
     673                        mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES; 
     674 
     675                        // just render ambient passes 
     676                        mIlluminationStage = IRS_AMBIENT; 
     677                } 
     678         
     679                if (mShadowTechnique == SHADOWTYPE_STENCIL_MODULATIVE) 
     680                { 
     681                        mLeavePassesInQueue |= RenderPriorityGroup::SOLID_PASSES_NOSHADOW; 
     682                        mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES; 
     683                } 
     684         
     685                // transparents should be rendered after hierarchical culling to  
     686                // provide front-to-back ordering 
     687                if (mDelayRenderTransparents) 
     688                { 
     689                        mLeavePassesInQueue |= RenderPriorityGroup::TRANSPARENT_PASSES; 
     690                } 
     691        } 
     692 
     693        // skip rendering transparents in the hierarchical culling 
     694        // (because they will be rendered afterwards) 
     695        mSkipTransparents = mUseDepthPass ||  
     696                (mLeavePassesInQueue & RenderPriorityGroup::TRANSPARENT_PASSES); 
     697 
     698        // -- initialise interface for rendering traversal of the hierarchy 
     699        mHierarchyInterface->SetHierarchyRoot(mOctree); 
     700         
     701        // possible two cameras (one for culling, one for rendering) 
     702        mHierarchyInterface->InitTraversal(mCameraInProgress,  
     703                                                        mCullCamera ? getCamera("CullCamera") : NULL, 
     704                                                        mLeavePassesInQueue); 
     705                 
     706        //std::stringstream d; d << "leave passes in queue: " << mLeavePassesInQueue;LogManager::getSingleton().logMessage(d.str()); 
     707} 
     708//----------------------------------------------------------------------- 
     709OctreeHierarchyInterface *VisibilityOctreeSceneManager::GetHierarchyInterface() 
     710{ 
     711        return mHierarchyInterface; 
     712} 
     713//----------------------------------------------------------------------- 
     714/*void VisibilityOctreeSceneManager::renderBasicQueueGroupObjects(RenderQueueGroup* pGroup) 
     715{ 
     716    // Basic render loop: Iterate through priorities 
     717    RenderQueueGroup::PriorityMapIterator groupIt = pGroup->getIterator(); 
     718 
     719    while (groupIt.hasMoreElements()) 
     720    { 
     721        RenderPriorityGroup* pPriorityGrp = groupIt.getNext(); 
     722 
     723        // Sort the queue first 
     724        pPriorityGrp->sort(mCameraInProgress); 
     725 
     726                // Do solids 
     727                // TODO: render other solid passes for shadows 
     728        renderObjects(pPriorityGrp->_getSolidPassesNoShadows(), true); 
     729 
     730                // do solid passes no shadows if addititive stencil shadows 
     731                if (mSavedShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE) 
     732                        renderObjects(pPriorityGrp->_getSolidPassesNoShadows(), true); 
     733                 
     734        // Do transparents 
     735        renderObjects(pPriorityGrp->_getTransparentPasses(), true); 
     736 
     737 
     738    }// for each priority 
     739} 
     740*/ 
     741//----------------------------------------------------------------------- 
     742/* 
     743Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName,  
     744                                                                                                        const String& meshName) 
     745{ 
     746        Entity *ent = SceneManager::createEntity(entityName, meshName); 
     747 
     748        for (int i = 0; i < (int)ent->getNumSubEntities(); ++i) 
     749        { 
     750                ent->getSubEntity(i)->setId(mCurrentEntityId); 
     751        } 
     752 
     753        // increase counter of entity id values 
     754        ++ mCurrentEntityId; 
     755 
     756        return ent; 
     757}*/ 
    383758}   // namespace Ogre 
  • trunk/VUT/Ogre/src/OgreVisibilityTerrainSceneManager.cpp

    r158 r159  
    3131mEnableDepthWrite(true), 
    3232mSkipTransparents(false), 
    33 mSavedShadowTechnique(SHADOWTYPE_NONE) 
     33mSavedShadowTechnique(SHADOWTYPE_NONE), 
     34mRenderTransparentsForItemBuffer(false), 
     35mExecuteVertexProgramForAllPasses(false) 
    3436{ 
    3537        mHierarchyInterface = new OctreeHierarchyInterface(this, mDestRenderSystem); 
     
    3739        //mDisplayNodes = true; 
    3840        //mShowBoundingBoxes = true; 
     41        //mShowBoxes = true; 
     42        //mShowBoxes = true; 
    3943 
    4044        // TODO: set maxdepth to reasonable value 
     
    4852        if (depthMat.isNull()) 
    4953    { 
    50                 // Init 
    5154                depthMat = MaterialManager::getSingleton().create( 
    5255                "Visibility/DepthPass", 
    5356                ResourceGroupManager::DEFAULT_RESOURCE_GROUP_NAME); 
     57 
    5458        mDepthPass = depthMat->getTechnique(0)->getPass(0); 
    5559                mDepthPass->setColourWriteEnabled(false); 
     
    6064        { 
    6165                mDepthPass = depthMat->getTechnique(0)->getPass(0); 
     66        } 
     67} 
     68//----------------------------------------------------------------------- 
     69VisibilityTerrainSceneManager::~VisibilityTerrainSceneManager() 
     70{ 
     71        if (mHierarchyInterface) 
     72        { 
     73                delete mHierarchyInterface; 
     74                mHierarchyInterface = NULL; 
    6275        } 
    6376} 
     
    8598        } 
    8699        //mItemBufferPass->setAmbient(1, 1, 0); 
    87 } 
    88 //----------------------------------------------------------------------- 
    89 VisibilityTerrainSceneManager::~VisibilityTerrainSceneManager() 
    90 { 
    91         if (mHierarchyInterface) 
    92         { 
    93                 delete mHierarchyInterface; 
    94                 mHierarchyInterface = NULL; 
    95         } 
    96100} 
    97101//----------------------------------------------------------------------- 
     
    160164        } 
    161165         
    162         if (mRenderDepthPass) 
    163         { 
    164                 // --- set vertex program of current pass so z-buffer is updated correctly 
    165         if (pass->hasVertexProgram()) 
    166                 { 
    167                         mDepthPass->setVertexProgram(pass->getVertexProgramName()); 
    168  
    169                         if (mDepthPass->hasVertexProgram()) 
    170                         { 
    171                                 const GpuProgramPtr& prg = mDepthPass->getVertexProgram(); 
    172                                 // Load this program if not done already 
    173                                 if (!prg->isLoaded()) 
    174                                         prg->load(); 
    175                                 // Copy params 
    176                                 mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters()); 
    177                         } 
    178                 } 
    179                 else if (mDepthPass->hasVertexProgram()) 
    180                 { 
    181                         mDepthPass->setVertexProgram(""); 
    182                 } 
    183         } 
     166        // --- set vertex program of current pass in order to set correct depth 
     167        if (mExecuteVertexProgramForAllPasses && mRenderDepthPass && pass->hasVertexProgram()) 
     168        { 
     169                // add vertex program of current pass to depth pass 
     170                mDepthPass->setVertexProgram(pass->getVertexProgramName()); 
     171 
     172                if (mDepthPass->hasVertexProgram()) 
     173                { 
     174                        const GpuProgramPtr& prg = mDepthPass->getVertexProgram(); 
     175                        // Load this program if not done already 
     176                        if (!prg->isLoaded()) 
     177                                prg->load(); 
     178                        // Copy params 
     179                        mDepthPass->setVertexProgramParameters(pass->getVertexProgramParameters()); 
     180                } 
     181        } 
     182        else if (mDepthPass->hasVertexProgram()) 
     183        { 
     184                mDepthPass->setVertexProgram(""); 
     185        } 
     186         
    184187 
    185188        bool IsDepthWrite = usedPass->getDepthWriteEnabled(); 
     
    228231                // mHierarchyInterface->SetOnlyShadowCasters(onlyShadowCasters); 
    229232        } 
    230         //TerrainSceneManager::_findVisibleObjects(cam, onlyShadowCasters); 
     233         
    231234         
    232235        // -- delete lists stored for visualization 
     
    240243        ColourValue savedAmbient = mAmbientLight; 
    241244 
    242         // --- apply standard rendering for some cases (e.g., visualization, shadow pass) 
     245        //-- apply standard rendering for some modes (e.g., visualization, shadow pass) 
    243246 
    244247        if (mShowVisualization || 
     
    257260                mIlluminationStage = savedStage; 
    258261        } 
    259         else // -- the hierarchical culling algorithm 
     262        else //-- the hierarchical culling algorithm 
    260263        { 
    261264                // don't render backgrounds for item buffer 
     
    266269                } 
    267270 
     271                //-- hierarchical culling 
    268272                // the objects of different layers (e.g., background, scene,  
    269273                // overlay) must be identified and rendered one after another 
     
    279283 
    280284#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    281                 // delete previously rendered contenbt 
     285                // delete previously rendered content 
    282286                _deleteRenderedQueueGroups(); 
    283287#endif 
     
    296300                /**  
    297301                * the hierarchical culling algorithm 
    298                 * if we use a depth pass: will just find objects and update depth buffer 
    299                 * for "delayed" rendering: will render some passes afterwards, e.g., transparents 
     302                * for depth pass: we just find objects and update depth buffer 
     303                * for "delayed" rendering: we render some passes afterwards 
     304                * e.g., transparents, because they need front-to-back sorting 
    300305                **/ 
    301306                 
     
    325330                 
    326331                //-- now we can render all remaining queue objects 
    327                 // for depth pass, transparents, overlay  
     332                // used for depth pass, transparents, overlay  
    328333                clearSpecialCaseRenderQueues(); 
    329334                TerrainSceneManager::_renderVisibleObjects(); 
    330335        } 
    331336                 
    332         // set the new render level index afterwards => new level in the next frame  
    333         int levelIdx = TerrainRenderable::getCurrentRenderLevelIndex() + 1; 
    334         TerrainRenderable::setCurrentRenderLevelIndex(levelIdx); 
    335  
     337        // set the new render level index  
     338        TerrainRenderable::NextRenderLevelIndex(); 
     339         
    336340        // reset ambient light 
    337341        setAmbientLight(savedAmbient); 
    338342 
    339         getRenderQueue()->clear(); 
     343        getRenderQueue()->clear(); // finally clear render queue 
    340344        //WriteLog(); // write out stats 
    341345} 
     
    397401                return true; 
    398402        } 
    399         // notifiy that frame has ended so terrain render level can be reset for correct 
    400         // terrain rendering 
    401         if (key == "TerrainLevelIdx") 
    402         { 
    403                 TerrainRenderable::setCurrentRenderLevelIndex((*static_cast<const int *>(val))); 
    404                 return true; 
    405         } 
     403 
    406404        if (key == "DepthWrite") 
    407405        { 
     
    414412                return true; 
    415413        } 
    416          
     414        if (key == "ExecuteVertexProgramForAllPasses") 
     415        {  
     416                mExecuteVertexProgramForAllPasses  = (*static_cast<const bool *>(val)); 
     417                return true; 
     418        } 
     419        if (key == "RenderTransparentsForItemBuffer") 
     420        {  
     421                mRenderTransparentsForItemBuffer  = (*static_cast<const bool *>(val)); 
     422                return true; 
     423        } 
     424 
    417425        return VisibilityOptionsManager(mVisibilityManager, mHierarchyInterface). 
    418426                setOption(key, val) || TerrainSceneManager::setOption(key, val); 
     
    547555        } 
    548556 
    549         // ----- TRANSPARENT LOOP: must be handled differently  
    550         // TODO: HOW TO HANDLE OCCLUDED OBJECTS ???? 
    551         RenderPriorityGroup::TransparentRenderablePassList 
    552                 transpObjs = pGroup->_getTransparentPasses(); 
    553         RenderPriorityGroup::TransparentRenderablePassList::const_iterator itrans, itransend; 
    554  
    555         itransend = transpObjs.end(); 
    556         for (itrans = transpObjs.begin(); itrans != itransend; ++itrans) 
    557         { 
    558                 // like for solids, render only first pass 
    559                 if (itrans->pass->getIndex() == 0) 
    560                 {        
    561                         RenderSingleObjectForItemBuffer(itrans->renderable, itrans->pass); 
    562                 } 
    563         }  
     557        // -- TRANSPARENT LOOP: must be handled differently  
     558 
     559        // transparents are treated either as solids or completely discarded 
     560        if (mRenderTransparentsForItemBuffer) 
     561        { 
     562                RenderPriorityGroup::TransparentRenderablePassList transpObjs =  
     563                        pGroup->_getTransparentPasses(); 
     564                RenderPriorityGroup::TransparentRenderablePassList::const_iterator  
     565                        itrans, itransend; 
     566 
     567                itransend = transpObjs.end(); 
     568                for (itrans = transpObjs.begin(); itrans != itransend; ++itrans) 
     569                { 
     570                        // like for solids, render only first pass 
     571                        if (itrans->pass->getIndex() == 0) 
     572                        {        
     573                                RenderSingleObjectForItemBuffer(itrans->renderable, itrans->pass); 
     574                        } 
     575                } 
     576        } 
    564577} 
    565578//----------------------------------------------------------------------- 
     
    583596 
    584597        // set vertex program of current pass 
    585         if (pass->hasVertexProgram()) 
     598        if (mExecuteVertexProgramForAllPasses && pass->hasVertexProgram()) 
    586599        { 
    587600                mItemBufferPass->setVertexProgram(pass->getVertexProgramName()); 
     
    614627} 
    615628//----------------------------------------------------------------------- 
    616 Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName,  
    617                                                                                                         const String& meshName) 
    618 { 
    619         Entity *ent = SceneManager::createEntity(entityName, meshName); 
    620  
    621         for (int i = 0; i < (int)ent->getNumSubEntities(); ++i) 
    622         { 
    623                 ent->getSubEntity(i)->setId(mCurrentEntityId); 
    624         } 
    625  
    626         // increase counter of entity id values 
    627         ++ mCurrentEntityId; 
    628  
    629         return ent; 
    630 } 
    631 //----------------------------------------------------------------------- 
    632629void VisibilityTerrainSceneManager::InitVisibilityCulling(Camera *cam) 
    633630{ 
     
    644641        if ((mShadowTechnique == SHADOWTYPE_STENCIL_ADDITIVE) || 
    645642            (mShadowTechnique == SHADOWTYPE_STENCIL_MODULATIVE)) 
    646         { 
    647          
     643        {        
    648644                mShadowTechnique = SHADOWTYPE_NONE; 
    649645        } 
     
    660656 
    661657 
    662         // set passes which should be stored in render queue  
     658        // set passes which are stored in render queue  
    663659        // for rendering AFTER hierarchical culling, i.e., passes which need  
    664660        // a special rendering order 
     
    715711} 
    716712//----------------------------------------------------------------------- 
     713void VisibilityTerrainSceneManager::endFrame() 
     714{ 
     715        TerrainRenderable::ResetRenderLevelIndex(); 
     716} 
     717//----------------------------------------------------------------------- 
    717718/*void VisibilityTerrainSceneManager::renderBasicQueueGroupObjects(RenderQueueGroup* pGroup) 
    718719{ 
     
    742743} 
    743744*/ 
     745//----------------------------------------------------------------------- 
     746/* 
     747Entity* VisibilityTerrainSceneManager::createEntity(const String& entityName,  
     748                                                                                                        const String& meshName) 
     749{ 
     750        Entity *ent = SceneManager::createEntity(entityName, meshName); 
     751 
     752        for (int i = 0; i < (int)ent->getNumSubEntities(); ++i) 
     753        { 
     754                ent->getSubEntity(i)->setId(mCurrentEntityId); 
     755        } 
     756 
     757        // increase counter of entity id values 
     758        ++ mCurrentEntityId; 
     759 
     760        return ent; 
     761} 
     762*/ 
    744763} // namespace Ogre 
  • trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.cpp

    r158 r159  
    103103mVisibilityManager(NULL), 
    104104mDelayedQueriesIssued(0.0), 
    105 mDelayedTraversedNodes(0.0) 
     105mDelayedTraversedNodes(0.0), 
     106mUseItemBuffer(false), 
     107mRenderPatchesForItemBuffer(false) 
    106108{ 
    107109        //mInputDevice = PlatformManager::getSingleton().createInputReader(); 
     
    162164        //-- visibility query stats overlay 
    163165        mQueryTypeInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/QueryTypeInfo"); 
     166         
    164167        mQueryVisibleNodesInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/VisibleNodesInfo"); 
    165168    mQueryVisibleGeometryInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/VisibleGeometryInfo"); 
     169        mQueryVisiblePatchInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/VisiblePatchInfo"); 
     170         
    166171        mQueryNodeVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/NodeVisibilityInfo"); 
    167172        mQueryGeometryVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/GeometryVisibilityInfo"); 
     173        mQueryPatchVisibilityInfo = OverlayManager::getSingleton().getOverlayElement("Example/Visibility/Query/PatchVisibilityInfo"); 
    168174 
    169175        // show stats overlays 
     
    294300 
    295301        //-- IMPORTANT: must be set, otherwise terrain is not rendered correctly 
    296         int terrainLevelIdx = 0; 
    297         mSceneMgr->setOption("TerrainLevelIdx", &terrainLevelIdx); 
     302        mSceneMgr->endFrame(); 
    298303 
    299304        //-- setup what is needed for immediate mouse/key movement 
     
    392397        { 
    393398                mQueryManager = new ItemBufferQueryManager(sm->GetHierarchyInterface(),  
    394                         mWindow->getViewport(0)); 
     399                        mWindow->getViewport(0), mRenderPatchesForItemBuffer); 
    395400        } 
    396401        else 
     
    404409        InfoContainer<GtpVisibility::NodeInfo> visibleNodes; 
    405410        InfoContainer<GtpVisibility::MeshInfo> visibleGeometry; 
     411        InfoContainer<GtpVisibility::PatchInfo> visiblePatches; 
    406412 
    407413        if (fromPoint) 
     
    409415                mQueryManager-> 
    410416                        ComputeFromPointVisibility(mCamNode->getPosition(), &visibleNodes,  
    411                                                                            &visibleGeometry, relativeVisibility); 
     417                                                                           &visibleGeometry, &visiblePatches, relativeVisibility); 
    412418        } 
    413419        else 
    414420        { 
    415421                mQueryManager->ComputeCameraVisibility(*mCamera, 
    416                             &visibleNodes, &visibleGeometry, relativeVisibility); 
    417         } 
    418  
    419         float averageNodeVis = 0; 
    420         float averageGeometryVis = 0; 
    421         int geomSize = 0; 
    422         int nodesSize = 0; 
     422                            &visibleNodes, &visibleGeometry, &visiblePatches, relativeVisibility); 
     423        } 
     424 
     425        float averageNodeVis = 0, averageGeometryVis = 0, averagePatchVis = 0; 
     426        int geomSize = 0, nodesSize = 0, patchSize = 0; 
    423427 
    424428        InfoContainer<GtpVisibility::MeshInfo>::iterator geomIt, geomIt_end = visibleGeometry.end(); 
     
    458462        } 
    459463 
     464        InfoContainer<GtpVisibility::PatchInfo>::iterator patchIt, patchIt_end = visiblePatches.end(); 
     465 
     466        for (patchIt = visiblePatches.begin(); patchIt != patchIt_end; ++patchIt) 
     467        { 
     468                // add if not 0 
     469                if ((*patchIt).GetVisiblePixels()) 
     470                { 
     471                        float vis = relativeVisibility ?  
     472                                (*patchIt).ComputeRelativeVisibility() : (float)(*patchIt).GetVisiblePixels(); 
     473                 
     474                        averagePatchVis += vis; 
     475                        ++patchSize; 
     476 
     477                        std::stringstream d; d << "Patch visibility: " << vis; 
     478                        LogManager::getSingleton().logMessage(d.str()); 
     479                }        
     480        } 
     481 
    460482        if (nodesSize) 
    461483                averageNodeVis /= (float)nodesSize; 
    462484        if (geomSize) 
    463485                averageGeometryVis /= (float)geomSize; 
     486        if (patchSize) 
     487                averagePatchVis /= (float)patchSize; 
    464488 
    465489        //-- update visibility queries stats 
     
    481505                mQueryVisibleGeometryInfo->setCaption(str); 
    482506                 
     507                sprintf(str,": %d", (int)patchSize);  
     508                mQueryVisiblePatchInfo->setCaption(str); 
     509 
    483510                sprintf(str,": %3.3f", averageNodeVis);  
    484511                mQueryNodeVisibilityInfo->setCaption(str); 
     
    486513                sprintf(str,": %3.3f", averageGeometryVis);  
    487514                mQueryGeometryVisibilityInfo->setCaption(str); 
     515 
     516                sprintf(str,": %3.3f", averagePatchVis);  
     517                mQueryPatchVisibilityInfo->setCaption(str); 
    488518        } 
    489519        catch (...) 
     
    909939                break; 
    910940         
    911         case KC_F: 
     941    case KC_F: 
    912942                nextFilter(); 
    913943                break; 
     
    929959        case KC_S: 
    930960                toggleShowShadows(); 
     961                break; 
     962 
     963        case KC_I: 
     964                mUseItemBuffer = !mUseItemBuffer; 
     965                break; 
     966 
     967        case KC_C: 
     968                mRenderPatchesForItemBuffer = !mRenderPatchesForItemBuffer; 
    931969                break; 
    932970 
     
    959997                break; 
    960998        case KC_F5: 
    961                 ApplyVisibilityQuery(false, mShiftPressed, false); 
     999                ApplyVisibilityQuery(false, mShiftPressed, mUseItemBuffer); 
    9621000                break; 
    9631001        case KC_F6: 
    964                 ApplyVisibilityQuery(true, mShiftPressed, false); 
    965                 break; 
    966         case KC_F7: 
    967                 ApplyVisibilityQuery(false, mShiftPressed, true); 
    968                 break; 
    969         case KC_F8: 
    970                 ApplyVisibilityQuery(true, mShiftPressed, true); 
    971                 break; 
     1002                ApplyVisibilityQuery(true, mShiftPressed, mUseItemBuffer); 
     1003                break; 
     1004         
    9721005        case KC_F11: 
    9731006                takeScreenShot(); 
  • trunk/VUT/work/TestCullingTerrain/TerrainFrameListener.h

    r155 r159  
    169169        OverlayElement *mQueryTypeInfo; 
    170170        OverlayElement *mQueryVisibleNodesInfo; 
    171     OverlayElement *mQueryVisibleGeometryInfo; 
     171        OverlayElement *mQueryVisibleGeometryInfo; 
     172        OverlayElement *mQueryVisiblePatchInfo; 
     173 
    172174        OverlayElement *mQueryVisiblityInfo; 
    173175        OverlayElement *mQueryNodeVisibilityInfo; 
    174176        OverlayElement *mQueryGeometryVisibilityInfo; 
     177        OverlayElement *mQueryPatchVisibilityInfo; 
    175178 
    176179        RayQueryExecutor *mRayQueryExecutor; 
     
    190193        bool mShutdownRequested; 
    191194        bool mDisplayCameraDetails; 
    192          
     195        bool mUseItemBuffer; 
     196 
    193197        Real mVizCameraHeight; 
    194198 
     
    236240        unsigned long mAvgFps; 
    237241        unsigned long mFrameCount; 
     242 
    238243        //bool mUseBufferedInputKeys, mUseBufferedInputMouse, mInputTypeSwitchingOn; 
    239244        PlatformQueryManager *mQueryManager; 
     
    241246        float mDelayedQueriesIssued; 
    242247        float mDelayedTraversedNodes; 
     248 
     249        bool mRenderPatchesForItemBuffer; 
    243250}; 
    244251 
  • trunk/VUT/work/TestCullingTerrain/TestCullingTerrainApplication.cpp

    r156 r159  
    127127        setupGui(); 
    128128 
    129         // Floor plane 
    130         /* 
     129         
     130        /* // occluder plane to test visibility 
    131131        Plane plane; 
    132132        plane.normal = Vector3::UNIT_Y; 
     
    138138        pPlaneEnt->setMaterialName("Examples/Rockwall"); 
    139139        pPlaneEnt->setCastShadows(true); 
    140         mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt); 
    141         */ 
     140        mSceneMgr->getRootSceneNode()->createChildSceneNode()->attachObject(pPlaneEnt); */ 
     141 
    142142        mSceneMgr->setShadowTextureSettings(1024, 2); 
    143143        mSceneMgr->setShadowColour(ColourValue(0.5, 0.5, 0.5)); 
    144     //mSceneMgr->setShowDebugShadows(true); 
    145  
     144    
    146145 
    147146        //-- terrain content setup 
  • trunk/VUT/work/ogre_changes/OgreMain/include/OgreSceneManager.h

    r139 r159  
    156156                 
    157157                /** Renders an Ogre MovableObject. 
     158                        @param mov the movable object to be rendered 
     159                        @param leavePassesInQueue flag determining the passes which are left 
     160                        in render queue after rendering 
    158161                */ 
    159162                void _renderMovableObject(MovableObject *mov, const int leavePassesInQueue); 
    160163 
     164                /** Tells the scene manager that the frame ends (i.e., 
     165                        one frame in the main loop. 
     166                */ 
     167                virtual void endFrame() {}; 
    161168#endif // GTP_VISIBILITY_MODIFIED_OGRE 
    162169 
  • trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/include/OgreTerrainRenderable.h

    r154 r159  
    299299 
    300300#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    301                 // index of renderlevel used for current pass 
    302                 static int getCurrentRenderLevelIndex(); 
    303                 // returns index of renderlevel 
    304                 static void setCurrentRenderLevelIndex(int index); 
     301                // resets index of renderlevel used for current pass 
     302                static void ResetRenderLevelIndex(); 
     303                // next index of renderlevel 
     304                static void NextRenderLevelIndex(); 
    305305#endif // GTP_VISIBILITY_MODIFIED_OGRE 
    306306 
  • trunk/VUT/work/ogre_changes/Plugins/OctreeSceneManager/src/OgreTerrainRenderable.cpp

    r154 r159  
    15011501#ifdef GTP_VISIBILITY_MODIFIED_OGRE 
    15021502        //----------------------------------------------------------------------- 
    1503         int TerrainRenderable::getCurrentRenderLevelIndex()  
     1503        void TerrainRenderable::ResetRenderLevelIndex()  
    15041504        { 
    1505                 return msCurrentRenderLevelIndex; 
     1505                msCurrentRenderLevelIndex = 0; 
    15061506        } 
    15071507        //----------------------------------------------------------------------- 
    1508         void TerrainRenderable::setCurrentRenderLevelIndex(int index) 
     1508        void TerrainRenderable::NextRenderLevelIndex() 
    15091509        { 
    1510                 if (index > MAX_RENDERLEVEL_INDEX) 
    1511                         index = 0; 
    1512  
    1513                 msCurrentRenderLevelIndex = index; 
     1510                if ((++ msCurrentRenderLevelIndex) > MAX_RENDERLEVEL_INDEX) 
     1511                        msCurrentRenderLevelIndex = 0; 
    15141512        } 
    15151513#endif // GTP_VISIBILITY_MODIFIED_OGRE 
Note: See TracChangeset for help on using the changeset viewer.