Changeset 2838 for GTP


Ignore:
Timestamp:
07/15/08 16:18:50 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/default.env

    r2837 r2838  
    1010winHeight=768 
    1111camPosition=483.398f 242.364f 186.078f 
     12camDirection=1 1 0 
    1213useFullScreen=0 
    13 numSsaoSamples=8 
     14 
     15############ 
     16# shader stuff 
     17expFactor=0.1f 
     18#numSsaoSamples=8 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp

    r2834 r2838  
    4848        */ 
    4949        Vector3 up = Vector3(0, 0, 1); 
    50         Vector3 right = -Normalize(-CrossProd(direction, up)); 
    51         up = -Normalize(CrossProd(right, direction)); 
     50        Vector3 right = Normalize(CrossProd(up, direction)); 
     51        up = Normalize(CrossProd(direction, right)); 
    5252 
    5353        mBaseOrientation = Matrix4x4(right, up, direction); 
    5454        mViewOrientation = mBaseOrientation; 
     55 
     56        cout << "right: " << right << endl; 
     57        cout << "up:    " << up << endl; 
     58        cout << "dir:   " << direction << endl; 
    5559} 
    5660 
     
    181185        const Vector3 fc = mPosition + view * z_far;  
    182186         
    183         const Vector3 up = -GetUpVector(); 
    184  
     187        const Vector3 up = GetUpVector(); 
    185188        const Vector3 right = GetRightVector(); 
    186189 
     
    229232void Camera::SetDirection(const Vector3 &direction) 
    230233{ 
    231         Vector3 h1 = direction; h1.z = 0; h1.Normalize(); 
    232         Vector3 h2 = direction; h1.x = 0; h2.Normalize(); 
    233  
    234         mYaw = acos(DotProd(h1, Vector3(0, 1, 0))); 
    235         mPitch = acos(DotProd(h2, Vector3(0, 1, 0))); 
    236  
     234        Vector3 h1 = direction; h1.z = 0;  
     235         
     236        if (SqrMagnitude(h1) > 0) 
     237        { 
     238                h1.Normalize(); 
     239                mPitch = acos(DotProd(h1, Vector3(0, 1, 0))); 
     240        } 
     241 
     242        Vector3 h2 = direction;// h2.x = 0;  
     243         
     244        if (SqrMagnitude(h2) > 0) 
     245        { 
     246                h2.Normalize(); 
     247                mYaw = -acos(DotProd(h2, h1));//Vector3(0, 1, 0))); 
     248        } 
     249 
     250        cout<<"here2 " << DotProd(h1, Vector3(0, 1, 0)) << " " << mPitch << endl; 
    237251        CalculateFromPitchAndYaw(); 
    238252} 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.h

    r2829 r2838  
    7878        float GetPitch() const { return mPitch; } 
    7979        float GetYaw() const { return mYaw; } 
     80        void ResetPitchAndYaw() { mPitch = 0; mYaw = 0; } 
    8081        /** Sets the camera direction. 
    8182        */ 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/SceneQuery.cpp

    r2834 r2838  
    131131 
    132132        orthoCam->SetNear(0.0f); 
    133         orthoCam->Yaw(M_PI * 0.5f); 
     133        orthoCam->Yaw(-M_PI * 0.5f); 
    134134 
    135135        Vector3 pos = Vector3(mSceneBox.Center().x, mSceneBox.Center().y, mSceneBox.Max().z); 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2837 r2838  
    315315 
    316316        Vector3 camPos(.0f, .0f, .0f); 
     317        Vector3 camDir(.0f, 1.0f, .0f); 
    317318 
    318319        cout << "=== reading environment file === " << endl; 
     
    336337 
    337338                env.GetBoolParam(string("useFullScreen"), useFullScreen); 
     339                env.GetFloatParam(string("expFactor"), expFactor); 
     340                env.GetVectorParam(string("camPosition"), camPos); 
     341                env.GetVectorParam(string("camDirection"), camDir); 
     342 
    338343                //env.GetIntParam(string("numSssaoSamples"), numSsaoSamples); 
    339                 env.GetFloatParam(string("expFactor"), expFactor); 
    340  
    341                 env.GetVectorParam(string("camPosition"), camPos); 
    342344 
    343345                cout << "assumedVisibleFrames: " << assumedVisibleFrames << endl;  
     
    359361        camera->SetNear(nearDist); 
    360362         
    361         camera->Pitch(-M_PI * 0.5); 
     363        camera->SetDirection(camDir); 
    362364        camera->SetPosition(camPos); 
    363365 
     
    457459        visualization = new Visualization(bvh, camera, NULL, &state); 
    458460 
    459         sceneQuery = new SceneQuery(bvh->GetBox(), traverser); 
     461        //sceneQuery = new SceneQuery(bvh->GetBox(), traverser); 
    460462 
    461463 
     
    656658        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, colorsBuffer); 
    657659         
    658         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA16F_ARB, texWidth, texHeight); 
     660        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA32F_ARB, texWidth, texHeight); 
    659661        int samples = 8; 
    660662        //glEnable(GL_MULTISAMPLE_ARB); 
     
    665667        glBindTexture(GL_TEXTURE_2D, colorsTex); 
    666668 
    667         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
     669        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
    668670        //glGenerateMipmapEXT(GL_TEXTURE_2D); 
    669671        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, colorsTex, 0); 
     
    751753        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, colorsBuffer1); 
    752754         
    753         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA16F_ARB, texWidth, texHeight); 
     755        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA32F_ARB, texWidth, texHeight); 
    754756        glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, colorsBuffer1); 
    755757         
     
    757759        glBindTexture(GL_TEXTURE_2D, colorsTex1); 
    758760 
    759         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
     761        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
    760762        //glGenerateMipmapEXT(GL_TEXTURE_2D); 
    761763        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, colorsTex1, 0); 
     
    786788        glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, colorsBuffer2); 
    787789         
    788         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA16F_ARB, texWidth, texHeight); 
     790        glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGBA32F_ARB, texWidth, texHeight); 
    789791        glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, colorsBuffer2); 
    790792         
     
    792794        glBindTexture(GL_TEXTURE_2D, colorsTex2); 
    793795 
    794         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA16F_ARB, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
     796        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA32F_ARB, texWidth, texHeight, 0, GL_RGBA, GL_FLOAT, NULL); 
    795797        //glGenerateMipmapEXT(GL_TEXTURE_2D); 
    796798        glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, colorsTex2, 0); 
     
    798800        //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); 
    799801        //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR); 
     802 
    800803        //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); 
    801804        //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); 
     
    16781681        AxisAlignedBox3 box = bvh->GetBox(); 
    16791682 
    1680         // set far for viz 
     1683        // hack: set far plane for viz 
    16811684        camera->SetFar(0.35f * Magnitude(box.Diagonal())); 
    16821685 
    16831686        const float offs = box.Size().x * 0.3f; 
    16841687         
    1685         Vector3 pos = camera->GetPosition(); 
    1686  
    1687         Vector3 vizpos = Vector3(box.Min().x + 20, box.Min().y + 500, box.Min().z + box.Size().z * 50); 
     1688        //Vector3 vizpos = Vector3(box.Min().x, box.Min().y + box.Size().y * 0.5f, box.Min().z + box.Size().z * 50); 
     1689        Vector3 vizpos = Vector3(box.Min().x, box.Min().y  - box.Size().y * 0.35f, box.Min().z + box.Size().z * 50); 
    16881690         
    16891691        visCamera->SetPosition(vizpos); 
    1690          
     1692        visCamera->ResetPitchAndYaw(); 
     1693        //visCamera->Pitch(M_PI); 
     1694 
    16911695        glPushAttrib(GL_VIEWPORT_BIT); 
    16921696        glViewport(winWidth - winWidth / 3, winHeight - winHeight / 3, winWidth / 3, winHeight / 3); 
     
    17041708        visCamera->SetupCameraView(); 
    17051709 
     1710        //Matrix4x4 rotX = RotationXMatrix(camera->GetYaw()); 
     1711        //glMultMatrixf((float *)rotX.x); 
    17061712        Matrix4x4 rotZ = RotationZMatrix(-camera->GetPitch()); 
    17071713        glMultMatrixf((float *)rotZ.x); 
    17081714 
     1715        Vector3 pos = camera->GetPosition(); 
    17091716        glTranslatef(-pos.x, -pos.y, -pos.z); 
    17101717 
     
    19911998        Vector3 playerPos = camera->GetPosition(); 
    19921999 
    1993         bool validIntersect = sceneQuery->CalcIntersection(playerPos); 
     2000        bool validIntersect = false;//sceneQuery->CalcIntersection(playerPos); 
    19942001 
    19952002        if (validIntersect && 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/shaders/deferred.cg

    r2837 r2838  
    253253        if ((tex.x >= 0.0f) && (tex.x < 1.0f) &&  
    254254                (tex.y >= 0.0f) && (tex.y < 1.0f) &&  
    255                 (abs(depthDif)  < 9e-4f)) 
     255                (abs(depthDif)  < 8e-5f)) 
    256256                OUT.color = attenuated_color * expFactor + col1 * float4(1.0f - expFactor); 
    257257        else 
Note: See TracChangeset for help on using the changeset viewer.