- Timestamp:
- 09/12/08 13:20:42 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Matrix4x4.cpp
r2933 r2934 742 742 Matrix4x4 m(nRight, nUp, -nDir); 743 743 744 /*m.x[3][0] = -DotProd(nRight, position);745 m.x[3][1] = -DotProd(nUp, position);746 m.x[3][2] = -DotProd(nDir, position);*/747 748 744 Vector3 position = m * -pos; 749 745 … … 756 752 } 757 753 758 } 754 755 Matrix4x4 MyLookAt2(const Vector3 &pos, const Vector3 &dir, const Vector3& up) 756 { 757 const Vector3 nDir = Normalize(dir); 758 Vector3 nUp = Normalize(up); 759 760 Vector3 nRight = Normalize(CrossProd(nDir, nUp)); 761 nUp = Normalize(CrossProd(nRight, nDir)); 762 763 Matrix4x4 m(nRight, nUp, nDir); 764 765 /*m.x[3][0] = -DotProd(nRight, position); 766 m.x[3][1] = -DotProd(nUp, position); 767 m.x[3][2] = -DotProd(nDir, position);*/ 768 769 Vector3 position = m * -pos; 770 771 // note: left handed system => we go into positive z 772 m.x[3][0] = position.x; 773 m.x[3][1] = position.y; 774 m.x[3][2] = position.z; 775 776 return m; 777 } 778 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Matrix4x4.h
r2932 r2934 161 161 Matrix4x4 LookAt(const Vector3 &pos, const Vector3 &dir, const Vector3& up); 162 162 Matrix4x4 MyLookAt(const Vector3 &pos, const Vector3 &dir, const Vector3& up); 163 Matrix4x4 MyLookAt2(const Vector3 &pos, const Vector3 &dir, const Vector3& up); 163 164 164 165 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
r2933 r2934 89 89 { 90 90 mCullFaceEnabled = true; 91 //glEnable(GL_CULL_FACE);91 glEnable(GL_CULL_FACE); 92 92 } 93 93 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp
r2933 r2934 23 23 static Polyhedron *polyhedron = NULL; 24 24 static Polyhedron *lightPoly = NULL; 25 static Matrix4x4 dummy = IdentityMatrix();25 static Vector3 dummyPt; 26 26 27 27 … … 185 185 DrawPoly(polyhedron, Vector3(0, 1, 0)); 186 186 187 Vector3 pt = Vector3::ZERO();188 189 pt = dummy * pt;190 191 187 glPointSize(10.0f); 192 188 193 189 glBegin(GL_POINTS); 194 glVertex3f( pt.x, pt.y, pt.z);190 glVertex3f(dummyPt.x, dummyPt.y, dummyPt.z); 195 191 glEnd(); 196 192 } … … 223 219 //-- first find the free parameter values n, and P (the projection center), and the projection depth 224 220 225 const float n = 1e3f;226 //const float n = 1e6f;221 //const float n = 1e1f; 222 const float n = 1e6f; 227 223 //const float n = ComputeN(bounds_ls) * 100; 228 224 … … 244 240 245 241 cout <<"start: " << startPt << " " << projCenter << " " << Distance(lightSpace * mCamera->GetPosition(), startPt) << endl; 242 dummyPt = -projCenter; 246 243 247 244 //construct a translation that moves to the projection center … … 408 405 409 406 transform2LispSM.x[0][0] = 1.0f; 410 transform2LispSM.x[1][2] = -1.0f; // y => -z407 transform2LispSM.x[1][2] = -1.0f; // y => -z 411 408 transform2LispSM.x[2][1] = 1.0f; // z => y 412 409 transform2LispSM.x[3][3] = 1.0f; … … 424 421 //calculate a frame matrix that uses the projViewDir[lightspace] as up vector 425 422 //look(from position, into the direction of the projected direction, with unchanged up-vector) 426 const Matrix4x4 frame = MyLookAt (Vector3::ZERO(),projViewDir, Vector3::UNIT_Y());423 const Matrix4x4 frame = MyLookAt2(Vector3::ZERO(), -projViewDir, Vector3::UNIT_Y()); 427 424 //const Matrix4x4 frame = MyLookAt(Vector3::ZERO(), projViewDir, Vector3::UNIT_Z()); 428 425 … … 442 439 transformToGL.x[0][0] = 1.0f; 443 440 transformToGL.x[1][2] = 1.0f; // z => y 444 transformToGL.x[2][1] = -1.0f; // y => -z441 transformToGL.x[2][1] = -1.0f; // y => -z 445 442 transformToGL.x[3][3] = 1.0f; 446 443 … … 564 561 565 562 Vector3 upVec = CalcUpVec(mCamera->GetDirection(), dir); 566 Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), -dir, -upVec); 567 //Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), dir, mCamera->GetDirection()); 563 Matrix4x4 lightView = MyLookAt2(mShadowCam->GetPosition(), -dir, upVec); 568 564 569 565 mShadowCam->mViewOrientation = lightView; … … 603 599 604 600 mLightProjView = lightView * lightProj; 605 glEnable(GL_CULL_FACE);601 ; 606 602 cout << "here3" << endl; 607 603 DEL_PTR(lightPoly); … … 676 672 677 673 Vector3 upVec = CalcUpVec(mCamera->GetDirection(), dir); 678 Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), -dir, -upVec); 679 //Matrix4x4 lightView = Invert(_lightView); 680 //Matrix4x4 lightView = MyLookAt(mShadowCam->GetPosition(), dir, mCamera->GetDirection()); 674 Matrix4x4 lightView = MyLookAt2(mShadowCam->GetPosition(), -dir, upVec); 681 675 682 676 mShadowCam->mViewOrientation = lightView; … … 702 696 mLightProjView = lightView * lightProj; 703 697 704 dummy = mLightProjView;698 //dummy = mLightProjView; 705 699 706 700 DEL_PTR(lightPoly); … … 711 705 glLoadIdentity(); 712 706 713 glDisable(GL_CULL_FACE);707 //glDisable(GL_CULL_FACE); 714 708 715 709 mShadowCam->SetupCameraView();
Note: See TracChangeset
for help on using the changeset viewer.