Ignore:
Timestamp:
07/17/08 17:21:39 (16 years ago)
Author:
mattausch
Message:

lod starting to work

File:
1 edited

Legend:

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

    r2842 r2844  
    1010#include "Transform3.h" 
    1111#include "Shape.h" 
     12#include "LODInfo.h" 
    1213 
    1314 
     
    3334SceneEntity *ResourceManager::LoadSceneEntity(igzstream &str) 
    3435{        
    35         // shape 
    36         int shapeId; 
    37         str.read(reinterpret_cast<char *>(&shapeId), sizeof(int)); 
    38  
    39         Geometry *geom = mGeometryTable[shapeId]; 
    40         Material *mat = mMaterialTable[shapeId]; 
    41  
    42  
    4336        bool hasTrafo; 
    4437        str.read(reinterpret_cast<char *>(&hasTrafo), sizeof(bool)); 
     
    6053        Transform3 *trafo = new Transform3(m); 
    6154        mTrafos.push_back(trafo); 
    62          
    63         // use instancing 
     55 
    6456        sceneGeom = new SceneEntity(trafo); 
    6557 
    66         // create shape 
    67         Shape *shape = new Shape(geom, mat, sceneGeom); 
    68         mShapes.push_back(shape); 
    69  
    70         sceneGeom->AddShape(shape); 
     58        /////////////// 
     59        //-- load lod levels 
     60 
     61        int numLODs; 
     62        str.read(reinterpret_cast<char *>(&numLODs), sizeof(int)); 
     63 
     64        //if (numLODs > 1) cout << "numlods: " << numLODs << endl; 
     65        for (int i = 0; i < numLODs; ++ i) 
     66        { 
     67                float distance; 
     68                str.read(reinterpret_cast<char *>(&distance), sizeof(float)); 
     69 
     70                int numShapes; 
     71                str.read(reinterpret_cast<char *>(&numShapes), sizeof(int)); 
     72 
     73                //if (numLODs > 1) cout << "dist: " << distance << " shapes: " << numShapes; 
     74 
     75                LODLevel *lodLevel = new LODLevel(distance); 
     76 
     77                for (int j = 0; j < numShapes; ++ j) 
     78                { 
     79                        int shapeId; 
     80                        str.read(reinterpret_cast<char *>(&shapeId), sizeof(int)); 
     81 
     82                        //if (numLODs > 1) cout << " id " << shapeId; 
     83                         
     84                        Geometry *geom = mGeometryTable[shapeId]; 
     85                        Material *mat = mMaterialTable[shapeId]; 
     86 
     87                        // create shape 
     88                        Shape *shape = new Shape(geom, mat, sceneGeom); 
     89                         
     90                        mShapes.push_back(shape); 
     91 
     92                        sceneGeom->AddShape(shape); 
     93                        lodLevel->mShapes.push_back(shape); 
     94                } 
     95 
     96                //if (numLODs > 1) cout << endl; 
     97 
     98                sceneGeom->AddLODLevel(lodLevel); 
     99        } 
    71100 
    72101        return sceneGeom; 
     
    90119                str.read(texname, sizeof(char) * texnameSize); 
    91120 
    92                 //cout << "loading texture " << texname << " with len " << texnameSize << " id: " << id << endl; 
    93121                Texture *tex = new Texture(model_path + texname); 
    94122 
     
    135163         
    136164        str.read(reinterpret_cast<char *>(&mat->mAlphaTestEnabled), sizeof(bool)); 
     165 
     166        //str.read(reinterpret_cast<char *>(&mat->mCullFaceEnabled), sizeof(bool)); 
    137167 
    138168        // material 
Note: See TracChangeset for help on using the changeset viewer.