- Timestamp:
- 09/12/08 10:39:52 (16 years ago)
- 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 748 748 Vector3 position = m * -pos; 749 749 750 // note: left hande tsystem => we go into positive z750 // note: left handed system => we go into positive z 751 751 m.x[3][0] = position.x; 752 752 m.x[3][1] = position.y; -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderState.cpp
r2861 r2933 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
r2932 r2933 223 223 //-- first find the free parameter values n, and P (the projection center), and the projection depth 224 224 225 const float n = 1e 2f;225 const float n = 1e3f; 226 226 //const float n = 1e6f; 227 227 //const float n = ComputeN(bounds_ls) * 100; … … 230 230 231 231 const Vector3 nearPt = GetNearCameraPointE(body); 232 const float dummy = 0;232 233 233 //get the coordinates of the near camera point in light space 234 234 const Vector3 lsNear = lightSpace * nearPt; … … 249 249 250 250 // 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]); 252 252 253 253 const float dy = fabs(bounds_ls.Max()[1] - bounds_ls.Min()[1]); … … 263 263 Matrix4x4 matLispSM; 264 264 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); 266 266 267 267 //cout << "lispsm\n" << matLispSM << endl; … … 310 310 } 311 311 312 // Invert(eyeView); return eyeView* nearest;312 // return Invert(eyeView) * nearest; 313 313 return nearest; 314 314 } … … 346 346 #endif 347 347 348 Vector3 ShadowMap::GetProjViewDir(const Matrix4x4 &lightSpace, const VertexArray &pts) const 348 Vector3 ShadowMap::GetProjViewDir(const Matrix4x4 &lightSpace, 349 const VertexArray &pts) const 349 350 { 350 351 //get the point in the LVS volume that is nearest to the camera … … 359 360 Vector3 projDir(b_lp - e_lp); 360 361 361 Matrix4x4 dummy = lightSpace;362 Matrix4x4 dummy = Invert(lightSpace); 362 363 Invert(dummy); 363 364 Vector3 dummyVec = dummy * e_lp; … … 412 413 413 414 //switch to the lightspace used in the article 414 //lightProj = lightProj * transform2LispSM;415 lightProj = lightProj * transform2LispSM; 415 416 416 417 const Vector3 projViewDir = GetProjViewDir(lightView * lightProj, frustumPoints); … … 418 419 419 420 cout << "projViewDir: " << projViewDir << " orig " << mCamera->GetDirection() << endl; 420 421 421 422 //do Light Space Perspective shadow mapping 422 423 //rotate the lightspace so that the projected light view always points upwards … … 424 425 //look(from position, into the direction of the projected direction, with unchanged up-vector) 425 426 const Matrix4x4 frame = MyLookAt(Vector3::ZERO(), projViewDir, Vector3::UNIT_Y()); 427 //const Matrix4x4 frame = MyLookAt(Vector3::ZERO(), projViewDir, Vector3::UNIT_Z()); 426 428 427 429 cout << "frame\n " << frame << endl; 428 //lightProj = lightProj * frame;430 lightProj = lightProj * frame; 429 431 430 432 cout << "here9\n" << lightProj << endl; … … 443 445 transformToGL.x[3][3] = 1.0f; 444 446 445 //lightProj = lightProj * transformToGL;447 lightProj = lightProj * transformToGL; 446 448 //cout << "here4 \n" << lightProj << endl; 447 449 … … 562 564 563 565 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()); 566 568 567 569 mShadowCam->mViewOrientation = lightView; … … 601 603 602 604 mLightProjView = lightView * lightProj; 603 605 glEnable(GL_CULL_FACE); 604 606 cout << "here3" << endl; 605 607 DEL_PTR(lightPoly); … … 674 676 675 677 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()); 677 681 678 682 mShadowCam->mViewOrientation = lightView; … … 706 710 glPushMatrix(); 707 711 glLoadIdentity(); 712 713 glDisable(GL_CULL_FACE); 708 714 709 715 mShadowCam->SetupCameraView(); … … 722 728 glDisable(GL_DEPTH_TEST); 723 729 glDepthMask(GL_FALSE); 724 glDisable(GL_CULL_FACE);725 730 726 731 Polyhedron *hpoly = CreatePolyhedron(projView, mSceneBox);
Note: See TracChangeset
for help on using the changeset viewer.