Changeset 3261 for GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter
- Timestamp:
- 01/09/09 19:50:56 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter
- Files:
-
- 2 added
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp
r3260 r3261 30 30 { 31 31 string s(pch); 32 //s += "\n",33 32 triples.push_back(s); 34 33 … … 104 103 if (!normals.empty()) 105 104 { 106 //if (dummy < 3) cout << nIndices[idx1] << " " << nIndices[idx2] << " " << nIndices[idx3] << endl;107 105 faceNormals.push_back(normals[nIndices[idx1]]); 108 106 faceNormals.push_back(normals[nIndices[idx2]]); … … 140 138 { 141 139 for (size_t i = 0; i < mGeometry.size(); ++ i) 142 {143 delete [] mGeometry[i]->mVertices;144 delete [] mGeometry[i]->mNormals;145 delete [] mGeometry[i]->mTexcoords;146 147 140 delete mGeometry[i]; 148 }149 141 150 142 mGeometry.clear(); … … 211 203 212 204 for (size_t i = 0; i < mGeometry.size(); ++ i) 213 {214 delete [] mGeometry[i]->mVertices;215 delete [] mGeometry[i]->mNormals;216 delete [] mGeometry[i]->mTexcoords;217 218 205 delete mGeometry[i]; 219 }220 206 221 207 mGeometry.clear(); … … 306 292 ++ mNumShapes; 307 293 294 if (!currentMat) cout << "here3" << endl; 308 295 LoadShape(faceVertices, faceNormals, faceTexcoords, currentMat); 309 296 … … 323 310 324 311 currentMat = mMaterialTable[matName]; 325 cout << "matname: " << matName << endl;312 //cout << "matname: " << matName << endl; 326 313 } 327 314 … … 538 525 Material *mat = (*it)->mMaterial; 539 526 527 if (!mat) cerr << "error: no material specified!!" << endl; 528 540 529 ofile.write(reinterpret_cast<char *>(&mat->texture), sizeof(int)); 541 530 … … 628 617 { 629 618 string s(pch); 630 //s += "\n",631 619 strings.push_back(s); 632 620 … … 634 622 } 635 623 636 cout << endl; 637 638 639 if ((strings.size() == 2) && (strcmp(strings[0].c_str(),"newmtl") == 0)) 624 if ((strings.size() == 2) && (strcmp(strings[0].c_str(), "newmtl") == 0)) 640 625 { 641 626 currentMat = new Material(); … … 643 628 } 644 629 645 if ((strings.size() == 2) && (strcmp(strings[0].c_str(), "map_Kd") == 0))630 if ((strings.size() == 2) && (strcmp(strings[0].c_str(), "map_Kd") == 0)) 646 631 { 647 632 TextureTable::const_iterator it = mTextureTable.find(strings[1]); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.h
r3247 r3261 15 15 16 16 class Geometry; 17 18 static std::string model_path("data/city/model/"); 19 17 20 18 21 typedef std::vector<SimpleVec> VertexArray; … … 37 40 // const std::string textureFilename) const; 38 41 39 bool LoadMaterials(const std::string &m atFileName);42 bool LoadMaterials(const std::string &mtlFilename); 40 43 41 44 ~ObjConverter(); … … 45 48 struct Geometry 46 49 { 50 Geometry(): 51 mVertices(NULL), 52 mNormals(NULL), 53 mTexcoords(NULL), 54 mMaterial(NULL), 55 mVertexCount(0), 56 mTexcoordCount(0) 57 {} 58 59 ~Geometry() 60 { 61 delete [] mVertices; 62 delete [] mNormals; 63 delete [] mTexcoords; 64 } 65 47 66 SimpleVec *mVertices; 48 67 SimpleVec *mNormals; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp
r3247 r3261 1 #include "ObjConverter .h"1 #include "ObjConverter2.h" 2 2 #include <iostream> 3 3 #include <time.h> … … 5 5 using namespace std; 6 6 7 static string model_path("data/city/model/");8 7 9 8 int main(int argc, char* argv[]) … … 11 10 int returnCode = 0; 12 11 13 ObjConverter converter;12 ObjConverter2 converter; 14 13 15 14 cout << "converting obj to dem format" << endl; 16 15 #if 0 17 16 if (!converter.LoadMaterials(model_path + argv[3])) 18 17 { … … 30 29 exit(0); 31 30 } 31 #else 32 33 //const int numFiles = 879; 34 const int numFiles = 100; 35 36 vector<string> filenames; 37 const string base(model_path + argv[1]); 38 39 for (int i = 0; i < numFiles; ++ i) 40 { 41 char filename[100]; 42 sprintf(filename, "%s%s%d%s", base.c_str(), ".b", i, ".obj"); 43 filenames.push_back(filename); 44 } 45 46 if (!converter.Convert2(filenames, model_path + argv[2])) 47 { 48 cerr << "conversion failed" << endl; 49 50 std::cin.get(); 51 exit(0); 52 } 53 #endif 32 54 33 55 cout << "conversion successful" << endl; 34 cout << "press any key" << std::cin.get();56 //cout << "press any key" << std::cin.get(); 35 57 36 58 return 0;
Note: See TracChangeset
for help on using the changeset viewer.