Commit 419c57e5 authored by Andreas Neu's avatar Andreas Neu
Browse files

-Bug fixes in camera coordinate system calculation.

parent 3f055220
......@@ -80,20 +80,20 @@ public:
}
~Camera(void) {}
inline float getAspectRatio () const { return (float)mWidth / (float)mHeight; }
inline const glm::vec3& getUpDirection () const { return mUp; }
inline const glm::vec3& getRightDirection () const { return mRight; }
inline const glm::vec3& getForwardDirection () const { return mForward; }
inline int_t getWidth () const { return mWidth; }
inline int_t getHeight () const { return mHeight; }
inline float getFOV () const { return mFOV; }
inline float getNear () const { return mNear; }
inline float getFar () const { return mFar; }
inline float getPitch () const { return mPitch; }
inline float getYaw () const { return mYaw; }
inline float getRoll () const { return mRoll; }
inline const glm::vec3& getPosition () const { return mPosition; }
inline const glm::vec3& getTarget () const { return mTarget; }
inline float getAspectRatio (void) const { return (float)mWidth / (float)mHeight; }
inline const glm::vec3& getUpDirection (void) const { return mUp; }
inline const glm::vec3& getRightDirection (void) const { return mRight; }
inline const glm::vec3& getForwardDirection (void) const { return mForward; }
inline int_t getWidth (void) const { return mWidth; }
inline int_t getHeight (void) const { return mHeight; }
inline float getFOV (void) const { return mFOV; }
inline float getNear (void) const { return mNear; }
inline float getFar (void) const { return mFar; }
inline float getPitch (void) const { return mPitch; }
inline float getYaw (void) const { return mYaw; }
inline float getRoll (void) const { return mRoll; }
inline const glm::vec3& getPosition (void) const { return mPosition; }
inline const glm::vec3& getTarget (void) const { return mTarget; }
inline void setWidth (int_t _width) { mWidth = _width; }
inline void setHeight (int_t _height) { mHeight = _height; }
......@@ -136,12 +136,14 @@ public:
{
mPitch = _pitch;
updateLocalCoordinateSystemByOrientation();
mTarget = mPosition + glm::length(mTarget - mPosition) * mForward;
}
inline void setYaw(float _yaw)
{
mYaw = _yaw;
updateLocalCoordinateSystemByOrientation();
mTarget = mPosition + glm::length(mTarget - mPosition) * mForward;
}
inline void setRoll(float _roll)
......@@ -177,8 +179,8 @@ public:
private:
void updateLocalCoordinateSystemByTarget(const glm::vec3& _up = glm::vec3(0.0f, 1.0f, 0.0f));
void updateLocalCoordinateSystemByOrientation(bool _moveTarget = true);
void updateOrientationByLocalCoordinateSystem();
void updateLocalCoordinateSystemByOrientation(void);
void updateOrientationByLocalCoordinateSystem(void);
glm::vec3 mRight;
glm::vec3 mUp;
......
......@@ -58,7 +58,7 @@ void Camera::updateLocalCoordinateSystemByTarget(const glm::vec3& _up)
}
void Camera::updateLocalCoordinateSystemByOrientation(bool _moveTarget)
void Camera::updateLocalCoordinateSystemByOrientation(void)
{
//Calculate the full rotation in the right order:
//rot => 1. mYaw (y) -> 2. mPitch (x) -> 3. mRoll (z)
......@@ -71,11 +71,6 @@ void Camera::updateLocalCoordinateSystemByOrientation(bool _moveTarget)
mRight = rotation * glm::vec3(1.0f, 0.0f, 0.0f);
mUp = rotation * glm::vec3(0.0f, 1.0f, 0.0f);
mForward = rotation * glm::vec3(0.0f, 0.0f, -1.0f);
if(_moveTarget)
{
mTarget = mPosition + (rotation * (mTarget - mPosition));
}
}
void Camera::updateOrientationByLocalCoordinateSystem(void)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment