- Timestamp:
- 09/10/08 08:45:41 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/Camera.cpp
r2918 r2926 12 12 13 13 // our coordinate system has the positive z axis pointing up 14 static Vector3 baseDir = Vector3(0, 1, 0);14 static const Vector3 baseDir = Vector3::UNIT_Y(); 15 15 16 16 … … 51 51 void Camera::Precompute(const Vector3 &direction) 52 52 { 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); 58 58 mViewOrientation = mBaseOrientation; 59 59 } … … 88 88 mat = mViewOrientation; 89 89 90 Vector3 pos = mViewOrientation * -mPosition;90 const Vector3 pos = mViewOrientation * -mPosition; 91 91 92 92 mat.x[3][0] = pos.x; 93 93 mat.x[3][1] = pos.y; 94 mat.x[3][2] = pos.z;94 mat.x[3][2] = -pos.z; 95 95 96 96 //glGetFloatv(GL_MODELVIEW_MATRIX, (float *)mat.x); … … 129 129 Matrix4x4 viewOrientation = mViewOrientation; 130 130 131 Vector3 pos = mViewOrientation * -mPosition;131 const Vector3 pos = mViewOrientation * -mPosition; 132 132 133 133 viewOrientation.x[3][0] = pos.x; 134 134 viewOrientation.x[3][1] = pos.y; 135 viewOrientation.x[3][2] = pos.z;135 viewOrientation.x[3][2] = -pos.z; 136 136 137 137 glLoadMatrixf((float *)viewOrientation.x); … … 220 220 void Camera::SetDirection(const Vector3 &dir) 221 221 { 222 Vector3 ndir = -Normalize(dir);222 Vector3 ndir = Normalize(dir); 223 223 224 224 mPitch = -atan2(ndir.x, ndir.y); … … 243 243 Vector3 Camera::GetDirection() const 244 244 { 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]); 246 246 } 247 247 … … 261 261 Vector3 Camera::GetBaseDirection() const 262 262 { 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]); 264 264 } 265 265
Note: See TracChangeset
for help on using the changeset viewer.