Changeset 2933


Ignore:
Timestamp:
09/12/08 10:39:52 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
3 edited

Legend:

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

    r2932 r2933  
    748748        Vector3 position = m * -pos; 
    749749         
    750         // note: left handet system => we go into positive z 
     750        // note: left handed system => we go into positive z 
    751751        m.x[3][0] = position.x; 
    752752        m.x[3][1] = position.y; 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp

    r2861 r2933  
    8989        { 
    9090                mCullFaceEnabled = true; 
    91                 glEnable(GL_CULL_FACE); 
     91                //glEnable(GL_CULL_FACE); 
    9292        } 
    9393 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp

    r2932 r2933  
    223223        //-- first find the free parameter values n, and P (the projection center), and the projection depth 
    224224 
    225         const float n = 1e2f; 
     225        const float n = 1e3f; 
    226226        //const float n = 1e6f; 
    227227        //const float n = ComputeN(bounds_ls) * 100; 
     
    230230 
    231231        const Vector3 nearPt = GetNearCameraPointE(body); 
    232         const float dummy = 0; 
     232         
    233233        //get the coordinates of the near camera point in light space 
    234234        const Vector3 lsNear = lightSpace * nearPt; 
     
    249249 
    250250        // light space y size 
    251         const float d = fabs(bounds_ls.Max()[2] - bounds_ls.Min()[2])+dummy; 
     251        const float d = fabs(bounds_ls.Max()[2] - bounds_ls.Min()[2]); 
    252252 
    253253        const float dy = fabs(bounds_ls.Max()[1] - bounds_ls.Min()[1]); 
     
    263263        Matrix4x4 matLispSM; 
    264264         
    265         matLispSM = GetFrustum(-1.0, 1.0, -1.0, 1.0, n+dummy, n + d); 
     265        matLispSM = GetFrustum(-1.0, 1.0, -1.0, 1.0, n, n + d); 
    266266 
    267267        //cout << "lispsm\n" << matLispSM << endl; 
     
    310310        } 
    311311 
    312         //      Invert(eyeView); return eyeView * nearest; 
     312        //      return Invert(eyeView) * nearest; 
    313313        return nearest; 
    314314} 
     
    346346#endif 
    347347 
    348 Vector3 ShadowMap::GetProjViewDir(const Matrix4x4 &lightSpace, const VertexArray &pts) const  
     348Vector3 ShadowMap::GetProjViewDir(const Matrix4x4 &lightSpace,  
     349                                                                  const VertexArray &pts) const  
    349350{ 
    350351        //get the point in the LVS volume that is nearest to the camera 
     
    359360        Vector3 projDir(b_lp - e_lp); 
    360361 
    361         Matrix4x4 dummy = lightSpace; 
     362        Matrix4x4 dummy = Invert(lightSpace); 
    362363        Invert(dummy); 
    363364        Vector3 dummyVec = dummy * e_lp; 
     
    412413 
    413414        //switch to the lightspace used in the article 
    414         //lightProj = lightProj * transform2LispSM; 
     415        lightProj = lightProj * transform2LispSM; 
    415416 
    416417        const Vector3 projViewDir = GetProjViewDir(lightView * lightProj, frustumPoints); 
     
    418419 
    419420        cout << "projViewDir: " << projViewDir << " orig " << mCamera->GetDirection() << endl; 
    420  
     421                                                                 
    421422        //do Light Space Perspective shadow mapping 
    422423        //rotate the lightspace so that the projected light view always points upwards 
     
    424425        //look(from position, into the direction of the projected direction, with unchanged up-vector) 
    425426        const Matrix4x4 frame = MyLookAt(Vector3::ZERO(), projViewDir, Vector3::UNIT_Y()); 
     427        //const Matrix4x4 frame = MyLookAt(Vector3::ZERO(), projViewDir, Vector3::UNIT_Z()); 
    426428 
    427429        cout << "frame\n " << frame << endl; 
    428         //lightProj = lightProj * frame; 
     430        lightProj = lightProj * frame; 
    429431 
    430432        cout << "here9\n" << lightProj << endl; 
     
    443445        transformToGL.x[3][3] =  1.0f; 
    444446 
    445         //lightProj = lightProj * transformToGL; 
     447        lightProj = lightProj * transformToGL; 
    446448        //cout << "here4 \n" << lightProj << endl; 
    447449 
     
    562564 
    563565        Vector3 upVec = CalcUpVec(mCamera->GetDirection(), dir); 
    564         Matrix4x4 lightView =  
    565                 MyLookAt(mShadowCam->GetPosition(), dir, upVec); 
     566        Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), -dir, -upVec); 
     567        //Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), dir, mCamera->GetDirection()); 
    566568 
    567569        mShadowCam->mViewOrientation = lightView; 
     
    601603 
    602604        mLightProjView = lightView * lightProj; 
    603  
     605glEnable(GL_CULL_FACE); 
    604606        cout << "here3" << endl; 
    605607        DEL_PTR(lightPoly); 
     
    674676 
    675677        Vector3 upVec = CalcUpVec(mCamera->GetDirection(), dir); 
    676         Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), dir, upVec); 
     678        Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), -dir, -upVec); 
     679        //Matrix4x4 lightView = Invert(_lightView); 
     680        //Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), dir, mCamera->GetDirection()); 
    677681 
    678682        mShadowCam->mViewOrientation = lightView; 
     
    706710        glPushMatrix(); 
    707711        glLoadIdentity(); 
     712 
     713        glDisable(GL_CULL_FACE); 
    708714 
    709715        mShadowCam->SetupCameraView(); 
     
    722728        glDisable(GL_DEPTH_TEST); 
    723729        glDepthMask(GL_FALSE); 
    724         glDisable(GL_CULL_FACE); 
    725730 
    726731        Polyhedron *hpoly = CreatePolyhedron(projView, mSceneBox); 
Note: See TracChangeset for help on using the changeset viewer.