Changeset 2963


Ignore:
Timestamp:
09/22/08 10:10:01 (16 years ago)
Author:
mattausch
Message:

debug version trying to find out how to speed up app

Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
9 edited

Legend:

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

    r2961 r2963  
    4141                int index = (int)strtol(str, NULL, 10) - 1; 
    4242 
    43                 str = strtok_s(substrings[i], "/", &next_token);           
     43                int tIndex = index; 
     44                int nIndex = index; 
     45 
     46                /*str = strtok_s(substrings[i], "/", &next_token);         
    4447                int tIndex = (int)strtol(str, NULL, 10) - 1; 
    4548 
    4649                str = strtok_s(substrings[i], "/", &next_token);           
    4750                int nIndex = (int)strtol(str, NULL, 10) - 1; 
    48  
     51*/ 
    4952                // store indices 
    5053                if (index >= 0) 
     
    7073                        faceVertices.push_back(vertices[indices[idx2]]); 
    7174                        faceVertices.push_back(vertices[indices[idx3]]); 
    72                  
     75         
     76                        Vector3 dummy(1, 0, 0); 
     77                        faceNormals.push_back(dummy); 
     78                        faceNormals.push_back(dummy); 
     79                        faceNormals.push_back(dummy); 
     80 
     81                        /* 
     82                        const Vector3 v2 = mVertices[2] - mVertices[1]; 
     83                        Normalize(CrossProd(v2, v1)); 
     84 
    7385                        faceNormals.push_back(normals[nIndices[idx1]]); 
    7486                        faceNormals.push_back(normals[nIndices[idx2]]); 
     
    7890                        faceTexcoords.push_back(texcoords[tIndices[idx2]]); 
    7991                        faceTexcoords.push_back(texcoords[tIndices[idx3]]); 
     92                        */ 
    8093                } 
    8194        } 
     
    129142                geom->mNormals[i].z = faceNormals[i].y; 
    130143 
    131                 geom->mTexcoords[i].first = faceTexcoords[i].first; 
    132                 geom->mTexcoords[i].second = faceTexcoords[i].second; 
     144                if (i <= geom->mTexcoordCount) 
     145                { 
     146                        geom->mTexcoords[i].first = faceTexcoords[i].first; 
     147                        geom->mTexcoords[i].second = faceTexcoords[i].second; 
     148                } 
    133149        } 
    134150 
     
    228244                                                faceVertices, faceNormals, faceTexcoords); 
    229245 
     246                                if (((line % 100) == 99) &&  
     247                                        !faceVertices.empty()) 
     248                                { 
     249                                        ++ mNumShapes; 
     250 
     251                                        LoadShape(faceVertices, faceNormals, faceTexcoords); 
     252 
     253                                        faceVertices.clear(); 
     254                                        faceNormals.clear(); 
     255                                        faceTexcoords.clear(); 
     256                                } 
     257 
    230258                                break; 
    231259                        }   // end face 
     
    286314        //-- texture 
    287315 
    288         //int texId = -1; 
    289         int texId = 0; 
     316        int texId = -1; 
     317        //int texId = 0; 
    290318        str.write(reinterpret_cast<char *>(&texId), sizeof(int)); 
    291319 
     
    330358        //-- write textures 
    331359 
    332         int textureCount = 1; 
    333         //int textureCount = 0; 
     360        //int textureCount = 1; 
     361        int textureCount = 0; 
    334362 
    335363        ofile.write(reinterpret_cast<char *>(&textureCount), sizeof(int)); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/Converter/main.cpp

    r2961 r2963  
    2121        } 
    2222*/ 
    23         if (!converter.Convert(model_path + "toyplane.obj", model_path + "toyplane.dem")) 
    24                 cerr << "conversion failed" << endl; 
     23        //if (!converter.Convert(model_path + "toyplane.obj", model_path + "toyplane.dem")) 
     24        //      cerr << "conversion failed" << endl; 
    2525 
    2626        //if (!converter.Convert(model_path + "sky.obj", model_path + "sky.dem")) 
    2727        //      cerr << "conversion failed" << endl; 
     28 
     29        if (!converter.Convert(model_path + "city_full.obj", model_path + "city_full.dem")) 
     30                cerr << "conversion failed" << endl; 
    2831 
    2932        cout << "conversion successful" << endl; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Bvh.cpp

    r2954 r2963  
    427427        else 
    428428        { 
     429                // hack: use dummy wrapper in order to use function 
    429430                static BvhNodeContainer dummy(1); 
    430431                dummy[0] = node; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/BvhLoader.cpp

    r2962 r2963  
    7777        newRoot->mLast = root->mLast; 
    7878 
    79         // create 'dynamic' leaf which basicly is a container 
     79        // create 'dynamic' leaf which basically is a container 
    8080        // for all dynamic objects 
    8181        BvhLeaf *dynamicLeaf = new BvhLeaf(newRoot); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ResourceManager.cpp

    r2961 r2963  
    235235        str.read(reinterpret_cast<char *>(&entityCount), sizeof(int)); 
    236236 
    237         entities.resize(entityCount); 
     237        entities.reserve(entityCount); 
    238238 
    239239        for (int i = 0; i < entityCount; ++ i) 
    240240        { 
    241241                SceneEntity *ent = LoadSceneEntity(str); 
    242                 entities[i] = ent; 
    243  
     242 
     243                // return loaded entities 
     244                entities.push_back(ent); 
     245                // also store internally 
    244246                mSceneEntities.push_back(ent); 
    245247        } 
     
    275277        mGeometryTable.clear(); 
    276278        mMaterialTable.clear(); 
    277         //mShapesTable.clear(); 
    278279 
    279280        return true; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp

    r2954 r2963  
    156156 
    157157 
    158 static void DrawPoly(Polyhedron *poly, const Vector3 &color) 
     158static void DrawPolyhedron(Polyhedron *poly, const Vector3 &color) 
    159159{ 
    160160        if (!poly) return; 
     
    179179 
    180180 
    181 void ShadowMap::DrawPolys() 
    182 { 
    183         DrawPoly(lightPoly, Vector3(1, 0, 1)); 
    184         DrawPoly(polyhedron, Vector3(0, 1, 0)); 
     181void ShadowMap::VisualizeFrustra() 
     182{ 
     183        DrawPolyhedron(lightPoly, Vector3(1, 0, 1)); 
     184        DrawPolyhedron(polyhedron, Vector3(0, 1, 0)); 
    185185} 
    186186 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.h

    r2952 r2963  
    2121class DirectionalLight; 
    2222 
    23 /** This class implements a the computation of single shadow map 
     23/** This class implements a the computation of single shadow map using  
     24        LispSM (light space perspective shadow mapping) 
    2425*/ 
    2526class ShadowMap 
     
    2829public: 
    2930        /** Constructor taking the scene boundig box and the current camera.  
    30                 The shadow map has resolution size * size. 
     31                The shadow map has resolution size squared. 
    3132        */ 
    3233        ShadowMap(DirectionalLight *light, int size, const AxisAlignedBox3 &sceneBox, Camera *cam); 
     
    3940        */ 
    4041        unsigned int GetShadowColorTexture() const; 
    41          
     42        /** Returns the depth texture used for shadow comparison. 
     43        */ 
    4244        unsigned int GetDepthTexture() const; 
    43  
    4445        /** Returns computed texture matrix. It must be applied on the 
    4546                the world space positions.  
     
    5354        */ 
    5455        int GetSize() const { return mSize; } 
    55  
     56        /** Returns the camera used for light view rendering. 
     57        */ 
    5658        Camera *GetShadowCamera() const { return mShadowCam; } 
    57  
     59        /** Renders the scene from shadow view using conventional shading. 
     60        */ 
    5861        void RenderShadowView(RenderTraverser *renderer, const Matrix4x4 &projView); 
    59  
    60         static void DrawPolys(); 
     62        /** Draws LispSM intersection body B and the used light frustrum 
     63        */ 
     64        static void VisualizeFrustra(); 
    6165 
    6266 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp

    r2931 r2963  
    154154        RenderFrustum(); 
    155155 
    156         ShadowMap::DrawPolys(); 
     156        ShadowMap::VisualizeFrustra(); 
    157157 
    158158        Vector3 pos = mCamera->GetPosition(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2961 r2963  
    447447 
    448448         
     449         
     450        // set far plane based on scene extent 
     451        farDist = 10.0f * Magnitude(bvh->GetBox().Diagonal()); 
     452        bvh->SetVirtualLeaves(trianglesPerVirtualLeaf); 
     453 
     454        camera->SetFar(Magnitude(bvh->GetBox().Diagonal())); 
     455         
     456        InitCg(); 
     457 
     458        DeferredRenderer::Init(sCgContext); 
     459        SkyPreetham::Init(sCgContext); 
     460 
    449461        Vector3 cubeCenter(470.398f, 240.364f, 182.5f); 
    450462        /*AxisAlignedBox3 box(cubeCenter - Vector3(2.0f), cubeCenter + Vector3(2.0f)); 
     
    457469        Matrix4x4 transl = TranslationMatrix(cubeCenter); 
    458470         
    459         const string aeroplaneStr = model_path + "toyplane.dem"; 
     471        //const string aeroplaneStr = model_path + "toyplane.dem"; 
     472        const string aeroplaneStr = model_path + "city_full.dem"; 
    460473 
    461474        SceneEntityContainer dummy; 
     
    471484        } 
    472485 
    473         aeroplane = dummy[0]; 
    474         aeroplane->GetTransform()->MultMatrix(transl); 
    475         dummy.clear(); 
    476  
    477  
    478         // set far plane based on scene extent 
    479         farDist = 10.0f * Magnitude(bvh->GetBox().Diagonal()); 
    480         bvh->SetVirtualLeaves(trianglesPerVirtualLeaf); 
    481  
    482         camera->SetFar(Magnitude(bvh->GetBox().Diagonal())); 
    483          
    484         InitCg(); 
    485  
    486         DeferredRenderer::Init(sCgContext); 
    487         SkyPreetham::Init(sCgContext); 
    488  
    489          
    490486        string skyDomeStr(model_path + "sky.dem"); 
    491487 
     
    500496        } 
    501497 
    502         skyDome = dummy[0]; 
    503          
     498        aeroplane = dummy[0]; 
     499        skyDome = dummy[1]; 
     500 
     501        aeroplane->GetTransform()->MultMatrix(transl); 
     502 
    504503        const float turbitiy = 3.0f; 
    505504        preetham = new SkyPreetham(turbitiy, skyDome); 
     
    10871086        { 
    10881087                // actually render the scene geometry using the specified algorithm 
    1089                 traverser->RenderScene(); 
     1088                //traverser->RenderScene(); 
     1089                state.Reset(); 
     1090        /*      SceneEntityContainer::const_iterator sit, sit_end = sceneEntities.end(); 
     1091 
     1092                for (sit = sceneEntities.begin(); sit != sit_end; ++ sit) 
     1093                { 
     1094                        renderQueue->Enqueue(*sit); 
     1095                }*/ 
     1096 
     1097                aeroplane->Render(&state); 
     1098 
     1099                renderQueue->Apply(); 
    10901100        } 
    10911101 
     
    11121122 
    11131123        //state.Reset(); glEnable(GL_TEXTURE_2D); 
    1114         aeroplane->Render(&state); 
     1124        //aeroplane->Render(&state); 
    11151125 
    11161126 
Note: See TracChangeset for help on using the changeset viewer.