Ignore:
Timestamp:
01/09/09 19:50:56 (16 years ago)
Author:
mattausch
Message:

worked on powerplant loading

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  
    3030        { 
    3131                string s(pch); 
    32                 //s += "\n", 
    3332                triples.push_back(s); 
    3433                 
     
    104103                        if (!normals.empty()) 
    105104                        { 
    106                                 //if (dummy < 3) cout << nIndices[idx1] << " " << nIndices[idx2] << " " << nIndices[idx3] << endl; 
    107105                                faceNormals.push_back(normals[nIndices[idx1]]); 
    108106                                faceNormals.push_back(normals[nIndices[idx2]]); 
     
    140138{ 
    141139        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  
    147140                delete mGeometry[i]; 
    148         } 
    149141         
    150142        mGeometry.clear(); 
     
    211203         
    212204        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  
    218205                delete mGeometry[i]; 
    219         } 
    220206         
    221207        mGeometry.clear(); 
     
    306292                                        ++ mNumShapes; 
    307293 
     294                                        if (!currentMat) cout << "here3" << endl; 
    308295                                        LoadShape(faceVertices, faceNormals, faceTexcoords, currentMat); 
    309296 
     
    323310 
    324311                                currentMat = mMaterialTable[matName]; 
    325                                 cout << "matname: " << matName << endl; 
     312                                //cout << "matname: " << matName << endl; 
    326313                        } 
    327314 
     
    538525                Material *mat = (*it)->mMaterial; 
    539526 
     527                if (!mat) cerr << "error: no material specified!!" << endl; 
     528 
    540529                ofile.write(reinterpret_cast<char *>(&mat->texture), sizeof(int)); 
    541530 
     
    628617                { 
    629618                        string s(pch); 
    630                         //s += "\n", 
    631619                        strings.push_back(s); 
    632620 
     
    634622                } 
    635623 
    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)) 
    640625                { 
    641626                        currentMat = new Material(); 
     
    643628                } 
    644629 
    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)) 
    646631                { 
    647632                        TextureTable::const_iterator it = mTextureTable.find(strings[1]); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.h

    r3247 r3261  
    1515 
    1616class Geometry; 
     17 
     18static std::string model_path("data/city/model/"); 
     19 
    1720 
    1821typedef std::vector<SimpleVec> VertexArray; 
     
    3740                     // const std::string textureFilename) const; 
    3841 
    39         bool LoadMaterials(const std::string &matFileName); 
     42        bool LoadMaterials(const std::string &mtlFilename); 
    4043 
    4144        ~ObjConverter(); 
     
    4548        struct Geometry 
    4649        { 
     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 
    4766                SimpleVec *mVertices; 
    4867                SimpleVec *mNormals; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp

    r3247 r3261  
    1 #include "ObjConverter.h" 
     1#include "ObjConverter2.h" 
    22#include <iostream> 
    33#include <time.h> 
     
    55using namespace std; 
    66 
    7 static string model_path("data/city/model/"); 
    87 
    98int main(int argc, char* argv[]) 
     
    1110        int returnCode = 0; 
    1211 
    13         ObjConverter converter; 
     12        ObjConverter2 converter; 
    1413 
    1514        cout << "converting obj to dem format" << endl; 
    16          
     15#if 0    
    1716        if (!converter.LoadMaterials(model_path + argv[3])) 
    1817        { 
     
    3029                exit(0); 
    3130        } 
     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 
    3254 
    3355        cout << "conversion successful" << endl; 
    34         cout << "press any key" << std::cin.get(); 
     56        //cout << "press any key" << std::cin.get(); 
    3557 
    3658        return 0; 
Note: See TracChangeset for help on using the changeset viewer.