Changeset 3063
- Timestamp:
- 10/23/08 16:37:00 (16 years ago)
- Location:
- GTP/trunk/App/Demos/Vis/FriendlyCulling/src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp
r3062 r3063 116 116 { 117 117 mNear = nearDist; 118 UpdateProjectionMatrix(); 118 119 } 119 120 … … 122 123 { 123 124 mFar = farDist; 125 UpdateProjectionMatrix(); 124 126 } 125 127 … … 272 274 273 275 276 void Camera::GetProjectionMatrix(Matrix4x4 &m)const 277 { 278 m = mProjection; 279 } 280 281 274 282 /*********************************************************/ 275 283 /* Class PerspectiveCamera implementation */ … … 280 288 { 281 289 mFOVy = 60.0f * M_PI / 180.0f; 290 mAspect = 1.0f; 291 292 UpdateProjectionMatrix(); 282 293 } 283 294 … … 287 298 mFOVy = fieldOfView * M_PI / 180.0f; 288 299 mAspect = aspect; 300 301 UpdateProjectionMatrix(); 289 302 } 290 303 … … 384 397 385 398 386 void PerspectiveCamera::GetProjectionMatrix(Matrix4x4 &mat) const 387 { 388 mat = GetPerspective(mFOVy, 1.0f / mAspect, mNear, mFar); 389 390 Matrix4x4 mat2; 391 glGetFloatv(GL_PROJECTION_MATRIX, (float *)mat2.x); 392 393 cout << "my projview:\n" << mat << endl; 394 cout << "gl projview:\n" << mat2 << endl; 395 } 396 397 398 } 399 void PerspectiveCamera::UpdateProjectionMatrix() 400 { 401 mProjection = GetPerspective(mFOVy, 1.0f / mAspect, mNear, mFar); 402 } 403 404 405 } -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.h
r3062 r3063 72 72 /** Returns the current projection matrix. 73 73 */ 74 v irtual void GetProjectionMatrix(Matrix4x4 &mat) const = 0;74 void GetProjectionMatrix(Matrix4x4 &mat) const; 75 75 /** Returns the current model view matrix. 76 76 */ … … 121 121 protected: 122 122 123 virtual void UpdateProjectionMatrix() = 0; 124 123 125 void Precompute(const Vector3 &direction); 124 126 … … 134 136 Matrix4x4 mBaseOrientation; 135 137 Matrix4x4 mViewOrientation; 138 139 Matrix4x4 mProjection; 136 140 137 141 float mPitch; … … 161 165 */ 162 166 inline float GetAspect() const { return mAspect; } 163 /** Returns the current projection matrix.164 */165 virtual void GetProjectionMatrix(Matrix4x4 &mat) const;166 167 /** Computes the extremal points of this frustum. 167 168 If farthestVisibleDistance is nearer than the far plane, … … 177 178 178 179 protected: 180 /** Calculates the current projection matrix. 181 */ 182 virtual void UpdateProjectionMatrix(); 179 183 180 184 void ComputePointsInternal(Vector3 &ftl, Vector3 &ftr, Vector3 &fbl, Vector3 &fbr, -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/DeferredRenderer.cpp
r3062 r3063 527 527 sCgSsaoProgram->SetValue3f(10, tr.x, tr.y, tr.z); 528 528 529 cout << "new projview:\n" << projViewMatrix << endl;530 cout << "old projview:\n" << oldProjViewMatrix << endl;529 //cout << "new projview:\n" << projViewMatrix << endl; 530 //cout << "old projview:\n" << oldProjViewMatrix << endl; 531 531 532 532 sCgSsaoProgram->SetMatrix(11, projViewMatrix); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/ShadowMapping.cpp
r3062 r3063 335 335 336 336 #if 0 337 337 338 Vector3 ShadowMap::GetNearCameraPointE(const VertexArray &pts) const 338 339 { … … 545 546 } 546 547 548 547 549 unsigned int ShadowMap::GetShadowColorTexture() const 548 550 { … … 562 564 polyhedron.CollectVertices(vertices); 563 565 564 // we 'look' at each point and calculate intersections of rays withscene bounding box566 // we 'look' at each point and intect rays with the scene bounding box 565 567 VertexArray::const_iterator it, it_end = vertices.end(); 566 568 … … 570 572 571 573 frustumPoints.push_back(v); 572 573 574 // hack: start at point which is guaranteed to be outside of box 574 575 v -= Magnitude(mSceneBox.Diagonal()) * lightDir; … … 587 588 588 589 589 void ShadowMap::ComputeShadowMap(RenderTraverser *renderer, const Matrix4x4 &projView) 590 void ShadowMap::ComputeShadowMap(RenderTraverser *renderer, 591 const Matrix4x4 &projView) 590 592 { 591 593 mFbo->Bind(); … … 607 609 _Render(renderer); 608 610 611 glPopAttrib(); 612 613 glShadeModel(GL_SMOOTH); 614 glEnable(GL_LIGHTING); 615 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE); 616 617 #if 0 618 float *data = new float[mSize * mSize]; 619 620 GrabDepthBuffer(data, mFbo->GetDepthTex()); 621 ExportDepthBuffer(data, mSize); 622 623 delete [] data; 624 625 PrintGLerror("shadow map"); 626 #endif 627 609 628 610 629 ////////////// … … 618 637 mTextureMatrix = mLightProjView * biasMatrix; 619 638 620 glPopAttrib();621 622 glShadeModel(GL_SMOOTH);623 glEnable(GL_LIGHTING);624 glColorMask(GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE);625 626 #if 0627 float *data = new float[mSize * mSize];628 629 GrabDepthBuffer(data, mFbo->GetDepthTex());630 ExportDepthBuffer(data, mSize);631 632 delete [] data;633 634 PrintGLerror("shadow map");635 #endif636 637 639 FrameBufferObject::Release(); 638 640 } 639 641 640 642 641 void ShadowMap::RenderShadowView(RenderTraverser *renderer, const Matrix4x4 &projView) 643 void ShadowMap::RenderShadowView(RenderTraverser *renderer, 644 const Matrix4x4 &projView) 642 645 { 643 646 glEnable(GL_LIGHTING); … … 671 674 mShadowCam->SetPosition(mCamera->GetPosition()); 672 675 673 Vector3 upVec = CalcUpVec(mCamera->GetDirection(), dir);674 Matrix4x4 lightView = LookAt(mShadowCam->GetPosition(), dir, upVec);676 const Vector3 upVec = CalcUpVec(mCamera->GetDirection(), dir); 677 const Matrix4x4 lightView = LookAt(mShadowCam->GetPosition(), dir, upVec); 675 678 676 679 mShadowCam->mViewOrientation = lightView; … … 684 687 CalcLightProjection(lightProj); 685 688 689 mLightProjView = lightView * lightProj; 690 691 DEL_PTR(lightPoly); 692 lightPoly = CreatePolyhedron(mLightProjView, mSceneBox); 693 686 694 glMatrixMode(GL_PROJECTION); 687 695 glPushMatrix(); 688 glLoadMatrixf((float *)lightProj.x);689 690 mLightProjView = lightView * lightProj;691 692 DEL_PTR(lightPoly);693 lightPoly = CreatePolyhedron(mLightProjView, mSceneBox);694 696 695 697 glMatrixMode(GL_MODELVIEW); 696 698 glPushMatrix(); 697 699 698 mShadowCam->SetupCameraView(); 700 // set projection matrix manually 701 mShadowCam->mProjection = lightProj; 702 703 // load gl view projection 704 mShadowCam->SetupViewProjection(); 699 705 700 706 -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.cpp
r3062 r3063 104 104 105 105 106 void Visualization::Render( )106 void Visualization::Render(bool showShadowFrustra) 107 107 { 108 108 stack<BvhNode *> tStack; … … 153 153 RenderFrustum(); 154 154 155 ShadowMap::VisualizeFrustra(); 155 if (showShadowFrustra) 156 ShadowMap::VisualizeFrustra(); 156 157 157 158 Vector3 pos = mCamera->GetPosition(); -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Visualization.h
r3062 r3063 27 27 28 28 ~Visualization(); 29 30 29 /** Renders the visualizatioin 31 30 */ 32 void Render( );31 void Render(bool showShadowFrustra); 33 32 /** Sets the scene hierarchy. 34 33 */ … … 36 35 /** Sets the visualization camera. 37 36 */ 38 void SetVizCamera(Camera *cam) {mVizCamera = cam;}37 void SetVizCamera(Camera *cam) { mVizCamera = cam; } 39 38 /** Sets the currently used scene camera. 40 39 */ 41 void SetCamera(PerspectiveCamera *cam) {mCamera = cam;}40 void SetCamera(PerspectiveCamera *cam) {mCamera = cam; } 42 41 /** Sets the current render state 43 42 */ … … 49 48 */ 50 49 void RenderFrustum(); 50 51 51 52 52 protected: -
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp
r3062 r3063 880 880 int oldRenderMethod = renderMethod; 881 881 // for rendering the light view, we use forward rendering 882 if (renderLightView) 883 renderMethod = RenderState::FORWARD; 882 if (renderLightView) renderMethod = RenderState::FORWARD; 884 883 885 884 /// enable vbo vertex array … … 1601 1600 //-- visualization of the occlusion culling 1602 1601 1603 visualization->Render( );1602 visualization->Render(showShadowMap); 1604 1603 1605 1604 … … 1948 1947 glDisable(GL_CULL_FACE); 1949 1948 state.LockCullFaceEnabled(true); 1950 1949 /// don't use alphatocoverage 1951 1950 state.SetUseAlphaToCoverage(false); 1952 1951 … … 1967 1966 1968 1967 glEnableClientState(GL_NORMAL_ARRAY); 1969 1970 1968 // change back state 1971 1969 BvhNode::SetCurrentState(CAMERA_PASS);
Note: See TracChangeset
for help on using the changeset viewer.