Changeset 525 for trunk/VUT/GtpVisibilityPreprocessor/src
- Timestamp:
- 01/12/06 14:27:18 (19 years ago)
- Location:
- trunk/VUT/GtpVisibilityPreprocessor/src
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/VUT/GtpVisibilityPreprocessor/src/Beam.cpp
r522 r525 67 67 68 68 69 void Beam::ComputeFrustum(float &near, float &far, 70 float &left, float &right, 69 void Beam::ComputeFrustum(float &left, float &right, 71 70 float &bottom, float &top, 72 const AxisAlignedBox3 &sceneBBox) 71 float &near, float &far, 72 const AxisAlignedBox3 &sceneBBox) const 73 73 { 74 74 const float xDirRange = mDirBox.Max().x - mDirBox.Min().x; 75 75 const float yDirRange = mDirBox.Max().y - mDirBox.Min().y; 76 76 77 near = 1; // NOTE: what is the best value for near and far plane?78 far = sceneBBox.Size(sceneBBox.Size().DrivingAxis());77 near = 0.1; // NOTE: what is the best value for near and far plane? 78 far = 2.0f * Magnitude(sceneBBox.Diagonal()); 79 79 80 left = 1.0f/ tan(xDirRange * 0.5);81 right = 1.0f/ tan(xDirRange * 0.5);80 left = near / tan(xDirRange * 0.5); 81 right = near / tan(xDirRange * 0.5); 82 82 83 bottom = 1.0f/ tan(yDirRange * 0.5);84 top = 1.0f/ tan(yDirRange * 0.5);83 bottom = near / tan(yDirRange * 0.5); 84 top = near / tan(yDirRange * 0.5); 85 85 } 86 87 Vector3 Beam::GetMainDirection() const 88 { 89 Vector3 directions[4]; 90 91 directions[0] = VssRay::GetDirection(dBox.Min().x, dBox.Min().y); 92 directions[1] = VssRay::GetDirection(dBox.Max().x, dBox.Min().y); 93 directions[2] = VssRay::GetDirection(dBox.Max().x, dBox.Max().y); 94 directions[3] = VssRay::GetDirection(dBox.Min().x, dBox.Max().y); 95 96 return Normalize(direction[0], direction[1], direction[2], direction[3]); 97 } -
trunk/VUT/GtpVisibilityPreprocessor/src/Beam.h
r522 r525 35 35 const AxisAlignedBox3 &dBox); 36 36 37 void ComputeFrustum(float &near, float &far, 38 float &left, float &right, 37 void ComputeFrustum(float &left, float &right, 39 38 float &bottom, float &top, 40 const AxisAlignedBox3 &sceneBBox); 39 float &near, float &far, 40 const AxisAlignedBox3 &sceneBBox) const; 41 41 42 42 int ComputeIntersection(const AxisAlignedBox3 &box); 43 44 Vector3 GetMainDirection() const; 43 45 44 46 bool IsValid() { return mFlags & VALID; } -
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp
r524 r525 53 53 static void handleCgError() 54 54 { 55 fprintf(stderr, "Cg error: %s\n", cgGetErrorString(cgGetError()));55 Debug << "Cg error: " << cgGetErrorString(cgGetError()) << endl; 56 56 exit(1); 57 57 } … … 639 639 { 640 640 // 1. setup the view port to match the desired samples 641 glViewport(0, 0, desiredSamples, desiredSamples); 642 641 643 // 2. setup the projection matrix and view matrix to match the viewpoint + beam.mDirBox 642 644 SetupProjectionForViewPoint(viewPoint, beam, sourceObject); 645 643 646 // 3. reset z-buffer to 0 and render the source object for the beam 644 647 // with glCullFace(Enabled) and glFrontFace(GL_CW) … … 740 743 { 741 744 glBeginOcclusionQueryNV(sQueries[queryIdx ++]); 742 745 743 746 RenderIntersectable(*vit); 744 747 745 748 glEndOcclusionQueryNV(); 746 749 } … … 785 788 } 786 789 } 790 791 void GlRendererBuffer::SetupProjectionForViewPoint(const Vector3 &viewPoint, 792 const Beam &beam, 793 Intersectable *sourceObject) 794 { 795 float left, right, bottom, top, znear, zfar; 796 797 beam.ComputeFrustum(left, right, bottom, top, znear, zfar, 798 mSceneGraph->GetBox()); 799 800 glFrustum(left, right, bottom, top, znear, zfar); 801 802 const Vector3 eye = viewPoint + beam.GetMainDirection; 803 const Vector3 up = AbitraryNormal(eye); 804 805 gluLookAt(eye, viewPoint, up); 806 } -
trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.h
r514 r525 175 175 private: 176 176 static void GenQueries(const int numQueries); 177 177 void SetupProjectionForViewPoint(const Vector3 &viewPoint, 178 const Beam &beam, 179 Intersectable *sourceObject); 178 180 }; 179 181
Note: See TracChangeset
for help on using the changeset viewer.