Changeset 2940 for GTP/trunk


Ignore:
Timestamp:
09/13/08 12:31:26 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
2 edited

Legend:

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

    r2939 r2940  
    772772        nUp = Normalize(CrossProd(nRight, nDir)); 
    773773 
    774         Matrix4x4 m(nRight, nUp, -nDir); 
     774        Matrix4x4 m(nRight.x, nRight.y, nRight.z, 0, 
     775                        nUp.x,    nUp.y,    nUp.z,    0, 
     776                                -nDir.x,  -nDir.y,   -nDir.z, 0, 
     777                                0,        0,        0,        1); 
     778 
     779        Vector3 position = m * -pos; 
     780         
     781        // note: left handed system => we go into positive z 
     782        m.x[3][0] = -DotProd(nRight, pos); 
     783        m.x[3][1] = -DotProd(nUp, pos); 
     784        m.x[3][2] =  DotProd(nDir, pos); 
     785 
     786        return m; 
     787} 
     788 
     789 
     790Matrix4x4 MyLookAt2(const Vector3 &pos, const Vector3 &dir, const Vector3& up)  
     791{ 
     792        const Vector3 nDir = Normalize(dir); 
     793        Vector3 nUp = Normalize(up); 
     794 
     795        Vector3 nRight = Normalize(CrossProd(nDir, nUp)); 
     796        nUp = Normalize(CrossProd(nRight, nDir)); 
     797 
     798        Matrix4x4 m(nRight, nUp, nDir); 
    775799 
    776800        Vector3 position = m * -pos; 
     
    785809 
    786810 
    787 Matrix4x4 MyLookAt2(const Vector3 &pos, const Vector3 &dir, const Vector3& up)  
    788 { 
    789         const Vector3 nDir = Normalize(dir); 
    790         Vector3 nUp = Normalize(up); 
    791  
    792         Vector3 nRight = Normalize(CrossProd(nDir, nUp)); 
    793         nUp = Normalize(CrossProd(nRight, nDir)); 
    794  
    795         Matrix4x4 m(nRight, nUp, nDir); 
    796  
    797         m.x[3][0] = -DotProd(nRight, pos); 
    798         m.x[3][1] = -DotProd(nUp, pos); 
    799         m.x[3][2] = -DotProd(nDir, pos); 
    800  
    801         return m; 
    802 } 
    803 } 
     811} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp

    r2939 r2940  
    227227                                                                                 ) 
    228228{ 
    229         return IdentityMatrix(); 
     229        //return IdentityMatrix(); 
    230230 
    231231        AxisAlignedBox3 bounds_ls = GetExtremalPoints(lightSpace, body); 
     
    236236 
    237237        //const float n = 1e2f; 
    238         const float n = 1e6f; 
    239         //const float n = ComputeN(bounds_ls); 
     238        //const float n = 1e6f; 
     239        const float n = ComputeN(bounds_ls); 
    240240 
    241241        cout << "n: " << n << endl; 
     
    442442        //look(from position, into the direction of the projected direction, with unchanged up-vector) 
    443443        //const Matrix4x4 frame = MyLookAt2(Vector3::ZERO(), projViewDir, Vector3::UNIT_Y()); 
    444         const Matrix4x4 frame = MyLookAt2(Vector3::ZERO(), -projViewDir, Vector3::UNIT_Y()); 
     444        const Matrix4x4 frame = MyLookAt(Vector3::ZERO(), projViewDir, Vector3::UNIT_Y()); 
    445445 
    446446        cout << "frame\n " << frame << endl; 
     
    455455        Matrix4x4 transformToGL = ZeroMatrix(); 
    456456         
    457         transformToGL.x[0][0] =  1.0f; 
    458         transformToGL.x[1][2] =  1.0f; // z => y 
     457        transformToGL.x[0][0] =   1.0f; 
     458        transformToGL.x[1][2] =   1.0f; // z => y 
    459459        transformToGL.x[2][1] =  -1.0f; // y => -z 
    460         transformToGL.x[3][3] =  1.0f; 
     460        transformToGL.x[3][3] =   1.0f; 
    461461 
    462462        lightProj *= transformToGL; 
     
    583583 
    584584        Vector3 upVec = CalcUpVec(mCamera->GetDirection(), dir); 
    585         Matrix4x4 lightView = MyLookAt2(mShadowCam->GetPosition(), -dir, upVec); 
     585        Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), dir, upVec); 
    586586        //Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), -dir, mCamera->GetDirection()); 
    587587 
     
    591591        mShadowCam->mViewOrientation = lightView; 
    592592 
    593         //cout << "here45:\n" << lightView << endl; 
    594  
    595         //mShadowCam->SetDirection(dir); 
    596         //mShadowCam->GetModelViewMatrix(lightView); 
    597         //cout << "here46:\n" << lightView << endl; 
    598593 
    599594        mFbo->Bind(); 
     
    701696 
    702697        Vector3 upVec = CalcUpVec(mCamera->GetDirection(), dir); 
    703         Matrix4x4 lightView = MyLookAt2(mShadowCam->GetPosition(), -dir, upVec); 
     698        Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), dir, upVec); 
    704699        //Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), -dir, mCamera->GetDirection()); 
    705700 
     
    720715 
    721716        Matrix4x4 lightProj; 
    722          
    723717        CalcLightProjection(lightProj); 
    724718 
     
    728722 
    729723        mLightProjView = lightView * lightProj; 
    730  
    731724        dummyMat = mLightProjView; 
    732725 
Note: See TracChangeset for help on using the changeset viewer.