Changeset 3262


Ignore:
Timestamp:
01/11/09 01:18:50 (15 years ago)
Author:
mattausch
Message:

working on pompeii loading. fixed bug in obj conversion

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

Legend:

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

    r3261 r3262  
    133133                                StringPooling="true" 
    134134                                RuntimeLibrary="2" 
     135                                BufferSecurityCheck="false" 
    135136                                EnableEnhancedInstructionSet="2" 
    136137                                RuntimeTypeInfo="false" 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter2.cpp

    r3261 r3262  
    1212                                                const VertexArray &vertices,  
    1313                                                const VertexArray &normals,  
    14                                                 const vector<pair<float, float> > &texcoords, 
     14                                                const vector<Texcoord> &texcoords, 
    1515                                                VertexArray &faceVertices, 
    1616                                                VertexArray &faceNormals, 
     
    2828        { 
    2929                string s(pch); 
    30                 //s += "\n", 
    3130                triples.push_back(s); 
    3231                 
     
    3433        } 
    3534 
     35        // throw away last symbol (\n) 
     36        triples.back().resize(triples.back().size() - 1); 
     37 
    3638        vector<int> indices; 
    3739        vector<int> nIndices; 
    3840        vector<int> tIndices; 
    3941 
    40         char seps[] = " /\t\n"; 
     42        char seps[] = " "; 
     43        char seps2[] = "/"; 
    4144 
    4245        for (size_t i = 0; i < triples.size(); ++ i) 
    4346        { 
    44                 static int dummy = 0; 
    45  
     47                //cout << "triple " << i << " " << triples[i] << endl; 
    4648                size_t found; 
    47                 found = triples[i].find_first_of(seps); 
     49                found = triples[i].find_first_of(seps2); 
    4850                size_t prevfound = 0; 
    49                 // vertex, normal, texture indices 
     51 
     52                // extract vertex, normal, texture indices 
    5053                string str = triples[i].substr(prevfound, found); 
    5154 
    5255                int index = (int)strtol(str.c_str(), NULL, 10) - 1; 
    53  
    5456                int tIndex = index; 
    5557                int nIndex = index;      
    5658                 
    57                 prevfound = found; 
    58                 found = triples[i].find_first_of(seps, found + 1);   
     59                // try to extract texture and normal indices 
     60                prevfound = found + 1; 
     61                found = triples[i].find_first_of(seps2, prevfound);   
    5962 
    6063                if (found != string::npos) 
     
    6568                        if (idx > 0) tIndex = idx; 
    6669                } 
    67  
    68                 if ((found + 1) < triples[i].size()) 
     70                 
     71                if (found != string::npos) 
    6972                { 
    7073                        str = triples[i].substr(found + 1); 
     
    8083                        nIndices.push_back(nIndex); 
    8184                        tIndices.push_back(tIndex); 
    82                 } 
    83  
     85 
     86                        //cout << index << " " << tIndex << " " << nIndex << endl; 
     87                } 
     88 
     89                int idx[3]; 
    8490                // new triangle found 
    8591                if (indices.size() > 2) 
     
    8793                        // change orientation of faces? 
    8894#if 1 
    89                         int idx1 = 0; 
    90                         int idx2 = (int)indices.size() - 2; 
    91                         int idx3 = (int)indices.size() - 1; 
     95                        idx[0] = 0; 
     96                        idx[1] = (int)indices.size() - 2; 
     97                        idx[2] = (int)indices.size() - 1; 
    9298#else 
    93                         int idx3 = 0; 
    94                         int idx2 = (int)indices.size() - 2; 
    95                         int idx1 = (int)indices.size() - 1; 
     99                        idx[2] = 0; 
     100                        idx[1] = (int)indices.size() - 2; 
     101                        idx[0] = (int)indices.size() - 1; 
    96102#endif 
    97                         faceVertices.push_back(vertices[indices[idx1]]); 
    98                         faceVertices.push_back(vertices[indices[idx2]]); 
    99                         faceVertices.push_back(vertices[indices[idx3]]); 
     103                        for (int j = 0; j < 3; ++ j) 
     104                                faceVertices.push_back(vertices[indices[idx[j]]]); 
    100105 
    101106 
    102107                        if (!normals.empty()) 
    103108                        { 
    104                                 faceNormals.push_back(normals[nIndices[idx1]]); 
    105                                 faceNormals.push_back(normals[nIndices[idx2]]); 
    106                                 faceNormals.push_back(normals[nIndices[idx3]]); 
     109                                for (int j = 0; j < 3; ++ j) 
     110                                        faceNormals.push_back(normals[nIndices[idx[j]]]); 
    107111                        } 
    108112                        else 
    109113                        { 
    110114                                // no face normals? => create normals 
    111                                 const SimpleTri tri(vertices[indices[idx1]], 
    112                                                         vertices[indices[idx2]],  
    113                                                                         vertices[indices[idx3]]); 
     115                                const SimpleTri tri(vertices[indices[idx[0]]], 
     116                                                        vertices[indices[idx[1]]],  
     117                                                                        vertices[indices[idx[2]]]); 
     118 
    114119                                const SimpleVec n = tri.GetNormal(); 
    115120 
     
    121126                        if (!texcoords.empty()) 
    122127                        { 
    123                                 faceTexcoords.push_back(texcoords[tIndices[idx1]]); 
    124                                 faceTexcoords.push_back(texcoords[tIndices[idx2]]); 
    125                                 faceTexcoords.push_back(texcoords[tIndices[idx3]]); 
     128                                for (int j = 0; j < 3; ++ j) 
     129                                { 
     130                                        if (tIndices[idx[j]] >= (int)texcoords.size()) 
     131                                                cerr << "error: texcoord indices exceed array size " << texcoords.size() << " " << tIndices[idx[j]] << endl; 
     132                                        const int tidx = min((int)texcoords.size() - 1, tIndices[idx[j]]); 
     133 
     134                                        faceTexcoords.push_back(texcoords[tidx]); 
     135                                } 
    126136                        } 
    127137                } 
     
    219229        } 
    220230 
    221  
    222231        return true; 
    223232} 
     
    233242        for (it = filenames.begin(); it != it_end; ++ it) 
    234243        { 
    235                 cout << "\n==================\n loading file " << *it << endl; 
    236  
    237                 if (!ReadFile(*it)) 
    238                 { 
    239                         cerr << "could not read file " << *it << endl; 
    240                         return false; 
    241                 } 
    242         } 
     244                const string filename = *it; 
     245 
     246                cout << "\n==================\n loading file " << filename << endl; 
     247 
     248                if (!ReadFile(filename)) 
     249                { 
     250                        cerr << "could not read file ... skipping " << filename << endl; 
     251                        //return false; 
     252                } 
     253        } 
     254 
     255        cout << "\n*******************\n writing file " << outputFilename << endl; 
    243256 
    244257        if (!WriteFile(outputFilename)) 
     
    279292        while (fgets(str, len, file) != NULL) 
    280293        { 
     294                //cout << "line: " << line << endl; 
     295 
    281296                switch (str[0]) 
    282297                { 
     
    323338                                //-- indices in the current line 
    324339 
     340                                //cout << "f: " << vertices.size() << " n: " << normals.size() << " " << texcoords.size() << endl; 
     341 
    325342                                LoadIndices(str,  
    326343                                                vertices, normals, texcoords,  
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp

    r3261 r3262  
    3232         
    3333        //const int numFiles = 879; 
    34         const int numFiles = 100; 
     34        const int numFiles = 300; 
    3535 
    3636        vector<string> filenames; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.vcproj

    r3260 r3262  
    160160                        > 
    161161                        <File 
     162                                RelativePath=".\src\BvhConstructor.cpp" 
     163                                > 
     164                        </File> 
     165                        <File 
     166                                RelativePath=".\src\BvhConstructor.h" 
     167                                > 
     168                        </File> 
     169                        <File 
    162170                                RelativePath=".\src\BvhExporter.cpp" 
    163171                                > 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/MainApp.vcproj

    r3261 r3262  
    130130                                PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS" 
    131131                                RuntimeLibrary="2" 
     132                                BufferSecurityCheck="false" 
    132133                                EnableEnhancedInstructionSet="2" 
    133134                                RuntimeTypeInfo="false" 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/VboFormatConverter.vcproj

    r3260 r3262  
    125125                                PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" 
    126126                                RuntimeLibrary="2" 
     127                                RuntimeTypeInfo="false" 
    127128                                UsePrecompiledHeader="0" 
    128129                                WarningLevel="3" 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter.vcproj

    r3258 r3262  
    122122                                Name="VCCLCompilerTool" 
    123123                                AdditionalOptions=" /D &quot;_CRT_SECURE_NO_WARNINGS&quot;" 
     124                                Optimization="3" 
     125                                InlineFunctionExpansion="2" 
     126                                EnableIntrinsicFunctions="true" 
     127                                FavorSizeOrSpeed="1" 
     128                                OmitFramePointers="true" 
     129                                EnableFiberSafeOptimizations="true" 
    124130                                AdditionalIncludeDirectories="libs\Zlib\include; src" 
    125131                                PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE" 
    126132                                RuntimeLibrary="2" 
     133                                BufferSecurityCheck="false" 
     134                                EnableEnhancedInstructionSet="2" 
     135                                RuntimeTypeInfo="false" 
    127136                                UsePrecompiledHeader="0" 
    128137                                WarningLevel="3" 
     
    145154                                AdditionalLibraryDirectories="libs\Zlib\lib; lib\$(ConfigurationName)" 
    146155                                IgnoreDefaultLibraryNames="libCMT" 
    147                                 GenerateDebugInformation="true" 
     156                                GenerateDebugInformation="false" 
    148157                                SubSystem="1" 
    149158                                LargeAddressAware="2" 
    150159                                OptimizeReferences="2" 
    151160                                EnableCOMDATFolding="2" 
     161                                OptimizeForWindows98="1" 
    152162                                TargetMachine="1" 
    153163                        /> 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env

    r3260 r3262  
    2323visibilitySolution=vienna_full-8x3-pgv 
    2424viewCellsScaleFactor=1.0f 
    25 useSkylightForIllum=1 
     25useSkylightForIllum=0 
    2626 
    2727 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp

    r3259 r3262  
    146146} 
    147147 
     148BvhInterior::BvhInterior(BvhNode *parent): 
     149mBack(NULL), mFront(NULL), BvhNode(parent) 
     150{} 
     151 
     152 
     153bool BvhInterior::IsLeaf() const 
     154{ 
     155        return false;  
     156} 
     157 
     158 
     159 
     160BvhLeaf::BvhLeaf(BvhNode *parent): BvhNode(parent) 
     161{} 
     162 
     163 
     164bool BvhLeaf::IsLeaf() const 
     165{ 
     166        return true;  
     167} 
     168 
     169 
    148170 
    149171/**********************************************************/ 
    150172/*                class Bvh implementation                */ 
    151173/**********************************************************/ 
    152  
    153  
    154  
    155 inline AxisAlignedBox3 ComputeBoundingBox(SceneEntity **entities, int numEntities) 
    156 { 
    157         AxisAlignedBox3 box; 
    158          
    159         if (!numEntities) 
    160         {       // no box=> just initialize 
    161                 box.Initialize(); 
    162         } 
    163         else 
    164         { 
    165                 box = entities[0]->GetWorldBoundingBox(); 
    166  
    167                 for (int i = 1; i < numEntities; ++ i) 
    168                 { 
    169                         box.Include(entities[i]->GetWorldBoundingBox()); 
    170                 } 
    171         } 
    172  
    173         return box; 
    174 } 
    175174 
    176175 
     
    14401439        leaf->mParent = parent; 
    14411440         
    1442         front->mBox = ComputeBoundingBox(mGeometry + front->mFirst, front->CountPrimitives()); 
    1443         leaf->mBox = ComputeBoundingBox(mGeometry + leaf->mFirst, leaf->CountPrimitives()); 
     1441        front->mBox = SceneEntity::ComputeBoundingBox(mGeometry + front->mFirst, front->CountPrimitives()); 
     1442        leaf->mBox = SceneEntity::ComputeBoundingBox(mGeometry + leaf->mFirst, leaf->CountPrimitives()); 
    14441443 
    14451444        // recursively continue subdivision 
     
    14681467                SceneEntity **entities = GetGeometry(node, numEntities); 
    14691468 
    1470                 node->mBox = ComputeBoundingBox(entities, numEntities); 
     1469                node->mBox = SceneEntity::ComputeBoundingBox(entities, numEntities); 
    14711470                //cout << "box: " << node->mBox << endl; 
    14721471        } 
     
    14881487{ 
    14891488        // the bvh has two main branches 
    1490         // a static branch (the old root), and adynamic branch  
     1489        // a static branch (the old root), and a dynamic branch  
    14911490        // we create a 'dynamic' leaf which basically is a container 
    14921491        // for all dynamic objects underneath 
     
    15011500        mDynamicRoot = l; 
    15021501 
    1503         l->mBox = ComputeBoundingBox(mGeometry + mStaticGeometrySize, (int)mDynamicGeometrySize); 
     1502        l->mBox = SceneEntity::ComputeBoundingBox(mGeometry + mStaticGeometrySize,  
     1503                                                      (int)mDynamicGeometrySize); 
    15041504 
    15051505        l->mFirst = (int)mStaticGeometrySize; 
     
    15101510 
    15111511        if (mDynamicGeometrySize) 
     1512        { 
    15121513                mDynamicRoot = SubdivideLeaf(l, 0); 
     1514        } 
    15131515} 
    15141516 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.h

    r3259 r3262  
    3131        friend class BvhLoader; 
    3232        friend class BvhExporter; 
    33         friend class mygreaterdistance; 
     33        friend class BvhConstructor; 
    3434 
    3535public: 
     
    236236        //-- rendering related options 
    237237 
    238         /// the bounding boxes of the test nodes are queries instead of the actual node 
     238        /// we  query the bounding boxes of the test nodes when testing this node 
    239239        int mTestNodesIdx; 
    240240        /// the number of these test nodes 
     
    246246 
    247247 
    248 ///////////////// 
    249 //-- public inline functions 
    250  
    251  
    252 int BvhNode::GetLastVisitedFrame() const  
    253 {  
    254         return mVisibility[sCurrentState].mLastVisitedFrame;  
    255 } 
    256  
    257  
    258 void BvhNode::SetLastVisitedFrame(const int lastVisited)  
    259 {  
    260         mVisibility[sCurrentState].mLastVisitedFrame = lastVisited;  
    261 } 
    262  
    263  
    264 bool BvhNode::IsVisible() const  
    265 {  
    266         return mVisibility[sCurrentState].mIsVisible;  
    267 } 
    268  
    269  
    270 void BvhNode::SetVisible(bool visible)  
    271 {  
    272         mVisibility[sCurrentState].mIsVisible = visible;  
    273 } 
    274  
    275  
    276 void BvhNode::IncTimesTestedInvisible()  
    277 {  
    278         ++ mVisibility[sCurrentState].mTimesInvisible;  
    279 } 
    280  
    281  
    282 int BvhNode::GetTimesTestedInvisible() const  
    283 {  
    284         return mVisibility[sCurrentState].mTimesInvisible;  
    285 } 
    286  
    287  
    288 void BvhNode::SetTimesTestedInvisible(int t)  
    289 {  
    290         mVisibility[sCurrentState].mTimesInvisible = t;  
    291 } 
    292  
    293  
    294 bool BvhNode::IsViewFrustumCulled() const  
    295 {  
    296         return mVisibility[sCurrentState].mIsFrustumCulled;  
    297 } 
    298  
    299  
    300 void BvhNode::SetViewFrustumCulled(bool frustumCulled)  
    301 {  
    302         mVisibility[sCurrentState].mIsFrustumCulled = frustumCulled;  
    303 } 
    304  
    305  
    306 bool BvhNode::IsNew() const  
    307 {  
    308         return mVisibility[sCurrentState].mIsNew; 
    309 } 
    310  
    311  
    312 void BvhNode::SetIsNew(bool isNew)  
    313 {  
    314         mVisibility[sCurrentState].mIsNew = isNew;  
    315 } 
    316  
    317  
    318 void BvhNode::SetAssumedVisibleFrameId(int t)  
    319 {  
    320         mVisibility[sCurrentState].mAssumedVisibleFrameId = t;  
    321 } 
    322  
    323  
    324 int BvhNode::GetAssumedVisibleFrameId() const  
    325 {  
    326         return mVisibility[sCurrentState].mAssumedVisibleFrameId; 
    327 } 
    328  
    329  
    330 int BvhNode::GetLastQueriedFrame() const 
    331 { 
    332         return mVisibility[sCurrentState].mLastQueriedFrame; 
    333 } 
    334  
    335  
    336 void BvhNode::SetLastQueriedFrame(int lastTested) 
    337 { 
    338         mVisibility[sCurrentState].mLastQueriedFrame = lastTested; 
    339 } 
    340  
    341  
    342 int BvhNode::GetLastRenderedFrame() const  
    343 {  
    344         return mLastRenderedFrame[sCurrentState];  
    345 } 
    346          
    347  
    348 void BvhNode::SetLastRenderedFrame(int lastRenderedFrame) 
    349 { 
    350         mLastRenderedFrame[sCurrentState] = lastRenderedFrame; 
    351 } 
    352          
    353          
    354 bool BvhNode::Empty() const  
    355 {  
    356         return (mFirst == -1);  
    357 } 
    358  
    359  
    360 int BvhNode::CountPrimitives() const  
    361 { 
    362         return mLast - mFirst + 1;  
    363 } 
    364  
    365 int BvhNode::GetDepth() const  
    366 {  
    367         return mDepth;  
    368 } 
    369  
    370  
    371 BvhNode *BvhNode::GetParent()  
    372 {  
    373         return mParent;  
    374 } 
    375  
    376  
    377 int BvhNode::GetNumLeaves() const 
    378 { 
    379         return mNumLeaves; 
    380 } 
    381  
    382  
    383 bool BvhNode::IsVirtualLeaf() const 
    384 {  
    385         return mIsVirtualLeaf;  
    386 } 
    387  
    388  
    389 float BvhNode::GetDistance() const 
    390 { 
    391         return mDistance;  
    392 } 
    393  
    394          
    395 const AxisAlignedBox3 &BvhNode::GetBox() const 
    396 { 
    397         return mBox;  
    398 } 
    399  
    400  
    401 int BvhNode::GetId() const  
    402 { 
    403         return mId;  
    404 } 
    405  
    406  
    407 void BvhNode::SetId(int id)  
    408 { 
    409         mId = id;  
    410 } 
    411  
    412  
    413 void BvhNode::SetCurrentState(int _state)  
    414 { 
    415         sCurrentState = _state;  
    416 } 
    417  
    418  
    419248/** Internal node of the bv hierarchy. 
    420249*/ 
     
    424253        friend class BvhLoader; 
    425254        friend class BvhExporter; 
     255        friend class BvhConstructor; 
    426256 
    427257public: 
    428258 
    429         BvhInterior(BvhNode *parent): mBack(NULL), mFront(NULL), BvhNode(parent) 
    430         {} 
    431         virtual bool IsLeaf() const { return false; } 
     259        BvhInterior(BvhNode *parent); 
     260         
     261        virtual bool IsLeaf() const; 
    432262        /** Back child. 
    433263        */ 
    434         inline BvhNode *GetBack() { return mBack; } 
     264        inline BvhNode *GetBack(); 
    435265        /** Front child. 
    436266        */ 
    437         inline BvhNode *GetFront() { return mFront; } 
     267        inline BvhNode *GetFront(); 
    438268        /** Recursivly delete hierarchy. 
    439269        */ 
     
    448278 
    449279 
     280 
    450281class BvhLeaf: public BvhNode 
    451282{ 
     
    455286public: 
    456287 
    457         BvhLeaf(BvhNode *parent): BvhNode(parent) 
    458         {} 
     288        BvhLeaf(BvhNode *parent); 
    459289 
    460290        ~BvhLeaf(); 
    461291 
    462         virtual bool IsLeaf() const { return true; } 
     292        virtual bool IsLeaf() const; 
    463293}; 
    464294 
     
    485315{ 
    486316        friend class BvhLoader; 
     317        friend class BvhConstructor; 
    487318        friend class BvhExporter; 
    488319 
     
    646477 
    647478        //////////// 
    648         //-- functions influencing the tightness of the bounds that are used for testing 
     479        //-- these functions determine the 'tightness' of the bounds that are used for querying 
    649480 
    650481 
     
    681512                Sets the static and dynamic objects for the hierarchy. 
    682513        */ 
    683         const Bvh(const SceneEntityContainer &staticEntities,  
    684                       const SceneEntityContainer &dynamicEntities); 
     514        Bvh(const SceneEntityContainer &staticEntities,  
     515            const SceneEntityContainer &dynamicEntities); 
    685516        /** Protected constructor taking scene geometry into account 
    686517                Sets the static and dynamic objects for the hierarchy. 
    687518        */ 
    688         const Bvh(const SceneEntityContainer &staticEntities,  
    689                       const SceneEntityContainer &dynamicEntities, 
    690                           int maxDepthForTestingChildren); 
     519        Bvh(const SceneEntityContainer &staticEntities,  
     520            const SceneEntityContainer &dynamicEntities, 
     521            int maxDepthForTestingChildren); 
    691522        /** Called by the constructor. Initializes important members. 
    692523        */ 
     
    842673 
    843674 
    844 int Bvh::GetNumNodes() const 
     675inline int BvhNode::GetLastVisitedFrame() const  
     676{  
     677        return mVisibility[sCurrentState].mLastVisitedFrame;  
     678} 
     679 
     680 
     681inline void BvhNode::SetLastVisitedFrame(const int lastVisited)  
     682{  
     683        mVisibility[sCurrentState].mLastVisitedFrame = lastVisited;  
     684} 
     685 
     686 
     687inline bool BvhNode::IsVisible() const  
     688{  
     689        return mVisibility[sCurrentState].mIsVisible;  
     690} 
     691 
     692 
     693inline void BvhNode::SetVisible(bool visible)  
     694{  
     695        mVisibility[sCurrentState].mIsVisible = visible;  
     696} 
     697 
     698 
     699inline void BvhNode::IncTimesTestedInvisible()  
     700{  
     701        ++ mVisibility[sCurrentState].mTimesInvisible;  
     702} 
     703 
     704 
     705inline int BvhNode::GetTimesTestedInvisible() const  
     706{  
     707        return mVisibility[sCurrentState].mTimesInvisible;  
     708} 
     709 
     710 
     711inline void BvhNode::SetTimesTestedInvisible(int t)  
     712{  
     713        mVisibility[sCurrentState].mTimesInvisible = t;  
     714} 
     715 
     716 
     717inline bool BvhNode::IsViewFrustumCulled() const  
     718{  
     719        return mVisibility[sCurrentState].mIsFrustumCulled;  
     720} 
     721 
     722 
     723inline void BvhNode::SetViewFrustumCulled(bool frustumCulled)  
     724{  
     725        mVisibility[sCurrentState].mIsFrustumCulled = frustumCulled;  
     726} 
     727 
     728 
     729inline bool BvhNode::IsNew() const  
     730{  
     731        return mVisibility[sCurrentState].mIsNew; 
     732} 
     733 
     734 
     735inline void BvhNode::SetIsNew(bool isNew)  
     736{  
     737        mVisibility[sCurrentState].mIsNew = isNew;  
     738} 
     739 
     740 
     741inline void BvhNode::SetAssumedVisibleFrameId(int t)  
     742{  
     743        mVisibility[sCurrentState].mAssumedVisibleFrameId = t;  
     744} 
     745 
     746 
     747inline int BvhNode::GetAssumedVisibleFrameId() const  
     748{  
     749        return mVisibility[sCurrentState].mAssumedVisibleFrameId; 
     750} 
     751 
     752 
     753inline int BvhNode::GetLastQueriedFrame() const 
     754{ 
     755        return mVisibility[sCurrentState].mLastQueriedFrame; 
     756} 
     757 
     758 
     759inline void BvhNode::SetLastQueriedFrame(int lastTested) 
     760{ 
     761        mVisibility[sCurrentState].mLastQueriedFrame = lastTested; 
     762} 
     763 
     764 
     765inline int BvhNode::GetLastRenderedFrame() const  
     766{  
     767        return mLastRenderedFrame[sCurrentState];  
     768} 
     769         
     770 
     771inline void BvhNode::SetLastRenderedFrame(int lastRenderedFrame) 
     772{ 
     773        mLastRenderedFrame[sCurrentState] = lastRenderedFrame; 
     774} 
     775         
     776         
     777inline bool BvhNode::Empty() const  
     778{  
     779        return (mFirst == -1);  
     780} 
     781 
     782 
     783inline int BvhNode::CountPrimitives() const  
     784{ 
     785        return mLast - mFirst + 1;  
     786} 
     787 
     788inline int BvhNode::GetDepth() const  
     789{  
     790        return mDepth;  
     791} 
     792 
     793 
     794inline BvhNode *BvhNode::GetParent()  
     795{  
     796        return mParent;  
     797} 
     798 
     799 
     800inline int BvhNode::GetNumLeaves() const 
     801{ 
     802        return mNumLeaves; 
     803} 
     804 
     805 
     806inline bool BvhNode::IsVirtualLeaf() const 
     807{  
     808        return mIsVirtualLeaf;  
     809} 
     810 
     811 
     812inline float BvhNode::GetDistance() const 
     813{ 
     814        return mDistance;  
     815} 
     816 
     817         
     818inline const AxisAlignedBox3 &BvhNode::GetBox() const 
     819{ 
     820        return mBox;  
     821} 
     822 
     823 
     824inline int BvhNode::GetId() const  
     825{ 
     826        return mId;  
     827} 
     828 
     829 
     830inline void BvhNode::SetId(int id)  
     831{ 
     832        mId = id;  
     833} 
     834 
     835 
     836inline void BvhNode::SetCurrentState(int _state)  
     837{ 
     838        sCurrentState = _state;  
     839} 
     840 
     841 
     842inline BvhNode *BvhInterior::GetBack() 
     843{ 
     844        return mBack;  
     845} 
     846 
     847 
     848inline BvhNode *BvhInterior::GetFront()  
     849{  
     850        return mFront;  
     851} 
     852 
     853 
     854inline int Bvh::GetNumNodes() const 
    845855{ 
    846856        return mNumNodes;  
     
    848858 
    849859 
    850 int Bvh::GetNumLeaves() const  
     860inline int Bvh::GetNumLeaves() const  
    851861{  
    852862        return mNumNodes / 2 + 1; 
     
    854864 
    855865 
    856 int Bvh::GetNumVirtualNodes() const   
     866inline int Bvh::GetNumVirtualNodes() const   
    857867{  
    858868        return mNumVirtualNodes;  
     
    860870 
    861871 
    862 int Bvh::GetNumVirtualLeaves() const 
     872inline int Bvh::GetNumVirtualLeaves() const 
    863873{ 
    864874        return mNumVirtualNodes / 2 + 1; 
     
    866876 
    867877 
    868 BvhNode *Bvh::GetRoot() 
     878inline BvhNode *Bvh::GetRoot() 
    869879{  
    870880        return mRoot;  
     
    872882 
    873883 
    874 BvhNode *Bvh::GetDynamicRoot() 
     884inline BvhNode *Bvh::GetDynamicRoot() 
    875885{  
    876886        return mDynamicRoot;  
     
    878888 
    879889 
    880 BvhNode *Bvh::GetStaticRoot() 
     890inline BvhNode *Bvh::GetStaticRoot() 
    881891{  
    882892        return mStaticRoot;  
     
    884894 
    885895 
    886 const AxisAlignedBox3 &Bvh::GetBox() const  
     896inline const AxisAlignedBox3 &Bvh::GetBox() const  
    887897{  
    888898        return mBox;  
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.cpp

    r3259 r3262  
    183183 
    184184 
    185 } 
     185AxisAlignedBox3 SceneEntity::ComputeBoundingBox(SceneEntity **entities, int numEntities) 
     186{ 
     187        AxisAlignedBox3 box; 
     188         
     189        if (!numEntities) 
     190        {       // no box => just initialize 
     191                box.Initialize(); 
     192        } 
     193        else 
     194        { 
     195                box = entities[0]->GetWorldBoundingBox(); 
     196 
     197                for (int i = 1; i < numEntities; ++ i) 
     198                { 
     199                        box.Include(entities[i]->GetWorldBoundingBox()); 
     200                } 
     201        } 
     202 
     203        return box; 
     204} 
     205 
     206 
     207AxisAlignedBox3 SceneEntity::ComputeBoundingBox(const SceneEntityContainer &entities) 
     208{ 
     209        AxisAlignedBox3 box; 
     210         
     211        if (!entities.empty()) 
     212        {       // no box => just initialize 
     213                box.Initialize(); 
     214        } 
     215        else 
     216        { 
     217                box = entities[0]->GetWorldBoundingBox(); 
     218 
     219                for (size_t i = 1; i < entities.size(); ++ i) 
     220                { 
     221                        box.Include(entities[i]->GetWorldBoundingBox()); 
     222                } 
     223        } 
     224 
     225        return box; 
     226} 
     227 
     228 
     229 
     230 
     231} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneEntity.h

    r3260 r3262  
    122122        */ 
    123123        static int GetCurrentVisibleId(); 
     124 
     125        static AxisAlignedBox3 ComputeBoundingBox(SceneEntity **entities, int numEntities); 
     126        static AxisAlignedBox3 ComputeBoundingBox(const SceneEntityContainer &entities); 
    124127 
    125128 
Note: See TracChangeset for help on using the changeset viewer.