Changeset 2927


Ignore:
Timestamp:
09/10/08 10:50:21 (16 years ago)
Author:
mattausch
Message:
 
Location:
GTP/trunk/App/Demos/Vis/FriendlyCulling/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp

    r2926 r2927  
    1212 
    1313// our coordinate system has the positive z axis pointing up 
    14 static const Vector3 baseDir = Vector3::UNIT_Y(); 
     14static Vector3 baseDir = Vector3(0, 1, 0); 
    1515 
    1616 
     
    5151void Camera::Precompute(const Vector3 &direction)  
    5252{ 
    53         Vector3 up = Vector3::UNIT_Z(); 
    54         Vector3 right = Normalize(CrossProd(up, -direction)); 
    55         up = Normalize(CrossProd(-direction, right)); 
    56  
    57         mBaseOrientation = Matrix4x4(right, up, -direction); 
     53        Vector3 up = Vector3(0, 0, 1); 
     54        Vector3 right = Normalize(CrossProd(up, direction)); 
     55        up = Normalize(CrossProd(direction, right)); 
     56 
     57        mBaseOrientation = Matrix4x4(right, up, direction); 
    5858        mViewOrientation = mBaseOrientation; 
    5959} 
     
    8888        mat = mViewOrientation; 
    8989 
    90         const Vector3 pos = mViewOrientation * -mPosition; 
     90        Vector3 pos = mViewOrientation * -mPosition; 
    9191         
    9292        mat.x[3][0] = pos.x; 
    9393        mat.x[3][1] = pos.y; 
    94         mat.x[3][2] = -pos.z; 
     94        mat.x[3][2] = pos.z; 
    9595 
    9696        //glGetFloatv(GL_MODELVIEW_MATRIX, (float *)mat.x); 
     
    129129        Matrix4x4 viewOrientation = mViewOrientation; 
    130130 
    131         const Vector3 pos = mViewOrientation * -mPosition; 
     131        Vector3 pos = mViewOrientation * -mPosition; 
    132132 
    133133        viewOrientation.x[3][0] = pos.x; 
    134134        viewOrientation.x[3][1] = pos.y; 
    135         viewOrientation.x[3][2] = -pos.z; 
     135        viewOrientation.x[3][2] = pos.z; 
    136136 
    137137        glLoadMatrixf((float *)viewOrientation.x); 
     
    220220void Camera::SetDirection(const Vector3 &dir) 
    221221{ 
    222         Vector3 ndir = Normalize(dir); 
     222        Vector3 ndir = -Normalize(dir); 
    223223 
    224224        mPitch = -atan2(ndir.x, ndir.y); 
     
    243243Vector3 Camera::GetDirection() const 
    244244{  
    245         return Vector3(mViewOrientation.x[0][2], mViewOrientation.x[1][2], mViewOrientation.x[2][2]); 
     245        return -Vector3(mViewOrientation.x[0][2], mViewOrientation.x[1][2], mViewOrientation.x[2][2]); 
    246246} 
    247247 
     
    261261Vector3 Camera::GetBaseDirection() const 
    262262{  
    263         return Vector3(mBaseOrientation.x[0][2], mBaseOrientation.x[1][2], mBaseOrientation.x[2][2]); 
     263        return -Vector3(mBaseOrientation.x[0][2], mBaseOrientation.x[1][2], mBaseOrientation.x[2][2]); 
    264264} 
    265265 
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/chcdemo.cpp

    r2925 r2927  
    7070int renderMode = RenderTraverser::CHCPLUSPLUS; 
    7171// eye near plane distance 
    72 float nearDist = 2.0f;  
     72float nearDist = 0.1f; 
     73float farDist = 1e6f; 
    7374/// the field of view 
    7475float fov = 50.0f; 
     
    104105double accumulatedTime = 1000; 
    105106float fps = 1e3f; 
    106  
    107 float myfar = 0; 
    108107 
    109108glfont::GLFont myfont; 
     
    428427 
    429428        // set far plane based on scene extent 
    430         myfar = 10.0f * Magnitude(bvh->GetBox().Diagonal()); 
     429        farDist = 10.0f * Magnitude(bvh->GetBox().Diagonal()); 
    431430        bvh->SetVirtualLeaves(trianglesPerVirtualLeaf); 
    432431 
     
    512511                Material::sAmbientTexParam = cgGetNamedParameter(RenderState::sCgMrtFragmentTexProgram, "ambient"); 
    513512 
    514                 cgGLSetParameter1f(sMaxDepthParamTex, MAX_DEPTH_CONST / myfar); 
     513                cgGLSetParameter1f(sMaxDepthParamTex, MAX_DEPTH_CONST / farDist); 
    515514                //Debug << "maxdepth: " << MAX_DEPTH_CONST / myfar << endl; 
    516515        } 
     
    534533                Material::sAmbientParam = cgGetNamedParameter(RenderState::sCgMrtFragmentProgram, "ambient"); 
    535534 
    536                 cgGLSetParameter1f(sMaxDepthParam, MAX_DEPTH_CONST / myfar); 
     535                cgGLSetParameter1f(sMaxDepthParam, MAX_DEPTH_CONST / farDist); 
    537536        } 
    538537        else 
     
    791790        glLoadIdentity(); 
    792791 
    793         gluPerspective(fov, winAspectRatio, nearDist, myfar); 
     792        gluPerspective(fov, winAspectRatio, nearDist, farDist); 
    794793 
    795794        glMatrixMode(GL_MODELVIEW); 
     
    10251024                cgGLDisableProfile(RenderState::sCgFragmentProfile); 
    10261025 
    1027                 if (!ssaoShader) ssaoShader = new DeferredRenderer(texWidth, texHeight, camera, myfar / MAX_DEPTH_CONST); 
     1026                if (!ssaoShader) ssaoShader = new DeferredRenderer(texWidth, texHeight, camera, farDist / MAX_DEPTH_CONST); 
    10281027                 
    10291028                DeferredRenderer::SHADING_METHOD shadingMethod; 
     
    13731372        glLoadIdentity(); 
    13741373 
    1375         gluPerspective(fov, winAspectRatio, nearDist, myfar); 
     1374        gluPerspective(fov, winAspectRatio, nearDist, farDist); 
    13761375 
    13771376        glMatrixMode(GL_MODELVIEW); 
Note: See TracChangeset for help on using the changeset viewer.