Changeset 2926 for GTP/trunk


Ignore:
Timestamp:
09/10/08 08:45:41 (16 years ago)
Author:
mattausch
Message:
 
File:
1 edited

Legend:

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

    r2918 r2926  
    1212 
    1313// our coordinate system has the positive z axis pointing up 
    14 static Vector3 baseDir = Vector3(0, 1, 0); 
     14static const Vector3 baseDir = Vector3::UNIT_Y(); 
    1515 
    1616 
     
    5151void Camera::Precompute(const Vector3 &direction)  
    5252{ 
    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); 
     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); 
    5858        mViewOrientation = mBaseOrientation; 
    5959} 
     
    8888        mat = mViewOrientation; 
    8989 
    90         Vector3 pos = mViewOrientation * -mPosition; 
     90        const 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         Vector3 pos = mViewOrientation * -mPosition; 
     131        const 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 
Note: See TracChangeset for help on using the changeset viewer.