Ignore:
Timestamp:
01/12/09 19:03:24 (15 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r3270 r3271  
    132132 
    133133string filename("city"); 
     134string bvhname(""); 
    134135string visibilitySolution(""); 
    135136 
     
    303304 
    304305GLuint sunQuery = 0; 
     306 
     307string walkThroughSuffix("frames"); 
    305308 
    306309 
     
    455458 
    456459                env.GetStringParam(string("recordedFramesSuffix"), recordedFramesSuffix); 
     460                env.GetStringParam(string("walkThroughSuffix"), walkThroughSuffix); 
    457461                env.GetStringParam(string("statsFilename"), statsFilename); 
    458462                env.GetStringParam(string("filename"), filename); 
     463                env.GetStringParam(string("bvhname"), bvhname); 
    459464                env.GetStringParam(string("visibilitySolution"), visibilitySolution); 
    460465 
     
    472477                cout << "max batch size: " << maxBatchSize << endl; 
    473478                cout << "triangles per virtual leaf: " << trianglesPerVirtualLeaf << endl; 
     479 
     480                cout << "static scene filename prefix: " << filename << endl; 
     481                cout << "bvh filename prefix: " << bvhname << endl; 
    474482 
    475483                cout << "key forward motion: " << keyForwardMotion << endl; 
     
    491499                cout << "use ssao full resolution: " << ssaoUseFullResolution << endl; 
    492500                cout << "recorded frames suffix: " << recordedFramesSuffix << endl; 
     501                cout << "walkthrough suffix: " << walkThroughSuffix << endl; 
    493502                cout << "stats filename: " << statsFilename << endl; 
    494                 cout << "static scene filename prefix: " << filename << endl; 
    495503                cout << "use PVSs: " << usePvs << endl; 
    496504                cout << "visibility solution: " << visibilitySolution << endl; 
     
    587595        //LoadModel("sibenik.dem", dynamicObjects); 
    588596 
     597#if 1 
     598 
     599        AxisAlignedBox3 pompeiiBox = SceneEntity::ComputeBoundingBox(staticObjects); 
     600 
    589601        // todo: dispose texture 
    590602        Texture *floorTex = new Texture(model_path + "stairs.c.01.tif"); 
     
    594606 
    595607        floorTex->Create(); 
    596  
    597  
    598608        Material *mymat = resourceManager->CreateMaterial(); 
    599609 
    600         mymat->GetTechnique(0)->SetDiffuse(RgbaColor(1, 1, 1, 1)); 
    601         mymat->GetTechnique(0)->SetTexture(floorTex); 
    602  
    603         const Vector3 offs(1300.0f, -2500.0f, .0f); 
     610        Technique *tech = mymat->GetDefaultTechnique(); 
     611        tech->SetDiffuse(RgbaColor(1, 1, 1, 1)); 
     612        tech->SetTexture(floorTex); 
     613 
     614        Technique *depthPass = new Technique(*tech); 
     615        Technique *deferred = new Technique(*tech); 
     616 
     617        depthPass->SetColorWriteEnabled(false); 
     618        depthPass->SetLightingEnabled(false); 
     619 
     620        ShaderProgram *defaultFragmentTexProgramMrt = ShaderManager::GetSingleton()->GetShaderProgram("defaultFragmentTexMrt"); 
     621        ShaderProgram *defaultVertexProgramMrt = ShaderManager::GetSingleton()->GetShaderProgram("defaultVertexMrt"); 
     622 
     623        deferred->SetFragmentProgram(defaultFragmentTexProgramMrt); 
     624        deferred->SetVertexProgram(defaultVertexProgramMrt); 
     625 
     626        deferred->GetFragmentProgramParameters()->SetViewMatrixParam(0); 
     627        deferred->GetVertexProgramParameters()->SetModelMatrixParam(1); 
     628        deferred->GetVertexProgramParameters()->SetOldModelMatrixParam(2); 
     629 
     630        deferred->SetTexture(floorTex); 
     631         
     632        mymat->AddTechnique(deferred); 
     633        mymat->AddTechnique(depthPass); 
     634 
     635 
     636        //const Vector3 offs(1300.0f, -2500.0f, .0f); 
     637        const Vector3 offs(pompeiiBox.Center(0), pompeiiBox.Center(1), 0); 
    604638        Matrix4x4 moffs = TranslationMatrix(offs); 
    605639 
     
    609643        SceneEntity *myplane =  
    610644                SceneEntityConverter().ConvertPlane(plane,  
    611                                                     500,  
    612                                                                                         500, 
     645                                                    pompeiiBox.Size(0), 
     646                                                                                        pompeiiBox.Size(1), 
    613647                                                                                        5,  
    614648                                                                                        5, 
     
    618652        resourceManager->AddSceneEntity(myplane); 
    619653        staticObjects.push_back(myplane); 
    620         /*const float side = 400.0f; 
    621         AxisAlignedBox3 mybox(Vector3(-side, -side, -side), Vector3(side, side, side)); 
    622  
    623         Transform3 *mytrafo2 = resourceManager->CreateTransform(moffs); 
    624  
    625         SceneEntity *myboxEnt =  
    626                 SceneEntityConverter().ConvertBox(mybox, mymat, mytrafo2); 
    627  
    628         staticObjects.push_back(myboxEnt); 
    629         resourceManager->AddSceneEntity(myboxEnt);*/ 
     654 
     655#endif 
    630656 
    631657#if 0 
     
    667693        //-- load the associated static bvh 
    668694 
    669         const string bvh_filename = string(model_path + filename + ".bvh"); 
    670  
    671695        BvhFactory bvhFactory; 
    672 #if 1 
    673         bvh = bvhFactory.Create(staticObjects, dynamicObjects, maxDepthForTestingChildren); 
    674 #else 
    675         bvh = bvhFactory.Create(bvh_filename, staticObjects, dynamicObjects, maxDepthForTestingChildren); 
    676 #endif 
    677  
    678         if (!bvh) 
    679         { 
    680                 cerr << "loading bvh " << bvh_filename << " failed" << endl; 
    681                 CleanUp(); 
    682                 exit(0); 
     696 
     697        if (bvhname != "") 
     698        { 
     699                cout << "loading bvh from disc" << endl; 
     700                const string bvh_fullpath = string(model_path + bvhname + ".bvh"); 
     701                bvh = bvhFactory.Create(bvh_fullpath, staticObjects, dynamicObjects, maxDepthForTestingChildren); 
     702 
     703                if (!bvh) 
     704                { 
     705                        cerr << "loading bvh " << bvh_fullpath << " failed" << endl; 
     706                        CleanUp(); 
     707                        exit(0); 
     708                } 
     709        } 
     710        else 
     711        { 
     712                cout << "creating new bvh" << endl; 
     713                bvh = bvhFactory.Create(staticObjects, dynamicObjects, maxDepthForTestingChildren); 
    683714        } 
    684715 
     
    11981229        { 
    11991230                if (!walkThroughPlayer) 
    1200                         walkThroughPlayer = new WalkThroughPlayer("frames.log"); 
     1231                        walkThroughPlayer = new WalkThroughPlayer(walkThroughSuffix + ".log"); 
    12011232                 
    12021233                ++ currentReplayFrame; 
     
    12291260        { 
    12301261                if (!walkThroughRecorder) 
    1231                         walkThroughRecorder = new WalkThroughRecorder("frames.log"); 
     1262                        walkThroughRecorder = new WalkThroughRecorder(walkThroughSuffix + ".log"); 
    12321263                 
    12331264                if ((Distance(oldPos, camera->GetPosition()) > 1e-6f) || 
     
    25602591{ 
    25612592        const string filename = string(model_path + model); 
    2562  
    25632593        int numEntities = 0; 
    25642594 
Note: See TracChangeset for help on using the changeset viewer.