Changeset 3277 for GTP


Ignore:
Timestamp:
01/15/09 04:52:43 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
5 edited

Legend:

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

    r3272 r3277  
    154154                                AdditionalLibraryDirectories="libs\Zlib\lib; lib\$(ConfigurationName)" 
    155155                                IgnoreDefaultLibraryNames="libCMT" 
    156                                 GenerateDebugInformation="true" 
     156                                GenerateDebugInformation="false" 
    157157                                SubSystem="1" 
    158158                                LargeAddressAware="2" 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp

    r3274 r3277  
    231231 
    232232        //if (!LoadSolution(bvhInputFilename)) 
    233         if (!LoadSolutionTest(bvhInputFilename)) 
     233        if (!LoadSolution(bvhInputFilename)) 
    234234        { 
    235235                cerr << "could not read solution file" << endl; 
     
    270270bool VisibilitySolutionConverter::ReadScene(const string &filename) 
    271271{ 
     272        /* 
    272273        VertexArray vertices; 
    273274        VertexArray normals; 
     
    278279                ConstructBvhObjects(vertices, normals, texCoords); 
    279280                return true; 
    280         } 
     281        }*/ 
     282 
     283        vector<CHCDemoEngine::Triangle3 *> triangles; 
     284 
     285        if (ReadObjSimple(filename, triangles))  
     286        { 
     287                ConstructBvhObjects2(triangles); 
     288                return true; 
     289        } 
     290 
     291        /*for (size_t i = 0; i < triangles.size(); ++ i) 
     292        delete triangles[i]; 
     293        */ 
    281294 
    282295        return false; 
     
    417430 
    418431        bool alphaTestEnabled = false; 
    419         //bool cullFaceEnabled = true; 
    420         bool cullFaceEnabled = false; 
     432        bool cullFaceEnabled = true; 
     433        //bool cullFaceEnabled = false; 
    421434 
    422435        str.write(reinterpret_cast<char *>(&alphaTestEnabled), sizeof(bool)); 
     
    929942        return true; 
    930943} 
     944 
     945 
     946bool VisibilitySolutionConverter::ReadObjSimple(const string &filename, 
     947                                                                                                vector<CHCDemoEngine::Triangle3 *> &triangles 
     948                                                                                                )  
     949{ 
     950        FILE *file; 
     951 
     952        if ((file = fopen(filename.c_str(), "r")) == NULL) return false; 
     953         
     954        VertexArray vertices; 
     955 
     956        int line = 0; 
     957        const int len = 10000; 
     958        char str[len]; 
     959 
     960        const string binFilename = ReplaceSuffix(filename, ".obj", ".bn"); 
     961 
     962        cout << "binary dump " << binFilename << " not available, loading ascii obj" << endl; 
     963 
     964        while (fgets(str, len, file) != NULL) 
     965        { 
     966                if (line % 500000 == 0) 
     967                        cout << line << " " << str; 
     968 
     969                ++ line; 
     970 
     971                switch (str[0]) 
     972                { 
     973                case 'v': // vertex or normal 
     974                        { 
     975                                float x, y, z; 
     976 
     977                                sscanf(str + 1, "%f %f %f", &x, &y, &z); 
     978                                CHCDemoEngine::Vector3 v = CHCDemoEngine::Vector3(x, -z, y) * sScale; 
     979                                vertices.push_back(v); 
     980 
     981                                if (vertices.size() == 3) 
     982                                { 
     983                                        CHCDemoEngine::Triangle3 *tri =  
     984                                                new CHCDemoEngine::Triangle3(vertices[0], vertices[1], vertices[2]); 
     985 
     986                                        triangles.push_back(tri); 
     987                                        vertices.clear(); 
     988                                } 
     989                                break; 
     990                        } 
     991                default: 
     992                        // throw away line 
     993                        break; 
     994                } 
     995        } 
     996 
     997        fclose(file); 
     998 
     999        return !triangles.empty(); 
     1000} 
     1001 
     1002 
     1003void VisibilitySolutionConverter::ConstructBvhObjects2(const vector<CHCDemoEngine::Triangle3 *> &triangles) 
     1004{ 
     1005        CHCDemoEngine::AxisAlignedBox3 testBox; 
     1006        testBox.Initialize(); 
     1007 
     1008        for (size_t i = 0; i < triangles.size(); ++ i) 
     1009        { 
     1010                testBox.Include(triangles[i]->mVertices[0]); 
     1011                testBox.Include(triangles[i]->mVertices[1]); 
     1012                testBox.Include(triangles[i]->mVertices[2]); 
     1013        } 
     1014 
     1015        cout << "geometry bounds: " << testBox << endl; 
     1016 
     1017        mGeometry.reserve(mBvhLeaves.size()); 
     1018        mNumShapes = (int)mBvhLeaves.size(); 
     1019 
     1020        VertexArray _vertices;   
     1021        VertexArray _normals; 
     1022        vector<TexCoord> _texCoords; 
     1023 
     1024        int total = 0; 
     1025        for (size_t i = 0; i < mBvhLeaves.size(); ++ i) 
     1026        { 
     1027                BvhLeaf *node = mBvhLeaves[i]; 
     1028                const int size = node->last - node->first + 1; 
     1029 
     1030                total += size; 
     1031 
     1032                if (i % 1000 == 0) 
     1033                        cout << "o " << i << " " << size << " " << total << endl; 
     1034 
     1035                _vertices.clear(); 
     1036                _normals.clear(); 
     1037                _texCoords.clear(); 
     1038 
     1039                //cout << "vtx: " << size << endl; 
     1040                for (int j = node->first; j <= node->last; ++ j) 
     1041                { 
     1042                        const int idx = mGlobalTriangleIds[j]; 
     1043 
     1044                        //cout << "idx: " << 3 * mGlobalTriangleIds[j] << " j " << j << " " << vertices.size()<< endl; 
     1045                        for (int k = 0; k < 3; ++ k) 
     1046                        { 
     1047                                _vertices.push_back(triangles[idx]->mVertices[k]); 
     1048                        } 
     1049 
     1050                        const CHCDemoEngine::Vector3 n = triangles[idx]->GetNormal(); 
     1051 
     1052                        _normals.push_back(n); 
     1053                        _normals.push_back(n); 
     1054                        _normals.push_back(n); 
     1055 
     1056                        delete triangles[idx]; 
     1057                } 
     1058 
     1059                LoadShape(_vertices, _normals, _texCoords); 
     1060                 
     1061                // we store geometry in our bvh => change first and last pointer 
     1062                // from triangles to geometry 
     1063                node->first = (int)mGeometry.size() - 1; 
     1064                node->last = (int)mGeometry.size() - 1; 
     1065 
     1066                //_vertices.clear(); 
     1067                //_normals.clear(); 
     1068                //_texCoords.clear(); 
     1069        } 
     1070} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.h

    r3272 r3277  
    1515 
    1616class ogzstream; 
    17  
    1817struct BvhInterior; 
    1918 
     
    140139 
    141140 
     141        bool ReadObjSimple(const std::string &filename, 
     142                std::vector<CHCDemoEngine::Triangle3 *> &triangles); 
     143 
     144        void ConstructBvhObjects2(const std::vector<CHCDemoEngine::Triangle3 *> &triangles); 
     145 
     146 
     147 
    142148        ////////////////////////////////// 
    143149 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env

    r3276 r3277  
    99#filename=vienna_full_hp 
    1010#bvhname=vienna_full_hp 
    11 #filename=newvienna 
    12 #bvhname=newvienna 
    13 filename=pompeii/pompeii_full 
     11filename=tryvienna 
     12bvhname=tryvienna 
     13filename=mypompeii 
     14bvhname=mypompeii 
     15#filename=pompeii/pompeii_full 
    1416#filename=pompeii/pompeii_part 
    15 filename=city 
    16 bvhname=city 
     17#filename=city 
     18#bvhname=city 
    1719useLODs=1 
    1820# shadow map size 
     
    2931 
    3032# if using pvs, this specifies the name of the visibility solutin 
    31 visibilitySolution=vienna_full-8x3-pgv 
     33#visibilitySolution=vienna_full-8x3-pgv 
     34visibilitySolution=mypompeii-1x1-pgv 
     35 
    3236viewCellsScaleFactor=1.0f 
    3337useSkylightForIllum=1 
     
    5862camPosition=483.398f 242.364f 186.078f 
    5963# pompeii view point 
    60 #camPosition=1300.0f -2500.0f 10.0f 
     64camPosition=1300.0f -2500.0f 10.0f 
    6165# pompeii problematic 
    6266#camPosition=627.003 -1725.33 25.2 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3276 r3277  
    599599        //LoadModel("sibenik.dem", dynamicObjects); 
    600600 
    601         if (1) LoadPompeiiScene(); 
     601        if (0) LoadPompeiiScene(); 
    602602 
    603603#if 0 
Note: See TracChangeset for help on using the changeset viewer.