- Timestamp:
- 09/13/08 12:31:26 (16 years ago)
- 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 772 772 nUp = Normalize(CrossProd(nRight, nDir)); 773 773 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 790 Matrix4x4 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); 775 799 776 800 Vector3 position = m * -pos; … … 785 809 786 810 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 227 227 ) 228 228 { 229 return IdentityMatrix();229 //return IdentityMatrix(); 230 230 231 231 AxisAlignedBox3 bounds_ls = GetExtremalPoints(lightSpace, body); … … 236 236 237 237 //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); 240 240 241 241 cout << "n: " << n << endl; … … 442 442 //look(from position, into the direction of the projected direction, with unchanged up-vector) 443 443 //const Matrix4x4 frame = MyLookAt2(Vector3::ZERO(), projViewDir, Vector3::UNIT_Y()); 444 const Matrix4x4 frame = MyLookAt 2(Vector3::ZERO(), -projViewDir, Vector3::UNIT_Y());444 const Matrix4x4 frame = MyLookAt(Vector3::ZERO(), projViewDir, Vector3::UNIT_Y()); 445 445 446 446 cout << "frame\n " << frame << endl; … … 455 455 Matrix4x4 transformToGL = ZeroMatrix(); 456 456 457 transformToGL.x[0][0] = 1.0f;458 transformToGL.x[1][2] = 1.0f; // z => y457 transformToGL.x[0][0] = 1.0f; 458 transformToGL.x[1][2] = 1.0f; // z => y 459 459 transformToGL.x[2][1] = -1.0f; // y => -z 460 transformToGL.x[3][3] = 1.0f;460 transformToGL.x[3][3] = 1.0f; 461 461 462 462 lightProj *= transformToGL; … … 583 583 584 584 Vector3 upVec = CalcUpVec(mCamera->GetDirection(), dir); 585 Matrix4x4 lightView = MyLookAt 2(mShadowCam->GetPosition(), -dir, upVec);585 Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), dir, upVec); 586 586 //Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), -dir, mCamera->GetDirection()); 587 587 … … 591 591 mShadowCam->mViewOrientation = lightView; 592 592 593 //cout << "here45:\n" << lightView << endl;594 595 //mShadowCam->SetDirection(dir);596 //mShadowCam->GetModelViewMatrix(lightView);597 //cout << "here46:\n" << lightView << endl;598 593 599 594 mFbo->Bind(); … … 701 696 702 697 Vector3 upVec = CalcUpVec(mCamera->GetDirection(), dir); 703 Matrix4x4 lightView = MyLookAt 2(mShadowCam->GetPosition(), -dir, upVec);698 Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), dir, upVec); 704 699 //Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), -dir, mCamera->GetDirection()); 705 700 … … 720 715 721 716 Matrix4x4 lightProj; 722 723 717 CalcLightProjection(lightProj); 724 718 … … 728 722 729 723 mLightProjView = lightView * lightProj; 730 731 724 dummyMat = mLightProjView; 732 725
Note: See TracChangeset
for help on using the changeset viewer.