Changeset 525


Ignore:
Timestamp:
01/12/06 14:27:18 (18 years ago)
Author:
mattausch
Message:
 
Location:
trunk/VUT/GtpVisibilityPreprocessor/src
Files:
1 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/VUT/GtpVisibilityPreprocessor/src/Beam.cpp

    r522 r525  
    6767 
    6868 
    69 void Beam::ComputeFrustum(float &near, float &far, 
    70                                                   float &left, float &right, 
     69void Beam::ComputeFrustum(float &left, float &right, 
    7170                                                  float &bottom, float &top, 
    72                                                   const AxisAlignedBox3 &sceneBBox) 
     71                                                  float &near, float &far, 
     72                                                  const AxisAlignedBox3 &sceneBBox) const 
    7373{ 
    7474        const float xDirRange = mDirBox.Max().x - mDirBox.Min().x; 
    7575        const float yDirRange = mDirBox.Max().y - mDirBox.Min().y; 
    7676 
    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()); 
    7979 
    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); 
    8282 
    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); 
    8585} 
     86 
     87Vector3 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  
    3535          const AxisAlignedBox3 &dBox); 
    3636   
    37   void ComputeFrustum(float &near, float &far, 
    38                                           float &left, float &right, 
     37  void ComputeFrustum(float &left, float &right, 
    3938                                          float &bottom, float &top, 
    40                                           const AxisAlignedBox3 &sceneBBox); 
     39                                          float &near, float &far, 
     40                                          const AxisAlignedBox3 &sceneBBox) const; 
    4141 
    4242  int ComputeIntersection(const AxisAlignedBox3 &box); 
     43 
     44  Vector3 GetMainDirection() const; 
    4345 
    4446  bool IsValid() { return mFlags & VALID; } 
  • trunk/VUT/GtpVisibilityPreprocessor/src/GlRenderer.cpp

    r524 r525  
    5353static void handleCgError()  
    5454{ 
    55     fprintf(stderr, "Cg error: %s\n", cgGetErrorString(cgGetError())); 
     55    Debug << "Cg error: " << cgGetErrorString(cgGetError()) << endl; 
    5656    exit(1); 
    5757} 
     
    639639{ 
    640640        // 1. setup the view port to match the desired samples 
     641        glViewport(0, 0, desiredSamples, desiredSamples); 
     642 
    641643        // 2. setup the projection matrix and view matrix to match the viewpoint + beam.mDirBox 
    642    
     644        SetupProjectionForViewPoint(viewPoint, beam, sourceObject); 
     645         
    643646        // 3. reset z-buffer to 0 and render the source object for the beam 
    644647        //    with glCullFace(Enabled) and glFrontFace(GL_CW) 
     
    740743        { 
    741744                glBeginOcclusionQueryNV(sQueries[queryIdx ++]); 
    742    
     745 
    743746                RenderIntersectable(*vit); 
    744    
     747                 
    745748                glEndOcclusionQueryNV(); 
    746749        } 
     
    785788        } 
    786789} 
     790 
     791void 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  
    175175private: 
    176176        static void GenQueries(const int numQueries); 
    177  
     177        void SetupProjectionForViewPoint(const Vector3 &viewPoint,  
     178                                                                         const Beam &beam,  
     179                                                                         Intersectable *sourceObject); 
    178180}; 
    179181 
Note: See TracChangeset for help on using the changeset viewer.