Changeset 3277
- Timestamp:
- 01/15/09 04:52:43 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter.vcproj
r3272 r3277 154 154 AdditionalLibraryDirectories="libs\Zlib\lib; lib\$(ConfigurationName)" 155 155 IgnoreDefaultLibraryNames="libCMT" 156 GenerateDebugInformation=" true"156 GenerateDebugInformation="false" 157 157 SubSystem="1" 158 158 LargeAddressAware="2" -
GTP/trunk/App/Demos/Vis/FriendlyCulling/VisibilitySolutionConverter/VisibilitySolutionConverter.cpp
r3274 r3277 231 231 232 232 //if (!LoadSolution(bvhInputFilename)) 233 if (!LoadSolution Test(bvhInputFilename))233 if (!LoadSolution(bvhInputFilename)) 234 234 { 235 235 cerr << "could not read solution file" << endl; … … 270 270 bool VisibilitySolutionConverter::ReadScene(const string &filename) 271 271 { 272 /* 272 273 VertexArray vertices; 273 274 VertexArray normals; … … 278 279 ConstructBvhObjects(vertices, normals, texCoords); 279 280 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 */ 281 294 282 295 return false; … … 417 430 418 431 bool alphaTestEnabled = false; 419 //bool cullFaceEnabled = true;420 bool cullFaceEnabled = false;432 bool cullFaceEnabled = true; 433 //bool cullFaceEnabled = false; 421 434 422 435 str.write(reinterpret_cast<char *>(&alphaTestEnabled), sizeof(bool)); … … 929 942 return true; 930 943 } 944 945 946 bool 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 1003 void 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 15 15 16 16 class ogzstream; 17 18 17 struct BvhInterior; 19 18 … … 140 139 141 140 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 142 148 ////////////////////////////////// 143 149 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env
r3276 r3277 9 9 #filename=vienna_full_hp 10 10 #bvhname=vienna_full_hp 11 #filename=newvienna 12 #bvhname=newvienna 13 filename=pompeii/pompeii_full 11 filename=tryvienna 12 bvhname=tryvienna 13 filename=mypompeii 14 bvhname=mypompeii 15 #filename=pompeii/pompeii_full 14 16 #filename=pompeii/pompeii_part 15 filename=city16 bvhname=city17 #filename=city 18 #bvhname=city 17 19 useLODs=1 18 20 # shadow map size … … 29 31 30 32 # if using pvs, this specifies the name of the visibility solutin 31 visibilitySolution=vienna_full-8x3-pgv 33 #visibilitySolution=vienna_full-8x3-pgv 34 visibilitySolution=mypompeii-1x1-pgv 35 32 36 viewCellsScaleFactor=1.0f 33 37 useSkylightForIllum=1 … … 58 62 camPosition=483.398f 242.364f 186.078f 59 63 # pompeii view point 60 #camPosition=1300.0f -2500.0f 10.0f64 camPosition=1300.0f -2500.0f 10.0f 61 65 # pompeii problematic 62 66 #camPosition=627.003 -1725.33 25.2 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3276 r3277 599 599 //LoadModel("sibenik.dem", dynamicObjects); 600 600 601 if ( 1) LoadPompeiiScene();601 if (0) LoadPompeiiScene(); 602 602 603 603 #if 0
Note: See TracChangeset
for help on using the changeset viewer.