diff --git a/apps/openmw/mwrender/camera.cpp b/apps/openmw/mwrender/camera.cpp index 251f7f593..148aa33ed 100644 --- a/apps/openmw/mwrender/camera.cpp +++ b/apps/openmw/mwrender/camera.cpp @@ -62,7 +62,7 @@ namespace MWRender mViewModeToggleQueued(false), mCameraDistance(0.f), mThirdPersonMode(ThirdPersonViewMode::Standard), - mOverShoulderHorizontalOffset(30.0f), + mOverShoulderOffset(osg::Vec2f(30.0f, -10.0f)), mSmoothTransitionToCombatMode(0.f) { mVanity.enabled = false; @@ -120,8 +120,8 @@ namespace MWRender osg::Vec3d offset(0, 0, 10.f); if (mThirdPersonMode == ThirdPersonViewMode::OverShoulder && !mPreviewMode && !mVanity.enabled) { - float horizontalOffset = mOverShoulderHorizontalOffset * (1.f - mSmoothTransitionToCombatMode); - float verticalOffset = mSmoothTransitionToCombatMode * 15.f + (1.f - mSmoothTransitionToCombatMode) * -10.f; + float horizontalOffset = mOverShoulderOffset.x() * (1.f - mSmoothTransitionToCombatMode); + float verticalOffset = mSmoothTransitionToCombatMode * 15.f + (1.f - mSmoothTransitionToCombatMode) * mOverShoulderOffset.y(); offset.x() += horizontalOffset * cos(getYaw()); offset.y() += horizontalOffset * sin(getYaw()); @@ -216,6 +216,11 @@ namespace MWRender updateSmoothTransitionToCombatMode(duration); } + void Camera::setOverShoulderOffset(float horizontal, float vertical) + { + mOverShoulderOffset = osg::Vec2f(horizontal, vertical); + } + void Camera::updateSmoothTransitionToCombatMode(float duration) { bool combatMode = true; diff --git a/apps/openmw/mwrender/camera.hpp b/apps/openmw/mwrender/camera.hpp index bdcb69297..c04bf31c2 100644 --- a/apps/openmw/mwrender/camera.hpp +++ b/apps/openmw/mwrender/camera.hpp @@ -59,7 +59,7 @@ namespace MWRender float mCameraDistance; ThirdPersonViewMode mThirdPersonMode; - float mOverShoulderHorizontalOffset; + osg::Vec2f mOverShoulderOffset; osg::Vec3d mFocalPointAdjustment; // Makes sense only if mThirdPersonMode is OverShoulder. Can be in range [0, 1]. @@ -77,7 +77,7 @@ namespace MWRender MWWorld::Ptr getTrackingPtr() const; void setThirdPersonViewMode(ThirdPersonViewMode mode) { mThirdPersonMode = mode; } - void setOverShoulderHorizontalOffset(float v) { mOverShoulderHorizontalOffset = v; } + void setOverShoulderOffset(float horizontal, float vertical); /// Update the view matrix of \a cam void updateCamera(osg::Camera* cam); diff --git a/apps/openmw/mwrender/renderingmanager.cpp b/apps/openmw/mwrender/renderingmanager.cpp index 6997fee03..fc78b6ebb 100644 --- a/apps/openmw/mwrender/renderingmanager.cpp +++ b/apps/openmw/mwrender/renderingmanager.cpp @@ -386,7 +386,11 @@ namespace MWRender mCamera->setThirdPersonViewMode(Camera::ThirdPersonViewMode::OverShoulder); else mCamera->setThirdPersonViewMode(Camera::ThirdPersonViewMode::Standard); - mCamera->setOverShoulderHorizontalOffset(Settings::Manager::getFloat("view over shoulder horizontal offset", "Camera")); + + std::stringstream offset(Settings::Manager::getString("view over shoulder offset", "Camera")); + float horizontal = 30.f, vertical = -10.f; + offset >> horizontal >> vertical; + mCamera->setOverShoulderOffset(horizontal, vertical); } osgUtil::IncrementalCompileOperation* RenderingManager::getIncrementalCompileOperation() diff --git a/docs/source/reference/modding/settings/camera.rst b/docs/source/reference/modding/settings/camera.rst index 756db3999..ecc1bda50 100644 --- a/docs/source/reference/modding/settings/camera.rst +++ b/docs/source/reference/modding/settings/camera.rst @@ -127,15 +127,15 @@ True: In non-combat mode camera is positioned behind the character's shoulder. C This setting can only be configured by editing the settings configuration file. -view over shoulder horizontal offset ------------------------------------- +view over shoulder offset +------------------------- -:Type: floating point +:Type: 2D vector floating point :Range: Any -:Default: 30 +:Default: 30 -10 -This setting makes sense only if 'view over shoulder' is enabled. Controls horizontal offset of the camera in third person mode. Negative value means offset to the left, positive - to the right. -Recommened values: 30 for the right shoulder, -30 for the left shoulder. +This setting makes sense only if 'view over shoulder' is enabled. Controls horizontal (first number) and vertical (second number) offset of the camera in third person mode. +Recommened values: 30 -10 for the right shoulder, -30 -10 for the left shoulder. This setting can only be configured by editing the settings configuration file. diff --git a/files/settings-default.cfg b/files/settings-default.cfg index f95998c1c..c48c8baf4 100644 --- a/files/settings-default.cfg +++ b/files/settings-default.cfg @@ -36,8 +36,8 @@ first person field of view = 60.0 # If enabled then third person camera is positioned above character's shoulder and crosshair is visible. view over shoulder = false -# Makes sense only if 'view over shoulder' is true. Negative value means offset to the left. -view over shoulder horizontal offset = 30 +# Makes sense only if 'view over shoulder' is true. First number is horizontal offset (negative value means offset to the left), second number is vertical offset. +view over shoulder offset = 30 -10 [Cells]