Changeset 2939 for GTP/trunk/App/Demos/Vis
- Timestamp:
- 09/12/08 22:02:41 (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
r2936 r2939 569 569 ret.y = v.x * M.x[0][1] + v.y * M.x[1][1] + v.z * M.x[2][1] + M.x[3][1]; 570 570 ret.z = v.x * M.x[0][2] + v.y * M.x[1][2] + v.z * M.x[2][2] + M.x[3][2]; 571 denom = M.x[0][3] + M.x[1][3] + M.x[2][3] + M.x[3][3]; 571 denom = v.x * M.x[0][3] + v.y * M.x[1][3] + v.z * M.x[2][3] + M.x[3][3]; 572 //denom = M.x[0][3] + M.x[1][3] + M.x[2][3] + M.x[3][3]; 573 572 574 if (denom != 1.0) 573 575 ret /= denom; … … 677 679 return m; 678 680 } 681 /* 682 683 template<class REAL> 684 Matrix4<REAL>& scaleTranslateToFit(Matrix4<REAL>& output, const Vector3<REAL>& vMin, const Vector3<REAL>& vMax) { 685 const REAL diffX = vMax.x()-vMin.x(); 686 output[ 0] = 2/diffX; 687 output[ 4] = 0; 688 output[ 8] = 0; 689 output[12] = -(vMax.x()+vMin.x())/diffX; 690 691 const REAL diffY = vMax.y()-vMin.y(); 692 output[ 1] = 0; 693 output[ 5] = 2/diffY; 694 output[ 9] = 0; 695 output[13] = -(vMax.y()+vMin.y())/diffY; 696 697 const REAL diffZ = vMax.z()-vMin.z(); 698 output[ 2] = 0; 699 output[ 6] = 0; 700 output[10] = 2/diffZ; 701 output[14] = -(vMax.z()+vMin.z())/diffZ; 702 703 output[ 3] = 0; 704 output[ 7] = 0; 705 output[11] = 0; 706 output[15] = 1; 707 return output; 708 } 709 */ 710 679 711 680 712 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp
r2938 r2939 60 60 } 61 61 62 // first create near plane because of precision issues 63 clipPlanes.push_back(frustum.mClipPlanes[4]); 64 62 65 clipPlanes.push_back(frustum.mClipPlanes[0]); 63 66 clipPlanes.push_back(frustum.mClipPlanes[1]); … … 65 68 clipPlanes.push_back(frustum.mClipPlanes[3]); 66 69 clipPlanes.push_back(frustum.mClipPlanes[5]); 67 68 clipPlanes.push_back(frustum.mClipPlanes[4]);69 70 70 71 return Polyhedron::CreatePolyhedron(clipPlanes, sceneBox); … … 226 227 ) 227 228 { 228 //return IdentityMatrix();229 return IdentityMatrix(); 229 230 230 231 AxisAlignedBox3 bounds_ls = GetExtremalPoints(lightSpace, body); … … 235 236 236 237 //const float n = 1e2f; 237 const float n = 1e 2f;238 //const float n = ComputeN(bounds_ls) * 100;238 const float n = 1e6f; 239 //const float n = ComputeN(bounds_ls); 239 240 240 241 cout << "n: " << n << endl; … … 245 246 const Vector3 lsNear = lightSpace * nearPt; 246 247 247 // c start has the x and y coordinate of e, the z coord of the near plane of the light volume248 // the start point has the x and y coordinate of e, the z coord of the near plane of the light volume 248 249 const Vector3 startPt = Vector3(lsNear.x, lsNear.y, bounds_ls.Max().z); 249 250 //const Vector3 schas = lightSpace * mCamera->GetPosition(); … … 278 279 Matrix4x4 matLispSM; 279 280 280 matLispSM = GetFrustum(-1.0, 1.0, -1.0, 1.0, n, n + d * 1e10f);281 matLispSM = GetFrustum(-1.0, 1.0, -1.0, 1.0, n, n + d); 281 282 282 283 //cout << "lispsm\n" << matLispSM << endl; … … 405 406 406 407 VertexArray frustumPoints; 407 IncludeLightVolume(*polyhedron, frustumPoints, mShadowCam->GetDirection(), mSceneBox); 408 //Vector3 lightDir = Vector3(0, 0, -1); 409 IncludeLightVolume(*polyhedron, frustumPoints, mLight->GetDirection(), mSceneBox); 408 410 409 411 … … 445 447 lightProj *= frame; 446 448 447 cout << "here9\n" << lightProj << endl;448 449 //Matrix4x4 refl2 = ScaleMatrix(-1, -1, 1);450 //lightProj = refl2 * lightProj;451 452 449 const Matrix4x4 matLispSM = 453 450 CalcLispSMTransform(lightView * lightProj, extremalPoints, frustumPoints); … … 464 461 465 462 lightProj *= transformToGL; 466 //cout << "here4 \n" << lightProj << endl;467 463 468 464 AxisAlignedBox3 lightPts = GetExtremalPoints(lightView * lightProj, frustumPoints); 469 465 470 //cout << "max2: " << lightPts.Max() << endl; 471 //cout << "min2: " << lightPts.Min() << endl; 472 473 AxisAlignedBox3 dummyBox = GetExtremalPoints(IdentityMatrix(), frustumPoints); 474 466 cout << "max: " << lightPts.Max() << " min: " << lightPts.Min() << endl; 475 467 // focus projection matrix on the extremal points => scale to unit cube 476 //Matrix4x4 scaleTranslate = GetFittingProjectionMatrix(extremalPoints);477 468 Matrix4x4 scaleTranslate = GetFittingProjectionMatrix(lightPts); 478 lightProj = scaleTranslate * lightProj; 479 480 cout << "max: " << lightView * lightProj * dummyBox.Max() << endl; 481 cout << "min: " << lightView * lightProj * dummyBox.Min() << endl; 469 470 cout << "scaleTranslate:\n" << scaleTranslate << endl; 471 472 lightProj = lightProj * scaleTranslate; 473 474 Matrix4x4 mymat = lightView * lightProj; 475 476 AxisAlignedBox3 lightPtsNew = GetExtremalPoints(mymat, frustumPoints); 477 478 cout << "newmax: " << lightPtsNew.Max() << endl; 479 cout << "newmin: " << lightPtsNew.Min() << endl; 482 480 483 481 // we have to flip the signs in order to tranform to opengl right handed system … … 554 552 frustumPoints.push_back(v); 555 553 556 // hack: get point surelyoutside of box554 // hack: start at point which is guaranteed to be outside of box 557 555 v -= Magnitude(mSceneBox.Diagonal()) * lightDir; 558 556 … … 575 573 const float ylen = Magnitude(mSceneBox.Diagonal() * 0.5f); 576 574 577 //const Vector3 dir = mLight->GetDirection();578 const Vector3 dir(0, 0, -1);575 const Vector3 dir = mLight->GetDirection(); 576 //const Vector3 dir(0, 0, -1); 579 577 580 578 // set position so that we can see the whole scene … … 627 625 628 626 mLightProjView = lightView * lightProj; 629 ; 627 630 628 cout << "here3" << endl; 631 629 DEL_PTR(lightPoly); … … 690 688 void ShadowMap::RenderShadowView(RenderTraverser *renderer, const Matrix4x4 &projView) 691 689 { 692 //const Vector3 dir = mLight->GetDirection(); 693 const Vector3 dir(0, 0, -1); 694 690 const Vector3 dir = mLight->GetDirection(); 691 //const Vector3 dir(0, 0, -1); 692 693 cout << "dir: " << dir << endl; 695 694 mShadowCam->SetDirection(dir); 696 695 … … 735 734 lightPoly = CreatePolyhedron(mLightProjView, mSceneBox); 736 735 736 Frustum frustum(mLightProjView); 737 cout << "near: " << Normalize(frustum.mClipPlanes[4].mNormal) << endl; 738 cout << "far: " << Normalize(frustum.mClipPlanes[5].mNormal) << endl; 739 737 740 glMatrixMode(GL_MODELVIEW); 738 741 glPushMatrix(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r2936 r2939 70 70 int renderMode = RenderTraverser::CHCPLUSPLUS; 71 71 // eye near plane distance 72 float nearDist = 0. 1f;72 float nearDist = 0.5f; 73 73 float farDist = 1e6f; 74 74 /// the field of view
Note: See TracChangeset
for help on using the changeset viewer.