Ignore:
Timestamp:
06/20/08 06:15:17 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
4 edited

Legend:

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

    r2786 r2788  
    222222        if (mUseRenderQueue && (mRenderState->GetMode() == RenderState::RENDER)) 
    223223        { 
    224                 //cout << "render queue: " << mRenderQueue.GetSize() << endl; 
     224                //Debug << "render queue: " << mRenderQueue.GetSize() << endl; 
    225225                mRenderQueue.Render(); 
    226226                mRenderQueue.Clear(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp

    r2787 r2788  
    1414namespace CHCDemoEngine 
    1515{ 
     16 
     17        GLUquadric *mSphere; 
    1618 
    1719/******************************************************/ 
     
    3032mFrameId(0) 
    3133{ 
     34        mSphere = (GLUquadric *)gluNewQuadric(); 
    3235} 
    3336 
     
    5659        tStack.push(mBvh->GetRoot()); 
    5760 
     61        glDisable(GL_LIGHTING); 
     62         
     63        RenderViewPoint(); 
     64        RenderFrustum(); 
     65        RenderBox(mBvh->GetBox()); 
     66 
     67        glEnable(GL_LIGHTING); 
     68 
    5869        glEnableClientState(GL_VERTEX_ARRAY); 
    5970        glEnableClientState(GL_NORMAL_ARRAY); 
    60  
    61         RenderFrustum(); 
    6271 
    6372        while (!tStack.empty()) 
     
    146155 
    147156        glEnable(GL_CULL_FACE); 
    148  
    149157        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); 
    150158} 
     
    153161void Visualization::RenderFrustum() 
    154162{ 
     163        glColor3f(1.0f, 0.0f, 0.0f); 
     164 
    155165        Vector3 ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr; 
    156166        mCamera->ComputePoints(ftl, ftr, fbl, fbr, ntl, ntr, nbl, nbr); 
     
    202212 
    203213 
    204 } 
     214 
     215void Visualization::RenderViewPoint() 
     216{ 
     217        glPushMatrix(); 
     218        Vector3 pos = mCamera->GetPosition(); 
     219        pos.z += 100; 
     220        glTranslatef(pos.x, pos.y, pos.z); 
     221         
     222        glScalef(5.0f, 5.0f, 5.0f); 
     223        glPushAttrib(GL_CURRENT_BIT); 
     224 
     225        glColor3f(1.0f, 0.0f, 0.0f); 
     226         
     227        gluSphere((::GLUquadric *)mSphere, 
     228                2e-3f * Magnitude(mBvh->GetBox().Size()), 6, 6); 
     229 
     230        glPopAttrib(); 
     231        glPopMatrix(); 
     232} 
     233 
     234} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.h

    r2787 r2788  
    5252        void RenderBox(const AxisAlignedBox3 &box); 
    5353 
     54        void RenderViewPoint(); 
    5455 
    5556 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2787 r2788  
    5757float winAspectRatio = 1.0f; 
    5858 
    59 float visZoomFactor = 1.5f; 
    60  
    6159double accumulatedTime = 1000; 
    6260float fps = 1e3f; 
     
    137135 
    138136 
    139         camera = new Camera(winWidth, winHeight); 
     137        camera = new Camera(winWidth, winHeight, 60); 
    140138        camera->SetNear(nearDist); 
    141139 
     
    267265                "'V'            - shows/hides bounding volumes", 
    268266                "", 
    269                 "'1'            - shows/hides visualization", 
    270                 "'2'            - zooms out visualization", 
    271                 "'3'            - zooms in visualization", 
     267                "'1'            - shows/hides bird eye view", 
    272268                0, 
    273269        }; 
     
    480476                visMode = !visMode; 
    481477                break; 
    482         case '2': 
    483                 visZoomFactor += 0.1;    
    484                 break; 
    485         case '3': 
    486                 visZoomFactor -= 0.1; 
    487                 if (visZoomFactor < 0.1) visZoomFactor = 0.1; 
    488                 break; 
    489478        case '8': 
    490479                { 
     
    630619 
    631620        gluPerspective(60.0f, 1.0f / winAspectRatio, nearDist, 2.0f * Magnitude(bvh->GetBox().Diagonal())); 
     621 
    632622        glMatrixMode(GL_MODELVIEW); 
    633623 
     
    817807        glColor4f(0.0,0.0,0.0,0.5);  
    818808 
    819         glRecti(winWidth, 0, winWidth / 2, winHeight / 2); 
     809        glRecti(winWidth, 0, winWidth - winWidth / 4, winHeight / 3); 
    820810        glDisable(GL_BLEND); 
    821811        end2D(); 
    822  
    823         glViewport(winWidth / 2, winHeight / 2, winWidth, winHeight); 
     812         
     813        glViewport(winWidth - winWidth / 4, winHeight - winHeight / 3, winWidth, winHeight); 
     814 
     815 
     816        glMatrixMode(GL_PROJECTION); 
     817        glLoadIdentity(); 
     818         
     819        //gluPerspective(60.0f, 1.0f / winAspectRatio, nearDist, 2.0f * Magnitude(bvh->GetBox().Diagonal())); 
     820        AxisAlignedBox3 box = bvh->GetBox(); 
     821        const float offs = 2000; 
     822        glOrtho(box.Min().y - offs, box.Max().y + offs, box.Min().y - offs, box.Max().y + offs, 0.1, 20.0f * Magnitude(bvh->GetBox().Diagonal()));  
     823         
     824         
    824825        glPushMatrix(); 
    825         //glMatrixMode(GL_PROJECTION); 
     826 
    826827        glMatrixMode(GL_MODELVIEW); 
    827828        glLoadIdentity(); 
    828829 
    829         Vector3 pos(camera->GetPosition()); 
    830     pos.z = 10.0f * bvh->GetBox().Size().z; 
    831         pos.y = 800; 
    832         pos.x += 1000; 
    833  
    834         Matrix4x4 m = RotationZMatrix(-rotation); 
    835         Matrix4x4 t = TranslationMatrix(pos); 
    836         Matrix4x4 minust = TranslationMatrix(-pos); 
    837  
    838830        glMultMatrixf((float *)visView.x); 
    839831 
    840         glMultMatrixf((float *)t.x); 
    841         glMultMatrixf((float *)m.x); 
    842         glMultMatrixf((float *)minust.x); 
     832        //SetupLighting(); 
     833        GLfloat position[] = {0.8f, 1.0f, 1.5f, 0.0f}; 
     834        glLightfv(GL_LIGHT0, GL_POSITION, position); 
     835 
     836        GLfloat position1[] = {bvh->GetBox().Center().x, bvh->GetBox().Max().y, bvh->GetBox().Center().z, 1.0f}; 
     837        glLightfv(GL_LIGHT1, GL_POSITION, position1); 
     838 
     839 
    843840 
    844841        glClear(GL_DEPTH_BUFFER_BIT); 
     
    847844        //-- visualization of the occlusion culling 
    848845 
    849         //traverser->RenderScene(); 
    850846        visualization->Render(); 
    851847         
     
    856852 
    857853 
    858 /** Sets up view matrix in order to get a good position  
    859         for viewing the kd tree node culling 
     854/** Sets up view matrix for bird eye view 
    860855*/ 
    861856void setupVisView() 
    862857{ 
    863         Vector3 pos(-camera->GetPosition()); 
    864     pos.z = -10.0f * bvh->GetBox().Size().z; 
    865         pos.y += 800; 
    866         pos.x -= 1000; 
     858        Vector3 pos(-bvh->GetBox().Center()); 
     859  
     860        pos.z = -15.0f * bvh->GetBox().Size().z; 
     861        pos.y += 1400; 
     862        pos.x -= 1170; 
    867863 
    868864        Vector3 dir(0, 0, 1); 
    869865        Vector3 up(0, 1, 0); 
    870         //Vector3 up(camera->GetDirection());up.y = 0; 
    871866 
    872867        Vector3 left = Normalize(CrossProd(dir, up)); 
     
    879874        visView.x[3][1] = pos.y; 
    880875        visView.x[3][2] = pos.z; 
     876 
     877        //cout << visView<< endl; 
    881878} 
    882879 
     
    929926        char msg4[200]; 
    930927        char msg5[200]; 
     928        char msg6[200]; 
    931929 
    932930 
     
    965963                          renderedNodes, bvh->GetNumVirtualNodes(), str.c_str(), str2.c_str());  
    966964 
    967         sprintf_s(msg4, "traversed: %5d, frustum culled: %5d, query culled: %5d, issued queries: %5d, state changes: %5d", 
    968                           traversedNodes, frustumCulledNodes, queryCulledNodes, issuedQueries, stateChanges); 
    969  
    970         sprintf_s(msg5, "fps: %6.1f", fps); 
     965        sprintf_s(msg4, "traversed: %5d, frustum culled: %5d, query culled: %5d", 
     966                          traversedNodes, frustumCulledNodes, queryCulledNodes); 
     967 
     968        sprintf_s(msg5, "issued queries: %5d, state changes: %5d", issuedQueries, stateChanges); 
     969 
     970        sprintf_s(msg6, "fps: %6.1f", fps); 
    971971        //cout << "previously visible node queries: " << traverser->GetStats().mNumPreviouslyVisibleNodeQueries << endl; 
    972972 
     
    988988                        Output(20, 90, msg4); 
    989989                        Output(20, 120, msg5); 
     990                        Output(20, 150, msg6); 
    990991                } 
    991992        } 
Note: See TracChangeset for help on using the changeset viewer.