Changeset 3063 for GTP


Ignore:
Timestamp:
10/23/08 16:37:00 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
7 edited

Legend:

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

    r3062 r3063  
    116116{ 
    117117        mNear = nearDist; 
     118        UpdateProjectionMatrix(); 
    118119} 
    119120 
     
    122123{  
    123124        mFar = farDist;  
     125        UpdateProjectionMatrix(); 
    124126} 
    125127 
     
    272274 
    273275 
     276void Camera::GetProjectionMatrix(Matrix4x4 &m)const 
     277{ 
     278        m = mProjection; 
     279} 
     280 
     281 
    274282/*********************************************************/ 
    275283/*       Class PerspectiveCamera implementation           */ 
     
    280288{ 
    281289        mFOVy = 60.0f * M_PI / 180.0f; 
     290        mAspect = 1.0f; 
     291 
     292        UpdateProjectionMatrix(); 
    282293} 
    283294 
     
    287298        mFOVy = fieldOfView * M_PI / 180.0f; 
    288299        mAspect = aspect; 
     300 
     301        UpdateProjectionMatrix(); 
    289302} 
    290303 
     
    384397 
    385398 
    386 void PerspectiveCamera::GetProjectionMatrix(Matrix4x4 &mat) const 
    387 { 
    388         mat = GetPerspective(mFOVy, 1.0f / mAspect, mNear, mFar); 
    389  
    390         Matrix4x4 mat2; 
    391         glGetFloatv(GL_PROJECTION_MATRIX, (float *)mat2.x); 
    392  
    393         cout << "my projview:\n" << mat  << endl; 
    394         cout << "gl projview:\n" << mat2 << endl; 
    395 } 
    396  
    397  
    398 } 
     399void PerspectiveCamera::UpdateProjectionMatrix() 
     400{ 
     401        mProjection = GetPerspective(mFOVy, 1.0f / mAspect, mNear, mFar); 
     402} 
     403 
     404 
     405} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.h

    r3062 r3063  
    7272        /** Returns the current projection matrix. 
    7373        */ 
    74         virtual void GetProjectionMatrix(Matrix4x4 &mat) const = 0; 
     74        void GetProjectionMatrix(Matrix4x4 &mat) const; 
    7575        /** Returns the current model view matrix. 
    7676        */ 
     
    121121protected: 
    122122 
     123        virtual void UpdateProjectionMatrix() = 0; 
     124 
    123125        void Precompute(const Vector3 &direction); 
    124126 
     
    134136        Matrix4x4 mBaseOrientation; 
    135137        Matrix4x4 mViewOrientation; 
     138 
     139        Matrix4x4 mProjection; 
    136140 
    137141        float mPitch; 
     
    161165        */ 
    162166        inline float GetAspect() const { return mAspect; } 
    163         /** Returns the current projection matrix. 
    164         */ 
    165         virtual void GetProjectionMatrix(Matrix4x4 &mat) const; 
    166167        /** Computes the extremal points of this frustum. 
    167168                If farthestVisibleDistance is nearer than the far plane,  
     
    177178 
    178179protected: 
     180        /** Calculates the current projection matrix. 
     181        */ 
     182        virtual void UpdateProjectionMatrix(); 
    179183 
    180184        void ComputePointsInternal(Vector3 &ftl, Vector3 &ftr, Vector3 &fbl, Vector3 &fbr, 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp

    r3062 r3063  
    527527        sCgSsaoProgram->SetValue3f(10, tr.x, tr.y, tr.z); 
    528528 
    529         cout << "new projview:\n" << projViewMatrix << endl; 
    530         cout << "old projview:\n" << oldProjViewMatrix << endl; 
     529        //cout << "new projview:\n" << projViewMatrix << endl; 
     530        //cout << "old projview:\n" << oldProjViewMatrix << endl; 
    531531 
    532532        sCgSsaoProgram->SetMatrix(11, projViewMatrix); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp

    r3062 r3063  
    335335 
    336336#if 0 
     337 
    337338Vector3 ShadowMap::GetNearCameraPointE(const VertexArray &pts) const 
    338339{ 
     
    545546} 
    546547 
     548 
    547549unsigned int ShadowMap::GetShadowColorTexture() const 
    548550{ 
     
    562564        polyhedron.CollectVertices(vertices); 
    563565 
    564         // we 'look' at each point and calculate intersections of rays with scene bounding box 
     566        // we 'look' at each point and intect rays with the scene bounding box 
    565567        VertexArray::const_iterator it, it_end = vertices.end(); 
    566568 
     
    570572 
    571573                frustumPoints.push_back(v); 
    572                  
    573574                // hack: start at point which is guaranteed to be outside of box 
    574575                v -= Magnitude(mSceneBox.Diagonal()) * lightDir; 
     
    587588 
    588589 
    589 void ShadowMap::ComputeShadowMap(RenderTraverser *renderer, const Matrix4x4 &projView) 
     590void ShadowMap::ComputeShadowMap(RenderTraverser *renderer,  
     591                                                                 const Matrix4x4 &projView) 
    590592{ 
    591593        mFbo->Bind(); 
     
    607609        _Render(renderer); 
    608610 
     611        glPopAttrib(); 
     612         
     613        glShadeModel(GL_SMOOTH); 
     614        glEnable(GL_LIGHTING); 
     615        glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
     616 
     617#if 0 
     618        float *data = new float[mSize * mSize]; 
     619 
     620        GrabDepthBuffer(data, mFbo->GetDepthTex()); 
     621        ExportDepthBuffer(data, mSize); 
     622 
     623        delete [] data; 
     624         
     625        PrintGLerror("shadow map"); 
     626#endif 
     627         
    609628 
    610629        ////////////// 
     
    618637        mTextureMatrix = mLightProjView * biasMatrix;  
    619638 
    620         glPopAttrib(); 
    621          
    622         glShadeModel(GL_SMOOTH); 
    623         glEnable(GL_LIGHTING); 
    624         glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 
    625  
    626 #if 0 
    627         float *data = new float[mSize * mSize]; 
    628  
    629         GrabDepthBuffer(data, mFbo->GetDepthTex()); 
    630         ExportDepthBuffer(data, mSize); 
    631  
    632         delete [] data; 
    633          
    634         PrintGLerror("shadow map"); 
    635 #endif 
    636          
    637639        FrameBufferObject::Release(); 
    638640} 
    639641 
    640642 
    641 void ShadowMap::RenderShadowView(RenderTraverser *renderer, const Matrix4x4 &projView) 
     643void ShadowMap::RenderShadowView(RenderTraverser *renderer,  
     644                                                                 const Matrix4x4 &projView) 
    642645{ 
    643646        glEnable(GL_LIGHTING); 
     
    671674        mShadowCam->SetPosition(mCamera->GetPosition()); 
    672675 
    673         Vector3 upVec = CalcUpVec(mCamera->GetDirection(), dir); 
    674         Matrix4x4 lightView = LookAt(mShadowCam->GetPosition(), dir, upVec); 
     676        const Vector3 upVec = CalcUpVec(mCamera->GetDirection(), dir); 
     677        const Matrix4x4 lightView = LookAt(mShadowCam->GetPosition(), dir, upVec); 
    675678 
    676679        mShadowCam->mViewOrientation = lightView; 
     
    684687        CalcLightProjection(lightProj); 
    685688 
     689        mLightProjView = lightView * lightProj; 
     690 
     691        DEL_PTR(lightPoly); 
     692        lightPoly = CreatePolyhedron(mLightProjView, mSceneBox); 
     693 
    686694        glMatrixMode(GL_PROJECTION); 
    687695        glPushMatrix(); 
    688         glLoadMatrixf((float *)lightProj.x); 
    689  
    690         mLightProjView = lightView * lightProj; 
    691  
    692         DEL_PTR(lightPoly); 
    693         lightPoly = CreatePolyhedron(mLightProjView, mSceneBox); 
    694696 
    695697        glMatrixMode(GL_MODELVIEW); 
    696698        glPushMatrix(); 
    697699         
    698         mShadowCam->SetupCameraView(); 
     700        // set projection matrix manually 
     701        mShadowCam->mProjection = lightProj; 
     702         
     703        // load gl view projection 
     704        mShadowCam->SetupViewProjection(); 
    699705 
    700706         
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp

    r3062 r3063  
    104104 
    105105 
    106 void Visualization::Render() 
     106void Visualization::Render(bool showShadowFrustra) 
    107107{ 
    108108        stack<BvhNode *> tStack; 
     
    153153        RenderFrustum(); 
    154154 
    155         ShadowMap::VisualizeFrustra(); 
     155        if (showShadowFrustra) 
     156                ShadowMap::VisualizeFrustra(); 
    156157 
    157158        Vector3 pos = mCamera->GetPosition(); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.h

    r3062 r3063  
    2727 
    2828        ~Visualization(); 
    29  
    3029        /** Renders the visualizatioin 
    3130        */ 
    32         void Render(); 
     31        void Render(bool showShadowFrustra); 
    3332        /** Sets the scene hierarchy. 
    3433        */ 
     
    3635        /** Sets the visualization camera. 
    3736        */ 
    38         void SetVizCamera(Camera *cam)  {mVizCamera = cam;} 
     37        void SetVizCamera(Camera *cam) { mVizCamera = cam; } 
    3938        /** Sets the currently used scene camera. 
    4039        */ 
    41         void SetCamera(PerspectiveCamera *cam)  {mCamera = cam;} 
     40        void SetCamera(PerspectiveCamera *cam) {mCamera = cam; } 
    4241        /** Sets the current render state 
    4342        */ 
     
    4948        */ 
    5049        void RenderFrustum(); 
     50 
    5151 
    5252protected: 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r3062 r3063  
    880880        int oldRenderMethod = renderMethod; 
    881881        // for rendering the light view, we use forward rendering 
    882         if (renderLightView) 
    883                 renderMethod = RenderState::FORWARD; 
     882        if (renderLightView) renderMethod = RenderState::FORWARD; 
    884883 
    885884        /// enable vbo vertex array 
     
    16011600        //-- visualization of the occlusion culling 
    16021601 
    1603         visualization->Render(); 
     1602        visualization->Render(showShadowMap); 
    16041603 
    16051604         
     
    19481947        glDisable(GL_CULL_FACE); 
    19491948        state.LockCullFaceEnabled(true); 
    1950  
     1949        /// don't use alphatocoverage 
    19511950        state.SetUseAlphaToCoverage(false); 
    19521951 
     
    19671966 
    19681967        glEnableClientState(GL_NORMAL_ARRAY); 
    1969  
    19701968        // change back state 
    19711969        BvhNode::SetCurrentState(CAMERA_PASS); 
Note: See TracChangeset for help on using the changeset viewer.