Changeset 3243


Ignore:
Timestamp:
01/02/09 23:07:07 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
13 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj

    r3242 r3243  
    651651                                </File> 
    652652                                <File 
    653                                         RelativePath=".\src\Pvs.cpp" 
    654                                         > 
    655                                 </File> 
    656                                 <File 
    657653                                        RelativePath=".\src\RenderQueue.cpp" 
    658654                                        > 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp

    r3242 r3243  
    55#include <iostream> 
    66#include <queue> 
     7#include <stack> 
    78 
    89 
     
    416417        { 
    417418                // no face normals? => create normals 
    418                 const CHCDemoEngine::Triangle3 tri(vertices[i + 0], 
    419                                                        vertices[i + 1], 
    420                                                                                    vertices[i + 2]); 
     419                const CHCDemoEngine::Triangle3  
     420                        tri(vertices[i], vertices[i + 1], vertices[i + 2]); 
    421421 
    422422                const CHCDemoEngine::Vector3 n = tri.GetNormal(); 
     
    498498        ogzstream ofile(filename.c_str()); 
    499499 
    500         if (!ofile.is_open()) 
    501                 return false; 
    502          
    503  
     500        if (!ofile.is_open()) return false; 
     501         
    504502        int textureCount = 0; 
    505503        ofile.write(reinterpret_cast<char *>(&textureCount), sizeof(int)); 
     
    541539                ofile.write(reinterpret_cast<char *>(&dist), sizeof(float)); 
    542540 
    543                 int shapesPerEnt = 1; 
    544                 ofile.write(reinterpret_cast<char *>(&shapesPerEnt), sizeof(int)); 
     541                int shapesPerEntity = 1; 
     542                ofile.write(reinterpret_cast<char *>(&shapesPerEntity), sizeof(int)); 
    545543 
    546544                int shapeId = i; 
     
    765763        bool ok = ReadDummyTree(fr); 
    766764 
    767         // read bvh to optain objects (= the leaves of the bvh) 
     765        // read bvh to determine objects (= the leaves of the bvh) 
    768766        if (ok) ok = ReadBvh(fr); 
    769767 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.h

    r3242 r3243  
    144144 
    145145 
     146 
    146147        ////////////////////////////////// 
    147148 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env

    r3242 r3243  
    1616statsFilename=mystats.log 
    1717 
     18visibilitySolution=vienna_full-8x3-refu 
    1819 
    1920############ 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/AxisAlignedBox3.h

    r3202 r3243  
    104104        /** Sets the minimum for one dimension. 
    105105        */ 
    106         void SetMin(int axis, const float value); 
     106        void SetMin(int axis, float value); 
    107107        /** Sets the maximum for one dimension. 
    108108        */ 
    109         void SetMax(int axis, const float value); 
     109        void SetMax(int axis, float value); 
    110110        /** Decrease box by given splitting plane 
    111111        */ 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h

    r3123 r3243  
    154154        */ 
    155155        inline int CountPrimitives() const; 
    156         /** This is an imporantent function once you have one or more 
    157                 view point changes within a frame (e.g., camera view and shadow view for 
     156        /** This function is important in case you have more than one 
     157                view position within a frame (e.g., camera view and shadow view for 
    158158                shadow mapping), because each camera needs its own state in 
    159159                order to not break temporal coherency. 
    160160        */ 
    161         inline static void SetCurrentState(int _state) { sCurrentState = _state; } 
     161        inline static void SetCurrentState(int _state); 
    162162 
    163163 
     
    180180        /// stores the visibility related info  
    181181        VisibilityInfo mVisibility[NUM_STATES]; 
    182          
    183         // members used to speed up view frustum culling 
     182        /// when the node was last rendered 
     183        int mLastRenderedFrame[NUM_STATES]; 
     184 
     185 
     186        /////////////// 
     187        //-- members that help to speed up view frustum culling 
     188 
    184189        /// masks out planes of the frustum that do not have to be tested against 
    185190        int mPlaneMask[NUM_STATES]; 
     
    188193        */ 
    189194        int mPreferredPlane[NUM_STATES]; 
    190         /// when the node was last rendered 
    191         int mLastRenderedFrame[NUM_STATES]; 
     195 
    192196 
    193197        //////////////////// 
     
    406410 
    407411 
     412void BvhNode::SetCurrentState(int _state)  
     413{ 
     414        sCurrentState = _state;  
     415} 
     416 
    408417 
    409418/** Internal node of the bv hierarchy. 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Pvs.h

    r3242 r3243  
    22#define __PVS_H 
    33 
    4          
     4#include "common.h" 
     5 
     6 
    57namespace CHCDemoEngine 
    68{ 
     
    1416public: 
    1517 
    16         Pvs(): mEntries() { 
     18        Pvs() {}; 
    1719 
    18                 entries.set_deleted_key(-1); 
    19                 entries.set_empty_key(-2); 
     20        void Clear() { mEntries.clear(); } 
    2021 
    21         }; 
     22        bool Empty() const { return mEntries.empty(); } 
    2223 
    23         int GetSize() const { 
    24                 return (int)entries.size(); 
    25         } 
     24        SceneEntity *GetEntry(int i) const { return mEntries[i]; } 
     25 
     26        int Size() { return (int)mEntries.size(); } 
     27 
     28        void AddEntry(SceneEntity *ent) { mEntries.push_back(ent); } 
    2629 
    2730 
    28         bool Empty() const { 
    29                 return entries.empty(); 
    30         } 
     31protected: 
    3132 
    32         /** Adds object to PVS. 
    33         @returns contribution of sample (0 or 1) 
    34         */ 
    35         bool Insert(const int id, const float time = 0.0f) { 
    36  
    37                 pair<PVS_ITERATOR, bool> result = entries.insert(pair<int, float>(id,time)); 
    38  
    39                 return result.second; 
    40         } 
    41  
    42         bool Find(const int id) { 
    43                 PVS_ITERATOR it; 
    44                 return Find(id, it); 
    45         } 
    46  
    47         bool Find(const int id, PVS_ITERATOR &it) { 
    48                 it = entries.find(id); 
    49  
    50                 // already in map 
    51                 return (it != entries.end()); 
    52         } 
    53  
    54         void Clear() { 
    55                 entries.clear(); 
    56         } 
    57  
    58         static void Merge(Pvs &mergedPvs, 
    59                 const Pvs &a,  
    60                 const Pvs &b) 
    61         { 
    62                 mergedPvs.entries.insert(a.entries.begin(), a.entries.end()); 
    63                 mergedPvs.entries.insert(b.entries.begin(), b.entries.end()); 
    64         } 
    65  
    66         // just an estimate - could not find proper reference how to 
    67         // calculate memory occupied by hash_map and hash_set! 
    68         int GetMemoryUsage() const { 
    69  
    70                 return sizeof(Pvs) + sizeof(HASH_SET::value_type)*entries.bucket_count(); 
    71         } 
    72  
    73 protected: 
    7433        /// hash table of PVS entries 
    75         HASH_SET entries;  
    76  
     34        SceneEntityContainer mEntries;  
    7735}; 
    7836 
    79  
    80 /** Iterator over a hash pvs. 
    81 */ 
    82 class PvsIterator 
    83 { 
    84 protected: 
    85  
    86         CONST_PVS_ITERATOR itCurrent; 
    87         CONST_PVS_ITERATOR itEnd; 
    88  
    89 public: 
    90  
    91         PvsIterator() {} 
    92  
    93         PvsIterator(Pvs &pvs): 
    94         itCurrent(pvs.entries.begin()), itEnd(pvs.entries.end()) 
    95         { 
    96         } 
    97  
    98         bool HasMoreEntries() const  
    99         { 
    100                 return (itCurrent != itEnd); 
    101         } 
    102  
    103         void Next() { 
    104                 ++itCurrent; 
    105         } 
    106  
    107         int Current() const { 
    108  
    109                 return (*itCurrent).first; 
    110  
    111         } 
    112         float CurrentTime() const { 
    113  
    114                 return (*itCurrent).second; 
    115  
    116         } 
    117  
    118 }; 
    119  
    120 #if 0 
    121 // iterator of the PVS at the given time stamp 
    122 // onnly works properly in PVS_TIME_STAMPS is defined 
    123 // otherwise behaves the same as PvsIterator 
    124  
    125 class PvsTimeIterator : public PvsIterator 
    126 { 
    127 protected: 
    128         float time; 
    129 public: 
    130  
    131         PvsTimeIterator(Pvs &pvs, const float _time): 
    132           PvsIterator(pvs), time(_time) 
    133           { 
    134                   // find the first entry satisfying the time constraint 
    135                   for (;HasMoreEntries(); ++itCurrent) 
    136                           if ((*itCurrent).second <= time) 
    137                                   break; 
    138           } 
    139  
    140           void Next() { 
    141                   for (++itCurrent; HasMoreEntries(); ++itCurrent) 
    142                           if ((*itCurrent).second <= time) 
    143                                   break; 
    144           } 
    145  
    146 }; 
    147  
    148 #endif 
    14937} 
    15038 
    15139#endif 
    152  
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h

    r3120 r3243  
    112112        static bool GetUseLODs() { return sUseLODs; } 
    113113 
    114  
    115         int mId; 
    116  
    117114protected: 
    118115 
     
    143140        /// the center of gravity of this entity 
    144141        Vector3 mCenter; 
     142         
     143        int mId; 
    145144 
    146145        static bool sUseLODs; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ViewCellsTree.cpp

    r3242 r3243  
    22#include "Timer/PerfTimer.h" 
    33#include <stack> 
     4#include <string> 
    45 
    56using namespace std; 
    67 
    78 
     9// MAGIC of all bin exports 
     10#ifndef MAGIC  
     11#define MAGIC 0x827923 
     12#endif 
     13 
     14#define VIEWCELLS_VERSION 1.0f 
     15 
    816namespace CHCDemoEngine 
    917{ 
    1018 
     19 
    1120ViewCell *ViewCellsTree::GetViewCell(const Vector3 &point) const 
    1221{ 
    13         ViewCellsTreeNode *node = root; 
     22        ViewCellsTreeNode *node = mRoot; 
    1423 
    1524        while (!node->IsLeaf())  
    1625        { 
    17                 if (point[node->axis] < node->position) 
    18                         node = node->back; 
     26                if (point[node->mAxis] < node->mPosition) 
     27                        node = node->mBack; 
    1928                else 
    20                         node = node->front; 
     29                        node = node->mFront; 
    2130        } 
    2231 
    23         return node->viewCell; 
     32        return node->mViewCell; 
    2433} 
    2534 
    2635 
    27 bool ViewCellsTree::LoadFromFile(const string &filename) 
     36bool ViewCellsTree::LoadFromFile(const std::string &filename) 
    2837{ 
    29         cout << ("Info: Loading view cells from file '" + filename + "'" ); 
     38        cout << "Info: Loading view cells from file '" + filename + "'"; 
    3039 
    3140        FILE *fr = fopen(filename.c_str(), "rb"); 
    3241 
    33         if (fr == NULL) { 
    34                 Message("Error: Cannot open file for reading"); 
     42        if (!fr)  
     43        { 
     44                cerr << "Error: Cannot open file for reading" << endl; 
    3545                return false; 
    3646        } 
     
    3848        bool result = _LoadFromFile(fr); 
    3949 
    40         Debug << "Info: done. " << endl; 
     50        cout << "Info: done. " << endl; 
    4151        fclose(fr); 
    4252 
     
    5060        fread(buffer, sizeof(int), 3, fr); 
    5161 
    52         if (buffer[0] != MAGIC) { 
    53                 Message( "Error: Wrong file type"); 
     62        if (buffer[0] != MAGIC)  
     63        { 
     64                cerr << "Error: Wrong file type" << endl; 
    5465                return false; 
    5566        } 
    5667 
    57         if (buffer[1] != (int)(1000*VIEWCELLS_VERSION)) { 
    58                 Message( "Error: Wrong viewcells version" ); 
     68        if (buffer[1] != (int)(1000 * VIEWCELLS_VERSION))  
     69        { 
     70                cerr << "Error: Wrong viewcells version" << endl; 
    5971                return false; 
    6072        } 
    6173 
    6274        // get the bounding box 
    63         fread(&box, sizeof(AxisAlignedBox3), 1, fr); 
     75        fread(&mBox, sizeof(AxisAlignedBox3), 1, fr); 
    6476 
    6577        stack<ViewCellsTreeNode **> nodeStack; 
    6678 
    67         nodeStack.push(&root); 
     79        nodeStack.push(&mRoot); 
    6880 
    69         while(!nodeStack.empty()) { 
     81        while (!nodeStack.empty())  
     82        { 
    7083                ViewCellsTreeNode *&node = *nodeStack.top(); 
    7184                nodeStack.pop(); 
    72                 node = new ViewCellsTreeNode; 
    73                 fread(&node->axis, sizeof(int), 1, fr); 
    74                 if (!node->IsLeaf()) { 
    75                         fread(&node->position, sizeof(float), 1, fr); 
    76                         nodeStack.push(&node->front); 
    77                         nodeStack.push(&node->back); 
     85                node = new ViewCellsTreeNode(); 
     86 
     87                fread(&node->mAxis, sizeof(int), 1, fr); 
     88 
     89                if (!node->IsLeaf()) 
     90                { 
     91                        fread(&node->mPosition, sizeof(float), 1, fr); 
     92                        nodeStack.push(&node->mFront); 
     93                        nodeStack.push(&node->mBack); 
    7894                } 
    7995        } 
     
    8399 
    84100 
    85 void ViewCellsTree::_ExportToFile(FILE *file) 
    86 { 
    87         int buffer[256]; 
    88         int i=0; 
    89         buffer[i++] = MAGIC; 
    90         buffer[i++] = VIEWCELLS_VERSION*1000; 
    91  
    92         fwrite(buffer, sizeof(int), i, file); 
    93  
    94         fwrite(&mMaxDepth, sizeof(float), 1, file); 
    95  
    96         fwrite(&box, sizeof(AxisAlignedBox3), 1, file); 
    97  
    98         stack<ViewCellsTreeNode *> nodeStack; 
    99  
    100         nodeStack.push(root); 
    101  
    102         while (!nodeStack.empty()) { 
    103                 ViewCellsTreeNode *node = nodeStack.top(); 
    104                 nodeStack.pop(); 
    105  
    106                 fwrite(&node->axis, sizeof(int), 1, file); 
    107                 if (!node->IsLeaf()) { 
    108                         fwrite(&node->position, sizeof(float), 1, file); 
    109                         nodeStack.push(node->front); 
    110                         nodeStack.push(node->back); 
    111                 } 
    112         } 
    113101} 
    114  
    115 } 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ViewCellsTree.h

    r3242 r3243  
    55#include "Pvs.h" 
    66#include "AxisAlignedBox3.h" 
    7  
     7#include "common.h" 
    88 
    99         
     
    1919        ViewCell(): mPvs() {} 
    2020 
     21        int GetId() const { return mId; } 
     22 
     23        void SetId(int id) { mId = id; } 
     24 
     25        void SetBox(const AxisAlignedBox3 &box) { mBox = box; } 
     26 
     27 
     28        // the pvs associated with the viewcell 
     29        Pvs mPvs; 
     30 
    2131protected: 
    2232 
     
    2535        // bounding box of the viewcell 
    2636        AxisAlignedBox3 mBox; 
    27         // the pvs associated with the viewcell 
    28         Pvs mPvs; 
    29  
    3037}; 
    3138 
     
    3340struct ViewCellsTreeNode 
    3441{ 
    35         union  
    36         { 
    37                 // split position - 4B 
    38                 float position; 
    39                 // the viewcell associated with this node (NULL for non terminal nodes) - 4B 
    40                 ViewCell *viewCell;  
    41         }; 
    42  
    43  
    4442        ViewCellsTreeNode(): mAxis(-1), mViewCell(NULL) {} 
    4543 
    46         bool IsLeaf() { return mAxis == -1; } 
    47  
    48         bool IsVirtualLeaf() { return mViewCell != NULL; } 
     44        bool IsLeaf() { return mViewCell != NULL; } 
    4945 
    5046 
    5147        /////////////////////// 
    5248 
    53         // children of the node - 8B 
    54         ViewCellsTreeNode *mBack, *mFront; 
     49        union  
     50        { 
     51                // split position - 4B 
     52                float mPosition; 
     53                // the viewcell associated with this node (NULL for non terminal nodes) 
     54                ViewCell *mViewCell;  
     55        }; 
    5556 
    56         // kd tree split params 
    57         // split axis - 4B 
     57        /// children of the node 
     58        ViewCellsTreeNode *mBack; 
     59        ViewCellsTreeNode *mFront; 
     60 
     61        /// split mAxis  
    5862        int mAxis; 
    5963}; 
     
    6266class ViewCellsTree 
    6367{ 
     68        friend class VisibilitySolutionLoader; 
     69 
    6470public: 
    6571         
     
    7783        ViewCell *GetViewCell(const Vector3 &point) const; 
    7884 
    79         bool LoadFromFile(const string &filename); 
     85        bool LoadFromFile(const std::string &filename); 
    8086 
    8187 
     
    8793        //////////////////////// 
    8894 
    89         float mMaxDepth; 
     95        int mMaxDepth; 
    9096        AxisAlignedBox3 mBox; 
    9197        ViewCellsTreeNode *mRoot; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.cpp

    r3242 r3243  
    11#include "VisibilitySolutionLoader.h" 
     2#include "ViewCellsTree.h" 
     3#include "Bvh.h" 
     4#include <stack> 
    25 
    36 
     
    811{ 
    912 
    10 bool VisibilitySolutionLoader::Load(const std::string &filename 
    11                                                                         ViewCellsTree *viewCells) 
     13 
     14typedef vector<ViewCell *> ViewCellsContainer; 
     15 
     16 
     17ViewCellsTree *VisibilitySolutionLoader::Load(const std::string &filename, 
     18                                                                                          Bvh *bvh) 
    1219{ 
     20        FILE *fr = fopen(filename.c_str(), "rb"); 
     21   
     22        cout << "Info: Loading visibility solution from file '" + filename + "'" << endl; 
     23   
     24        if (fr == NULL)  
     25        { 
     26                cerr << "Error: Cannot open file for reading" << endl; 
     27                return NULL; 
     28        } 
     29 
     30        float totalSamples; 
     31        float totalTime; 
     32 
     33        fread(&totalSamples, sizeof(float), 1, fr); 
     34        fread(&totalTime, sizeof(float), 1, fr); 
     35 
     36        ViewCellsTree *viewCellsTree = new ViewCellsTree(); 
     37 
     38        bool ok = viewCellsTree->_LoadFromFile(fr); 
     39   
     40        if (ok)  
     41        { 
     42                // skip bvh loading 
     43                int buffer[6];  
     44                fread(buffer, sizeof(int), 6, fr); 
     45 
     46                const size_t numNodes = buffer[5]; 
     47                 
     48                for (int i = 0; i < numNodes; ++ i) 
     49                        fread(buffer, sizeof(int), 4, fr); 
     50 
     51                AllocateLeafViewCells(viewCellsTree); 
     52                 
     53                ok = LoadPvs(fr, bvh); 
     54        } 
     55 
     56        fclose(fr); 
     57 
     58        if (ok)  
     59                cerr << "Info: visibility solution loaded" << endl; 
     60        else 
     61                cerr << "Info: loading visibility solution failed." << endl; 
     62 
     63        return viewCellsTree; 
     64} 
     65 
     66 
     67bool VisibilitySolutionLoader::CreateIdSortedList(Bvh *bvh, BvhNodeContainer &nodes) 
     68{ 
     69        std::stack<BvhNode *> tStack; 
     70        tStack.push(bvh->GetRoot()); 
     71         
     72        while (!tStack.empty()) 
     73        { 
     74                BvhNode *node = tStack.top(); 
     75                tStack.pop(); 
     76 
     77                nodes.push_back(node); 
     78 
     79                if (!node->IsLeaf()) 
     80                { 
     81                        BvhInterior *interior = static_cast<BvhInterior *>(node); 
     82 
     83                        BvhNode *front = interior->GetFront(); 
     84                        BvhNode *back = interior->GetBack(); 
     85 
     86                        tStack.push(front); 
     87                        tStack.push(back); 
     88                } 
     89        } 
     90 
    1391        return true; 
    1492} 
    1593 
     94 
     95bool VisibilitySolutionLoader::LoadPvs(FILE *fw, Bvh *bvh) 
     96{ 
     97        int number, entries; 
     98 
     99        fread(&number, sizeof(int), 1, fw); 
     100 
     101        if (number == 0)  
     102        { 
     103                cerr << "Info: Warning empty PVSs in visibility solution" << endl; 
     104                return true; 
     105        } 
     106 
     107        if (number != mViewCells.size())  
     108        { 
     109                cerr << "Info: Number of view cells does not match when loading PVSs!" << endl; 
     110                return false; 
     111        } 
     112 
     113        BvhNodeContainer nodes; 
     114        CreateIdSortedList(bvh, nodes); 
     115 
     116        for (int i = 0; i < number; ++ i)  
     117        { 
     118                fread(&entries, sizeof(int), 1, fw); 
     119 
     120                for (int j=0; j < entries; ++ j)  
     121                { 
     122                        int objectId; 
     123                        float time; 
     124                 
     125                        fread(&objectId, sizeof(int), 1, fw); 
     126                        fread(&time, sizeof(float), 1, fw); 
     127 
     128                        BvhNode *node = nodes[objectId]; 
     129 
     130                        int geometrySize; 
     131                        SceneEntity **entities; 
     132                        entities = bvh->GetGeometry(node, geometrySize); 
     133 
     134                        for (int k = 0; k < geometrySize; ++ k) 
     135                        { 
     136                                mViewCells[i]->mPvs.AddEntry(entities[k]); 
     137                        } 
     138                } 
     139        } 
     140 
     141        return true; 
    16142} 
     143 
     144 
     145void VisibilitySolutionLoader::AllocateLeafViewCells(ViewCellsTree *viewCellsTree) 
     146{ 
     147        stack< pair<ViewCellsTreeNode *, AxisAlignedBox3> > nodeStack; 
     148 
     149        nodeStack.push(pair<ViewCellsTreeNode *, AxisAlignedBox3> 
     150                           (viewCellsTree->mRoot, viewCellsTree->mBox)); 
     151 
     152        int id = 0; 
     153 
     154        mViewCells.clear(); 
     155         
     156        while (!nodeStack.empty())  
     157        { 
     158                ViewCellsTreeNode *node = nodeStack.top().first; 
     159                 
     160                if (node->IsLeaf())  
     161                { 
     162                        if (node->mViewCell == NULL)  
     163                        { 
     164                                node->mViewCell = new ViewCell(); 
     165                                node->mViewCell->SetId(id ++); 
     166                                node->mViewCell->SetBox(nodeStack.top().second); 
     167                        } 
     168 
     169                        mViewCells.push_back(node->mViewCell); 
     170 
     171                        nodeStack.pop(); 
     172                }  
     173                else  
     174                { 
     175                        AxisAlignedBox3 box = nodeStack.top().second; 
     176                        nodeStack.pop(); 
     177 
     178                        AxisAlignedBox3 newBox = box; 
     179                        newBox.SetMin(node->mAxis, node->mPosition); 
     180 
     181                        nodeStack.push( 
     182                                pair<ViewCellsTreeNode *, AxisAlignedBox3>(node->mFront, newBox) 
     183                                ); 
     184 
     185                        newBox = box; 
     186                        newBox.SetMax(node->mAxis, node->mPosition); 
     187 
     188                        nodeStack.push( 
     189                                pair<ViewCellsTreeNode *, AxisAlignedBox3>(node->mBack, newBox) 
     190                                ); 
     191                } 
     192        } 
     193 
     194        cout << "#of viewcells = " << id << endl; 
     195} 
     196 
     197 
     198} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/VisibilitySolutionLoader.h

    r3242 r3243  
    22#define _VISIBILITYSOLUTIONLOADER_H 
    33 
     4#include "common.h" 
     5 
     6 
     7namespace CHCDemoEngine 
     8{ 
    49 
    510class ViewCellsTree; 
    6          
    7 namespace CHCDemoEngine 
    8 { 
     11struct ViewCell; 
     12class Bvh; 
     13 
     14typedef std::vector<ViewCell *> ViewCellsContainer; 
     15 
    916 
    1017/** Loads a preprocessed visibility solution. 
     
    1421public: 
    1522 
    16         VisibilitySolutionLoader(); 
     23        VisibilitySolutionLoader(): mNumNodes(0) {}; 
    1724 
    18         ~VisibilitySolutionLoader(); 
     25        ViewCellsTree *Load(const std::string &filename, Bvh *bvh); 
    1926 
    20         bool Load(const std::string &filename 
    21                       ViewCellsTree *viewCells); 
    2227 
    2328protected: 
     29        /** Creates list of bvh nodes where the index 
     30                is equivalent to the id of this node in the bvh. 
     31        */ 
     32        bool CreateIdSortedList(Bvh *bvh, BvhNodeContainer &nodes); 
     33 
     34        bool LoadPvs(FILE *fw, Bvh *bvh); 
     35 
     36        void AllocateLeafViewCells(ViewCellsTree *viewCellsTree); 
     37 
     38 
     39        /////////////// 
    2440 
    2541        int mNumNodes; 
     42 
     43        ViewCellsContainer mViewCells; 
    2644}; 
    2745 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3242 r3243  
    5858#include "WalkThroughRecorder.h" 
    5959#include "StatsWriter.h" 
     60#include "VisibilitySolutionLoader.h" 
     61#include "ViewCellsTree.h" 
    6062 
    6163 
     
    127129 
    128130string filename("city"); 
     131string visibilitySolution(""); 
    129132 
    130133 
     
    430433                env.GetStringParam(string("statsFilename"), statsFilename); 
    431434                env.GetStringParam(string("filename"), filename); 
     435                env.GetStringParam(string("visibilitySolution"), visibilitySolution); 
    432436 
    433437                //env.GetStringParam(string("modelPath"), model_path); 
     
    461465                cout << "stats filename: " << statsFilename << endl; 
    462466                cout << "filename: " << filename << endl; 
     467                cout << "visibilitySolution: " << visibilitySolution << endl; 
     468                 
    463469 
    464470                //cout << "model path: " << model_path << endl; 
     
    604610        /// set the depth of the bvh depending on the triangles per leaf node 
    605611        bvh->SetVirtualLeaves(trianglesPerVirtualLeaf); 
     612 
     613        /////////// 
     614        //-- load the visibility solution 
     615 
     616        const string vis_filename =  
     617                string(model_path + visibilitySolution + ".vis"); 
     618 
     619        VisibilitySolutionLoader visLoader; 
     620 
     621        ViewCellsTree *viewCellsTree = visLoader.Load(vis_filename, bvh); 
     622 
    606623 
    607624        // set far plane based on scene extent 
Note: See TracChangeset for help on using the changeset viewer.