Changeset 3236


Ignore:
Timestamp:
12/26/08 03:40:45 (15 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
5 edited

Legend:

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

    r3235 r3236  
    363363        str.write(reinterpret_cast<char *>(geom->mNormals), sizeof(SimpleVec) * vertexCount); 
    364364 
    365         int texCoordCount = geom->mTexcoordCount; 
     365        int texCoordCount = 0;//geom->mTexcoordCount; 
    366366        str.write(reinterpret_cast<char *>(&texCoordCount), sizeof(int)); 
    367367 
     
    374374        //-- texture 
    375375 
    376 #ifdef USE_TEXTURE 
    377         int texId = 0; 
    378 #else 
    379376        int texId = -1; 
    380 #endif 
    381  
    382377        str.write(reinterpret_cast<char *>(&texId), sizeof(int)); 
    383378 
    384379        bool alphaTestEnabled = false; 
    385         //bool cullFaceEnabled = false; 
    386380        bool cullFaceEnabled = true; 
    387381 
     
    391385        // material 
    392386        bool hasMaterial = true; 
    393         //bool hasMaterial = false; 
     387         
    394388        str.write(reinterpret_cast<char *>(&hasMaterial), sizeof(bool)); 
    395389         
     
    425419         
    426420 
    427         ///////// 
    428         //-- write textures 
    429  
    430 #ifdef USE_TEXTURE 
    431         int textureCount = 1; 
    432 #else 
    433421        int textureCount = 0; 
    434 #endif 
    435422        ofile.write(reinterpret_cast<char *>(&textureCount), sizeof(int)); 
    436  
    437         if (textureCount > 0) 
    438         { 
    439                 // hack 
    440                 const string texName("wood.jpg"); 
    441  
    442                 int texnameSize = (int)texName.length() + 1; 
    443                 ofile.write(reinterpret_cast<char *>(&texnameSize), sizeof(int)); 
    444  
    445                 ofile.write(texName.c_str(), sizeof(char) * texnameSize); 
    446  
    447                 int boundS = 1, boundT = 1; 
    448  
    449                 ofile.write(reinterpret_cast<char *>(&boundS), sizeof(int)); 
    450                 ofile.write(reinterpret_cast<char *>(&boundT), sizeof(int)); 
    451         } 
    452423 
    453424 
     
    455426        //-- write shapes 
    456427 
    457         ofile.write(reinterpret_cast<char *>(&mNumShapes), sizeof(int)); 
     428        int numShapes = (int)mGeometry.size(); 
     429        ofile.write(reinterpret_cast<char *>(&numShapes), sizeof(int)); 
    458430 
    459431        vector<Geometry *>::const_iterator it, it_end = mGeometry.end(); 
     
    465437 
    466438 
    467         int entityCount = 1; 
     439        int entityCount = numShapes; 
    468440        ofile.write(reinterpret_cast<char *>(&entityCount), sizeof(int)); 
    469441 
    470442 
    471443        ////////// 
    472         //-- write single scene entity 
    473  
    474         // no transformation 
    475         bool hasTrafo = false; 
    476         ofile.write(reinterpret_cast<char *>(&hasTrafo), sizeof(bool)); 
    477  
    478         // a dummy lod 
    479         int numLODs = 1; 
    480         ofile.write(reinterpret_cast<char *>(&numLODs), sizeof(int)); 
    481  
    482         float dist = 0; 
    483         ofile.write(reinterpret_cast<char *>(&dist), sizeof(float)); 
    484  
    485         ofile.write(reinterpret_cast<char *>(&mNumShapes), sizeof(int)); 
     444        //-- write single scene entity for each shape 
    486445 
    487446        // all shapes belong to this scene entity 
    488         for (int i = 0; i < mNumShapes; ++ i) 
    489         { 
     447        for (int i = 0; i < numShapes; ++ i) 
     448        { 
     449                // no transformation 
     450                bool hasTrafo = false; 
     451                ofile.write(reinterpret_cast<char *>(&hasTrafo), sizeof(bool)); 
     452 
     453                // a dummy lod 
     454                int numLODs = 1; 
     455                ofile.write(reinterpret_cast<char *>(&numLODs), sizeof(int)); 
     456 
     457                float dist = 0; 
     458                ofile.write(reinterpret_cast<char *>(&dist), sizeof(float)); 
     459 
     460                int shapesPerEnt = 1; 
     461                ofile.write(reinterpret_cast<char *>(&shapesPerEnt), sizeof(int)); 
     462 
    490463                int shapeId = i; 
    491464                ofile.write(reinterpret_cast<char *>(&shapeId), sizeof(int)); 
     
    501474{ 
    502475        cout << "vtx: " << vertices.size() << endl; 
    503 /*      BvhNode n; 
    504          
    505         mGlobalTriangleIds.clear(); 
    506         for (size_t i = 0; i < vertices.size() / 3; ++ i) 
    507         { 
    508                 mGlobalTriangleIds.push_back((int)i); 
    509         } 
    510  
    511         for (size_t i = 0; i < vertices.size() / 3; ++ i) 
    512                 n.mTriangleIds.push_back((int)i); 
    513  
    514         mBvhNodes.push_back(n); 
    515 */ 
     476 
    516477        for (size_t i = 0; i < mBvhNodes.size(); ++ i) 
    517478        { 
     
    540501                } 
    541502 
    542                 LoadShape(_vertices, _normals, _texCoords); 
     503                if (!_vertices.empty()) 
     504                { 
     505                        ++ mNumShapes; 
     506                        LoadShape(_vertices, _normals, _texCoords); 
     507                } 
    543508        } 
    544509} 
     
    547512bool VisibilitySolutionConverter::WriteBvh(const string &filename) 
    548513{ 
    549         ogzstream ofile(filename.c_str()); 
    550  
    551         if (!ofile.is_open()) 
    552                 return false; 
    553          
    554  
    555         ///////// 
    556         //-- write textures 
    557  
    558 #ifdef USE_TEXTURE 
    559         int textureCount = 1; 
    560 #else 
    561         int textureCount = 0; 
    562 #endif 
    563         ofile.write(reinterpret_cast<char *>(&textureCount), sizeof(int)); 
    564  
    565         if (textureCount > 0) 
    566         { 
    567                 // hack 
    568                 const string texName("wood.jpg"); 
    569  
    570                 int texnameSize = (int)texName.length() + 1; 
    571                 ofile.write(reinterpret_cast<char *>(&texnameSize), sizeof(int)); 
    572  
    573                 ofile.write(texName.c_str(), sizeof(char) * texnameSize); 
    574  
    575                 int boundS = 1, boundT = 1; 
    576  
    577                 ofile.write(reinterpret_cast<char *>(&boundS), sizeof(int)); 
    578                 ofile.write(reinterpret_cast<char *>(&boundT), sizeof(int)); 
    579         } 
    580  
    581  
    582         /////////// 
    583         //-- write shapes 
    584  
    585         ofile.write(reinterpret_cast<char *>(&mNumShapes), sizeof(int)); 
    586  
    587         vector<Geometry *>::const_iterator it, it_end = mGeometry.end(); 
    588  
    589         for (it = mGeometry.begin(); it != it_end; ++ it) 
    590         { 
    591                 WriteGeometry(ofile, *it); 
    592         } 
    593  
    594  
    595         int entityCount = 1; 
    596         ofile.write(reinterpret_cast<char *>(&entityCount), sizeof(int)); 
    597  
    598  
    599         ////////// 
    600         //-- write single scene entity 
    601  
    602         // no transformation 
    603         bool hasTrafo = false; 
    604         ofile.write(reinterpret_cast<char *>(&hasTrafo), sizeof(bool)); 
    605  
    606         // a dummy lod 
    607         int numLODs = 1; 
    608         ofile.write(reinterpret_cast<char *>(&numLODs), sizeof(int)); 
    609  
    610         float dist = 0; 
    611         ofile.write(reinterpret_cast<char *>(&dist), sizeof(float)); 
    612  
    613         ofile.write(reinterpret_cast<char *>(&mNumShapes), sizeof(int)); 
    614  
    615         // all shapes belong to this scene entity 
    616         for (int i = 0; i < mNumShapes; ++ i) 
    617         { 
    618                 int shapeId = i; 
    619                 ofile.write(reinterpret_cast<char *>(&shapeId), sizeof(int)); 
    620         } 
    621  
     514         
    622515        return true; 
    623516} 
     
    648541                int id; 
    649542                fread(&id, sizeof(int), 1, fr); 
    650                 mGlobalTriangleIds[i] = id; 
     543                mGlobalTriangleIds.push_back(id); 
    651544                //triangles[i] = scene->triangles[id]; 
    652545        } 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp

    r3235 r3236  
    267267        mVboId = -1; 
    268268        // bound the maximal depth of the dynamic branch 
    269         mMaxDepthForDynamicBranch = 10; 
     269        mMaxDepthForDynamicBranch = 1; 
    270270} 
    271271 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp

    r3226 r3236  
    109109                        int shapeId; 
    110110                        str.read(reinterpret_cast<char *>(&shapeId), sizeof(int)); 
     111cout<<"x"; 
    111112 
    112113                        Geometry *geom = mGeometryTable[shapeId]; 
     114cout<<"y"; 
     115 
    113116                        Material *mat = mMaterialTable[shapeId]; 
    114  
     117cout<<"z"; 
    115118                        // create shape 
    116119                        Shape *shape = new Shape(geom, mat); 
     120cout<<"w"; 
     121 
    117122                        mShapes.push_back(shape); 
    118123 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Shape.cpp

    r3114 r3236  
    1515mGeometry(geometry),  
    1616mMaterial(mat) 
    17 { 
     17{       std::cout<<"i"; 
    1818        mCenter = GetBoundingBox().Center(); 
     19        std::cout<<"R"; 
    1920} 
    2021 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3235 r3236  
    578578 
    579579 
    580         //LoadModel("vienna_full_hp.dem", dynamicObjects); 
    581         //dynamicObjects.back()->GetTransform()->SetMatrix(transl); 
     580        LoadModel("vienna_full_hp.dem", dynamicObjects); 
     581        dynamicObjects.back()->GetTransform()->SetMatrix(transl); 
    582582 
    583583 
Note: See TracChangeset for help on using the changeset viewer.