Ignore:
Timestamp:
01/08/09 01:10:53 (15 years ago)
Author:
mattausch
Message:

worked on new method

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
2 added
8 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/CHCPlusPlusTraverser.cpp

    r3251 r3258  
    119119                        mDistanceQueue.pop(); 
    120120         
    121                         if (1 && !IsNodeVisible(node, 10)) 
     121                        if (1 && !IsNodeGeometryVisible(node, 10)) 
    122122                        { 
    123123                                node->SetVisible(false); 
     
    261261                        newPBatch = 0; 
    262262                else 
    263                 newPBatch *= mVisibilityPredictor.GetProbability(node); 
     263                        newPBatch *= mVisibilityPredictor.GetProbability(node); 
    264264 
    265265                if (query->GetNodes().empty()) 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/FrustumCullingTraverser.cpp

    r3251 r3258  
    11#include "FrustumCullingTraverser.h" 
    2 #include "SceneEntity.h" 
    32 
    43 
     
    1817                mDistanceQueue.pop(); 
    1918         
    20                 if (1 && !IsNodeVisible(node, 10)) 
     19                if (1 && !IsNodeGeometryVisible(node, 10)) 
    2120                { 
    2221                        node->SetVisible(false); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/OcclusionQuery.h

    r2782 r3258  
    2424 
    2525        virtual ~OcclusionQuery(); 
    26  
     26        /** Returns true if the query result is available. 
     27        */ 
    2728        bool ResultAvailable() const; 
    28          
     29        /** Returns number of visible pixels. 
     30        */ 
    2931        unsigned int GetQueryResult() const; 
    30          
     32        /** Starts the query. Everything drawn inbetween start and end is 
     33                queried. 
     34        */ 
    3135        void BeginQuery() const; 
    32          
     36        /** Ends the query. 
     37        */ 
    3338        void EndQuery() const; 
    34          
     39        /** Returns id of this query. 
     40        */ 
    3541        unsigned int GetQueryId() const; 
    3642        /** Returns the first node of the multiquery 
    3743        */ 
    3844        inline BvhNode *GetFrontNode() const { return mNodes[0]; } 
     45        /** Returns nodes by reference 
     46        */ 
    3947        inline const BvhNodeContainer &GetNodes() const { return mNodes; } 
    40  
    4148        /** Reset the list of nodes associated with this query. 
    4249        */ 
     
    4754        /** Returns the size of the multiquery. 
    4855        */ 
    49         inline int GetSize() const { return (int)mNodes.size();} 
    50          
     56        inline int GetSize() const { return (int)mNodes.size(); } 
     57 
     58        inline bool IsEmpty() const { return GetSize() == 0; } 
     59 
    5160 
    5261protected: 
    53  
     62        /** Constructor taking an already allocated query id. 
     63        */ 
    5464        OcclusionQuery(unsigned int id): mQueryId(id) { } 
    5565 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.cpp

    r3251 r3258  
    55#include "RenderState.h" 
    66#include "Geometry.h" 
     7#include "RenderQueue.h" 
    78#include "Timer/PerfTimer.h" 
    89 
     
    292293 
    293294 
    294 bool RenderTraverser::IsNodeVisible(BvhNode *node, int maxSize) 
     295bool RenderTraverser::IsNodeGeometryVisible(BvhNode *node, int maxSize) 
    295296{ 
    296297        // no invisible objects 
     
    300301        SceneEntity **entities = mBvh->GetGeometry(node, geometrySize); 
    301302 
    302         if (geometrySize > maxSize) return true; 
     303        if ((maxSize != -1) && (geometrySize > maxSize)) return true; 
    303304 
    304305        for (int i = 0; i < geometrySize; ++ i) 
     
    311312 
    312313 
    313 } 
     314void RenderTraverser::SetCamera(Camera *cam) 
     315{ 
     316        mCamera = cam; 
     317} 
     318 
     319 
     320void RenderTraverser::SetRenderQueue(RenderQueue *rq) 
     321{ 
     322        mRenderQueue = rq; 
     323} 
     324 
     325 
     326const TraversalStatistics &RenderTraverser::GetStats() const  
     327{ 
     328        return mStats;  
     329} 
     330 
     331 
     332const SceneEntityContainer &RenderTraverser::GetVisibleObjects() const  
     333{ 
     334        return mVisibleObjects;  
     335} 
     336 
     337 
     338float RenderTraverser::GetMaxVisibleDistance() const  
     339{  
     340        return mMaxVisibleDistance;  
     341} 
     342 
     343 
     344Camera *RenderTraverser::GetCamera() const 
     345{ 
     346        return mCamera;  
     347} 
     348 
     349 
     350 
     351} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderTraverser.h

    r3251 r3258  
    22#define __RENDERTRAVERSER_H 
    33 
    4 #include <queue> 
     4 
    55#include "Bvh.h" 
    66#include "OcclusionQuery.h" 
    7 #include "Camera.h" 
    8 #include "RenderQueue.h" 
    9 #include "Timer/PerfTimer.h" 
    10  
     7//#include "Timer/PerfTimer.h" 
     8#include <queue> 
    119 
    1210 
     
    1412{ 
    1513 
     14 
    1615class Camera; 
    17 class Matrix4x4; 
    18  
     16class RenderQueue; 
    1917 
    2018 
     
    5351 
    5452        /// types of traversers 
    55         enum {CULL_FRUSTUM, STOP_AND_WAIT, CHC, CHCPLUSPLUS, NUM_TRAVERSAL_TYPES}; 
     53        enum {CULL_FRUSTUM, 
     54                  STOP_AND_WAIT,  
     55                  CHC, CHCPLUSPLUS,  
     56                  CULL_COLLECTOR, 
     57                  NUM_TRAVERSAL_TYPES}; 
    5658 
    5759        /** Default constructor. 
    5860        */ 
    5961        RenderTraverser(); 
    60         /** Virtual constructor, has to be redefined in subclasses 
     62        /** Virtual constructor, has to be redefined in subclasses. 
    6163        */ 
    6264        virtual ~RenderTraverser(); 
    63         /** Abstract method that traverses and renders the scene 
     65        /** Maim method that traverses and renders the scene. 
    6466        */ 
    6567        void RenderScene(); 
     
    7880        /** Sets the camera. 
    7981        */ 
    80         void SetCamera(Camera *cam) { mCamera = cam;} 
     82        void SetCamera(Camera *cam); 
    8183        /** Sets the render queue. 
    8284        */ 
    83         void SetRenderQueue(RenderQueue *rq) {mRenderQueue =rq;} 
    84         /** Sets the current render state 
     85        void SetRenderQueue(RenderQueue *rq); 
     86        /** Sets the current render state. 
    8587        */ 
    8688        void SetRenderState(RenderState *state); 
    8789        /** The traversal statistics 
    8890        */ 
    89         const TraversalStatistics &GetStats() const { return mStats; } 
     91        const TraversalStatistics &GetStats() const; 
    9092        /** The current frame id 
    9193        */ 
    92         int GetCurrentFrameId() const { return mFrameId; } 
     94        inline int GetCurrentFrameId() const; 
    9395         
     96 
     97 
    9498        ////////////////// 
    95         //-- options for the different rendering algorithms 
     99        //-- methods that concern one or more of the implemented rendering algorithms 
    96100 
    97101        /** If a render queue should be used to batch up and sort scene entities before 
     
    107111        void SetVisibilityThreshold(int threshold); 
    108112 
     113 
    109114        /////////////////// 
    110115        //-- CHC / CHC ++ related options 
     116        //-- note: could be implemented more cleanly in a CoherentOcclusionCullingTraverser parent class! 
    111117 
    112118        /** CHC optimization to query the geometry itself instead of the bounding box. 
     
    131137            (only if StoreVisibleObjects is set) 
    132138        */ 
    133         const SceneEntityContainer &GetVisibleObjects() const { return mVisibleObjects; } 
     139        const SceneEntityContainer &GetVisibleObjects() const; 
    134140        /** Returns the current camera. 
    135141        */ 
    136         Camera *GetCamera() const { return mCamera; } 
     142        Camera *GetCamera() const; 
    137143        /** Returns the maximal visible distance encountered in the scene.  
    138144            Useful for e.g., shadow map focussing 
    139145        */ 
    140         float GetMaxVisibleDistance() const { return mMaxVisibleDistance; } 
    141         /** Render also dynamic objects. 
     146        float GetMaxVisibleDistance() const; 
     147        /** Render objects declared as dynamic (non-static) 
    142148        */ 
    143149        void SetRenderDynamicObjects(bool dynamic); 
     
    168174        */ 
    169175        void ApplyRenderQueue(); 
    170  
    171         bool IsNodeVisible(BvhNode *node, int maxSize); 
     176        /** Returns true if at least one of the objects in this node are  
     177                marked as visible. maxSize describes the maximum sized node  
     178                (in # of objects) that is tested. if maxSize is -1, all nodes are tested. 
     179        */ 
     180        bool IsNodeGeometryVisible(BvhNode *node, int maxSize); 
    172181 
    173182 
     
    189198        /// the statisitcs 
    190199        TraversalStatistics mStats; 
    191          
     200        /// the render queue 
    192201        RenderQueue *mRenderQueue; 
    193  
    194202        /// the objects found visible in current frame 
    195203        SceneEntityContainer mVisibleObjects; 
     
    197205        float mMaxVisibleDistance; 
    198206 
     207 
    199208        ///////////////// 
    200209        //-- algorithm parameters 
     
    222231 
    223232 
     233inline int RenderTraverser::GetCurrentFrameId() const  
     234{  
     235        return mFrameId;  
    224236} 
    225237 
    226238 
     239} 
     240 
     241 
    227242 
    228243#endif // RENDERTRAVERSER_H 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp

    r3233 r3258  
    77#include "Polyhedron.h" 
    88#include "ResourceManager.h" 
     9#include "Camera.h" 
    910 
    1011#include <IL/il.h> 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.cpp

    r3257 r3258  
    155155                        entities = bvh->GetGeometry(node, geometrySize); 
    156156 
    157                         //if (node->IsLeaf() && (geometrySize != 1)) 
    158                         //if (geometrySize != 1) cout << "Error!! " << geometrySize << endl; 
    159157                        for (int k = 0; k < geometrySize; ++ k) 
    160158                        { 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3257 r3258  
    6060#include "VisibilitySolutionLoader.h" 
    6161#include "ViewCellsTree.h" 
     62#include "PvsCollectionRenderer.h" 
    6263 
    6364 
     
    894895                tr = new CHCPlusPlusTraverser(); 
    895896                break; 
    896          
     897        case RenderTraverser::CULL_COLLECTOR: 
     898                tr = new PvsCollectionRenderer(); 
     899                break; 
    897900        default: 
    898901                tr = new FrustumCullingTraverser(); 
     
    12781281        else 
    12791282        { 
     1283                if (traverser->GetType() == RenderTraverser::CULL_COLLECTOR) 
     1284                        ((PvsCollectionRenderer *)traverser)->SetViewCell(usePvs ? viewCell : NULL); 
     1285 
    12801286                // actually render the scene geometry using the specified algorithm 
    12811287                traverser->RenderScene(); 
     
    14231429        case 32: // space 
    14241430                renderMode = (renderMode + 1) % RenderTraverser::NUM_TRAVERSAL_TYPES; 
     1431                //renderMode = (renderMode + 1) % 4; 
    14251432 
    14261433                DEL_PTR(traverser); 
     
    23122319 
    23132320                glColor3f(1.0f, 1.0f, 1.0f); 
    2314                 static char *alg_str[] = {"Frustum Cull", "Stop and Wait", "CHC", "CHC ++"}; 
     2321                static char *alg_str[] = { 
     2322                        "Frustum Cull" 
     2323                        , "Stop and Wait" 
     2324                        , "CHC" 
     2325                        , "CHC ++" 
     2326                        , "Collector" 
     2327                }; 
    23152328                 
    23162329                if (!showAlgorithmTime) 
     
    23932406                renderQueue->Enqueue(*sit); 
    23942407        } 
     2408 
    23952409        /// now render out everything in one giant pass 
    23962410        renderQueue->Apply(); 
     
    24072421{ 
    24082422        if (!sceneQuery) 
     2423        { 
    24092424                sceneQuery = new SceneQuery(bvh->GetBox(), traverser, &renderState); 
     2425        } 
    24102426 
    24112427        return sceneQuery; 
Note: See TracChangeset for help on using the changeset viewer.