Ignore:
Timestamp:
05/19/09 19:17:41 (15 years ago)
Author:
mattausch
Message:

reverted but now a good version

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/ObjConverter.cpp

    r3371 r3372  
    168168        geom->mMaterial = mat; 
    169169 
    170         static int count = 0; 
    171         if (count ++ < 10) 
    172170        cout << "creating new geometry with " << numElements << " vertices" << endl; 
    173171 
     
    206204 
    207205 
    208 bool ObjConverter::Convert(const string &filename,  
    209                                                    const std::string &outputFilename) 
     206bool ObjConverter::Convert(const string &filename, const std::string &outputFilename) 
    210207{ 
    211208        mNumShapes = 0; 
     
    361358                str.write(reinterpret_cast<char *>(geom->mTexcoords), sizeof(float) * texCoordCount * 2); 
    362359         
     360 
     361        /////// 
     362        //-- texture 
     363/* 
     364#ifdef USE_TEXTURE 
     365        int texId = 0; 
     366#else 
     367        int texId = -1; 
     368#endif 
     369 
     370        str.write(reinterpret_cast<char *>(&texId), sizeof(int)); 
     371 
     372        bool alphaTestEnabled = false; 
     373        //bool cullFaceEnabled = false; 
     374        bool cullFaceEnabled = true; 
     375 
     376        str.write(reinterpret_cast<char *>(&alphaTestEnabled), sizeof(bool)); 
     377        str.write(reinterpret_cast<char *>(&cullFaceEnabled), sizeof(bool)); 
     378 
     379        // material 
     380        bool hasMaterial = true; 
     381        //bool hasMaterial = false; 
     382        str.write(reinterpret_cast<char *>(&hasMaterial), sizeof(bool)); 
     383         
     384        if (hasMaterial) 
     385        { 
     386                SimpleVec ambient, diffuse, spec, emm; 
     387 
     388                ambient.x = ambient.y = ambient.z = 0.2f; 
     389                //diffuse.x = diffuse.y = diffuse.z = 1.0f; 
     390                diffuse.x = 0.7f; diffuse.y = 0.5f; diffuse.z = 0.2f; 
     391                spec.x    = spec.y    = spec.z    =  .0f; 
     392                emm = spec; 
     393 
     394                // only write rgb part of the material 
     395                str.write(reinterpret_cast<char *>(&ambient), sizeof(SimpleVec)); 
     396                str.write(reinterpret_cast<char *>(&diffuse), sizeof(SimpleVec)); 
     397                str.write(reinterpret_cast<char *>(&spec), sizeof(SimpleVec)); 
     398                str.write(reinterpret_cast<char *>(&emm), sizeof(SimpleVec)); 
     399        } 
     400*/ 
    363401} 
    364402 
     
    369407        ogzstream ofile(filename.c_str()); 
    370408 
    371         if (!ofile.is_open()) return false; 
     409        if (!ofile.is_open()) 
     410                return false; 
    372411         
    373412 
     
    409448        { 
    410449                WriteGeometry(ofile, *it); 
    411  
    412                 int texId = 0; 
    413                 ofile.write(reinterpret_cast<char *>(&texId), sizeof(int)); 
    414  
    415                 bool alphaTestEnabled = false; 
    416                 //bool cullFaceEnabled = false; 
    417                 bool cullFaceEnabled = true; 
    418  
    419                 ofile.write(reinterpret_cast<char *>(&alphaTestEnabled), sizeof(bool)); 
    420                 ofile.write(reinterpret_cast<char *>(&cullFaceEnabled), sizeof(bool)); 
    421  
    422                 // material 
    423                 bool hasMaterial = true; 
    424                 ofile.write(reinterpret_cast<char *>(&hasMaterial), sizeof(bool)); 
    425  
    426                 if (hasMaterial) 
    427                 { 
    428                         SimpleVec ambient, diffuse, spec, emm; 
    429  
    430                         ambient.x = ambient.y = ambient.z =  .2f; 
    431                         diffuse.x = diffuse.y = diffuse.z = 1.0f; 
    432                         spec.x    = spec.y    = spec.z    =  .0f; 
    433                         emm = spec; 
    434  
    435                         // only write rgb part of the material 
    436                         ofile.write(reinterpret_cast<char *>(&ambient), sizeof(SimpleVec)); 
    437                         ofile.write(reinterpret_cast<char *>(&diffuse), sizeof(SimpleVec)); 
    438                         ofile.write(reinterpret_cast<char *>(&spec), sizeof(SimpleVec)); 
    439                         ofile.write(reinterpret_cast<char *>(&emm), sizeof(SimpleVec)); 
    440                 } 
    441         } 
     450        } 
     451 
     452        int texId = 0; 
     453        ofile.write(reinterpret_cast<char *>(&texId), sizeof(int)); 
     454 
     455        bool alphaTestEnabled = false; 
     456        //bool cullFaceEnabled = false; 
     457        bool cullFaceEnabled = true; 
     458                 
     459        ofile.write(reinterpret_cast<char *>(&alphaTestEnabled), sizeof(bool)); 
     460        ofile.write(reinterpret_cast<char *>(&cullFaceEnabled), sizeof(bool)); 
     461 
     462        // material 
     463        bool hasMaterial = true; 
     464        ofile.write(reinterpret_cast<char *>(&hasMaterial), sizeof(bool)); 
     465         
     466        SimpleVec ambient, diffuse, spec, emm; 
     467 
     468        ambient.x = ambient.y = ambient.z = 0.2f; 
     469        diffuse.x = diffuse.y = diffuse.z = 1.0f; 
     470        spec.x = spec.y = spec.z = .0f; 
     471        emm = spec; 
     472 
     473        // only write rgb part of the material 
     474        ofile.write(reinterpret_cast<char *>(&ambient), sizeof(SimpleVec)); 
     475        ofile.write(reinterpret_cast<char *>(&diffuse), sizeof(SimpleVec)); 
     476        ofile.write(reinterpret_cast<char *>(&spec), sizeof(SimpleVec)); 
     477        ofile.write(reinterpret_cast<char *>(&emm), sizeof(SimpleVec)); 
     478 
    442479 
    443480        int entityCount = 1; 
Note: See TracChangeset for help on using the changeset viewer.