Changeset 3012 for GTP/trunk/App/Demos
- Timestamp:
- 10/08/08 10:45:08 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling
- Files:
-
- 4 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter.vcproj
r2961 r3012 197 197 > 198 198 </File> 199 <File 200 RelativePath=".\Converter\SimpleTri.cpp" 201 > 202 </File> 203 <File 204 RelativePath=".\Converter\SimpleVec.cpp" 205 > 206 </File> 199 207 </Filter> 200 208 <Filter … … 211 219 > 212 220 </File> 221 <File 222 RelativePath=".\Converter\SimpleTri.h" 223 > 224 </File> 225 <File 226 RelativePath=".\Converter\SimpleVec.h" 227 > 228 </File> 213 229 </Filter> 214 230 </Files> -
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp
r2965 r3012 1 1 #include "ObjConverter.h" 2 #include "SimpleTri.h" 3 #include "SimpleVec.h" 2 4 #include "gzstream.h" 3 5 #include <iostream> … … 35 37 for (size_t i = 0; i < substrings.size(); ++ i) 36 38 { 37 // vertex, normal andtexture indices39 // vertex, normal, texture indices 38 40 char *str = strtok_s(substrings[i], "/", &next_token); 39 41 int index = (int)strtol(str, NULL, 10) - 1; … … 42 44 int nIndex = index; 43 45 44 /*str = strtok_s(substrings[i], "/", &next_token);45 int tIndex = (int)strtol(str, NULL, 10) - 1;46 47 46 str = strtok_s(substrings[i], "/", &next_token); 48 int nIndex = (int)strtol(str, NULL, 10) - 1; 49 */ 47 48 if (str != NULL) 49 { 50 int idx = (int)strtol(str, NULL, 10) - 1; 51 if (idx) tIndex = idx; 52 } 53 str = strtok_s(substrings[i], "/", &next_token); 54 55 if (str != NULL) 56 { 57 int idx = (int)strtol(str, NULL, 10) - 1; 58 if (idx) nIndex = idx; 59 } 60 50 61 // store indices 51 62 if (index >= 0) … … 59 70 if (indices.size() > 2) 60 71 { 61 #if 172 #if 0 62 73 int idx1 = 0; 63 74 int idx2 = (int)indices.size() - 2; … … 71 82 faceVertices.push_back(vertices[indices[idx2]]); 72 83 faceVertices.push_back(vertices[indices[idx3]]); 73 74 Vector3 dummy(1, 0, 0); 75 faceNormals.push_back(dummy); 76 faceNormals.push_back(dummy); 77 faceNormals.push_back(dummy); 78 79 /* 80 const Vector3 v2 = mVertices[2] - mVertices[1]; 81 Normalize(CrossProd(v2, v1)); 82 83 faceNormals.push_back(normals[nIndices[idx1]]); 84 faceNormals.push_back(normals[nIndices[idx2]]); 85 faceNormals.push_back(normals[nIndices[idx3]]); 86 87 faceTexcoords.push_back(texcoords[tIndices[idx1]]); 88 faceTexcoords.push_back(texcoords[tIndices[idx2]]); 89 faceTexcoords.push_back(texcoords[tIndices[idx3]]); 90 */ 84 85 if (!normals.empty()) 86 { 87 faceNormals.push_back(normals[nIndices[idx1]]); 88 faceNormals.push_back(normals[nIndices[idx2]]); 89 faceNormals.push_back(normals[nIndices[idx3]]); 90 } 91 else 92 { 93 // no face normals? 94 const SimpleTri tri(vertices[indices[idx1]], vertices[indices[idx2]], vertices[indices[idx3]]); 95 const SimpleVec n = tri.GetNormal(); 96 97 faceNormals.push_back(n); 98 faceNormals.push_back(n); 99 faceNormals.push_back(n); 100 } 101 102 if (!texcoords.empty()) 103 { 104 faceTexcoords.push_back(texcoords[tIndices[idx1]]); 105 faceTexcoords.push_back(texcoords[tIndices[idx2]]); 106 faceTexcoords.push_back(texcoords[tIndices[idx3]]); 107 } 91 108 } 92 109 } … … 121 138 122 139 // convert the triangles to geometry 123 geom->mVertices = new Vector3[numElements];124 geom->mNormals = new Vector3[numElements];140 geom->mVertices = new SimpleVec[numElements]; 141 geom->mNormals = new SimpleVec[numElements]; 125 142 geom->mTexcoords = new Texcoord[numElements]; 126 143 … … 132 149 for (int i = 0; i < numElements; ++ i) 133 150 { 151 #if 0 134 152 geom->mVertices[i].x = faceVertices[i].x; 135 153 geom->mVertices[i].y = -faceVertices[i].z; 136 154 geom->mVertices[i].z = faceVertices[i].y; 137 155 138 156 geom->mNormals[i].x = faceNormals[i].x; 139 157 geom->mNormals[i].y = -faceNormals[i].z; 140 158 geom->mNormals[i].z = faceNormals[i].y; 141 159 #else 160 geom->mVertices[i].x = faceVertices[i].x; 161 geom->mVertices[i].y = faceVertices[i].y; 162 geom->mVertices[i].z = faceVertices[i].z; 163 164 geom->mNormals[i].x = faceNormals[i].x; 165 geom->mNormals[i].y = faceNormals[i].y; 166 geom->mNormals[i].z = faceNormals[i].z; 167 168 #endif 142 169 if (i < geom->mTexcoordCount) 143 170 { … … 220 247 case 'n' : 221 248 sscanf(str + 2, "%f %f %f", &x, &y, &z); 222 normals.push_back( Vector3(x, y, z));249 normals.push_back(SimpleVec(x, y, z)); 223 250 break; 224 251 case 't': … … 228 255 default: 229 256 sscanf(str + 1, "%f %f %f", &x, &y, &z); 230 vertices.push_back( Vector3(x, y, z));257 vertices.push_back(SimpleVec(x, y, z)); 231 258 //cout <<"v " << x << " " << y << " "<< z << " "; 232 259 } … … 242 269 faceVertices, faceNormals, faceTexcoords); 243 270 244 if ( ((line % 1000) == 999) &&245 !faceVertices.empty())271 if (0 && 272 (((line % 1000) == 999) && !faceVertices.empty())) 246 273 { 247 274 ++ mNumShapes; … … 299 326 str.write(reinterpret_cast<char *>(&vertexCount), sizeof(int)); 300 327 301 str.write(reinterpret_cast<char *>(geom->mVertices), sizeof( Vector3) * vertexCount);302 str.write(reinterpret_cast<char *>(geom->mNormals), sizeof( Vector3) * vertexCount);328 str.write(reinterpret_cast<char *>(geom->mVertices), sizeof(SimpleVec) * vertexCount); 329 str.write(reinterpret_cast<char *>(geom->mNormals), sizeof(SimpleVec) * vertexCount); 303 330 304 331 int texCoordCount = geom->mTexcoordCount; … … 330 357 if (hasMaterial) 331 358 { 332 Vector3ambient, diffuse, black;359 SimpleVec ambient, diffuse, black; 333 360 334 361 ambient.x = ambient.y = ambient.z = 0.2f; … … 337 364 338 365 // only write rgb part of the material 339 str.write(reinterpret_cast<char *>(&ambient), sizeof( Vector3));340 str.write(reinterpret_cast<char *>(&diffuse), sizeof( Vector3));341 str.write(reinterpret_cast<char *>(&black), sizeof( Vector3));342 str.write(reinterpret_cast<char *>(&black), sizeof( Vector3));366 str.write(reinterpret_cast<char *>(&ambient), sizeof(SimpleVec)); 367 str.write(reinterpret_cast<char *>(&diffuse), sizeof(SimpleVec)); 368 str.write(reinterpret_cast<char *>(&black), sizeof(SimpleVec)); 369 str.write(reinterpret_cast<char *>(&black), sizeof(SimpleVec)); 343 370 } 344 371 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.h
r2961 r3012 2 2 #define _OBJCONVERTER_H 3 3 4 #include "SimpleVec.h" 4 5 #include <string> 5 6 #include <vector> 6 7 7 struct Vector3 8 /*struct SimpleVec 8 9 { 9 Vector3() {}10 Vector3(float _x, float _y, float _z): x(_x), y(_y), z(_z) {}10 SimpleVec() {} 11 SimpleVec(float _x, float _y, float _z): x(_x), y(_y), z(_z) {} 11 12 12 13 float x, y, z; 13 }; 14 };*/ 14 15 15 typedef std::vector< Vector3> VertexArray;16 typedef std::vector<SimpleVec> VertexArray; 16 17 typedef std::pair<float, float> Texcoord; 17 18 … … 36 37 struct Geometry 37 38 { 38 Vector3*mVertices;39 Vector3*mNormals;39 SimpleVec *mVertices; 40 SimpleVec *mNormals; 40 41 Texcoord *mTexcoords; 41 42 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp
r2963 r3012 15 15 cout << "converting obj to dem format" << endl; 16 16 17 /*if (!converter.Convert(model_path + argv[1], model_path + argv[2]))17 if (!converter.Convert(model_path + argv[1], model_path + argv[2])) 18 18 { 19 19 cerr << "conversion failed" << endl; 20 20 exit(0); 21 21 } 22 */23 //if (!converter.Convert(model_path + "toyplane.obj", model_path + "toyplane.dem"))24 // cerr << "conversion failed" << endl;25 26 //if (!converter.Convert(model_path + "sky.obj", model_path + "sky.dem"))27 // cerr << "conversion failed" << endl;28 29 if (!converter.Convert(model_path + "city_full.obj", model_path + "city_full.dem"))30 cerr << "conversion failed" << endl;31 22 32 23 cout << "conversion successful" << endl; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/FriendlyCulling.sln
r3010 r3012 6 6 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Converter", "Converter.vcproj", "{93A522E1-76F0-4D46-9C97-30DC2DDB531D}" 7 7 EndProject 8 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = " FriendlyCulling", "MainApp.vcproj", "{A564071F-D054-4556-883B-999D7F9CC58C}"8 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "MainApp", "MainApp.vcproj", "{A564071F-D054-4556-883B-999D7F9CC58C}" 9 9 ProjectSection(ProjectDependencies) = postProject 10 10 {03661866-4093-4B02-B26A-028EA91AF023} = {03661866-4093-4B02-B26A-028EA91AF023} 11 11 EndProjectSection 12 EndProject 13 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "IrradianceMapping", "IrradianceMapping.vcproj", "{91680C49-A358-48AE-A02C-66CB884B7D7F}" 12 14 EndProject 13 15 Global … … 29 31 {A564071F-D054-4556-883B-999D7F9CC58C}.Release|Win32.ActiveCfg = Release|Win32 30 32 {A564071F-D054-4556-883B-999D7F9CC58C}.Release|Win32.Build.0 = Release|Win32 33 {91680C49-A358-48AE-A02C-66CB884B7D7F}.Debug|Win32.ActiveCfg = Debug|Win32 34 {91680C49-A358-48AE-A02C-66CB884B7D7F}.Debug|Win32.Build.0 = Debug|Win32 35 {91680C49-A358-48AE-A02C-66CB884B7D7F}.Release|Win32.ActiveCfg = Release|Win32 36 {91680C49-A358-48AE-A02C-66CB884B7D7F}.Release|Win32.Build.0 = Release|Win32 31 37 EndGlobalSection 32 38 GlobalSection(SolutionProperties) = preSolution -
GTP/trunk/App/Demos/Vis/FriendlyCulling/MainApp.vcproj
r3011 r3012 3 3 ProjectType="Visual C++" 4 4 Version="8,00" 5 Name=" FriendlyCulling"5 Name="MainApp" 6 6 ProjectGUID="{A564071F-D054-4556-883B-999D7F9CC58C}" 7 7 RootNamespace="MainApp" … … 143 143 Name="VCLinkerTool" 144 144 AdditionalDependencies="DemoEngine.lib glut32.lib glew32s.lib glew32.lib DevIL.lib ILUT.lib zlib.lib cg.lib cgGL.lib" 145 OutputFile="$(OutDir)\FriendlyCulling.exe" 145 146 LinkIncremental="1" 146 147 AdditionalLibraryDirectories=""lib/$(ConfigurationName)";libs;"$(CG_LIB_PATH)";libs/GL;libs/Devil/lib;libs/Zlib/lib" -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3010 r3012 59 59 /// the renderable scene geometry 60 60 SceneEntityContainer sceneEntities; 61 SceneEntityContainer sceneEntities2; 62 61 63 // traverses and renders the hierarchy 62 64 RenderTraverser *traverser = NULL; … … 440 442 loader = new ResourceManager(); 441 443 442 //const string filename("data/city/model/city.dem");443 444 const string filename = string(model_path + "city.dem"); 444 445 445 446 if (loader->Load(filename, sceneEntities)) 446 cout << " scene" << filename << " loaded" << endl;447 cout << "model " << filename << " loaded" << endl; 447 448 else 448 449 { 449 cerr << "loading scene" << filename << " failed" << endl;450 cerr << "loading model " << filename << " failed" << endl; 450 451 CleanUp(); 451 452 exit(0); … … 463 464 } 464 465 465 #if 0466 467 int merged = 0;468 469 SceneEntity *oldEnt = NULL;470 471 cout << "merging entities .. " << endl;472 SceneEntityContainer::const_iterator sit, sit_end = sceneEntities.end();473 474 for (sit = sceneEntities.begin(); sit < sit_end; ++ sit)475 {476 SceneEntity *newEnt = (*sit);477 478 if (!newEnt->GetTransform()->IsIdentity())479 {480 sceneEntities2.push_back(newEnt);481 continue;482 }483 484 if (oldEnt)485 {486 EntityMerger merger(newEnt, oldEnt);487 SceneEntity *ent = merger.Merge();488 489 sceneEntities2.push_back(ent);490 491 oldEnt = NULL;492 493 ++ merged;494 }495 else496 {497 oldEnt = newEnt;498 }499 }500 501 if (oldEnt && oldEnt->GetTransform()->IsIdentity())502 sceneEntities2.push_back(oldEnt);503 504 cout << "merged " << merged << " of " << (int)sceneEntities.size() << " entities " << endl;505 #endif506 466 507 467 // set far plane based on scene extent … … 1171 1131 // actually render the scene geometry using the specified algorithm 1172 1132 traverser->RenderScene(); 1173 //renderQueue->Apply();1174 1133 } 1175 1134
Note: See TracChangeset
for help on using the changeset viewer.