Make vertical offset of "view over shoulder" configurable

pull/578/head
Petr Mikheev 5 years ago
parent da65a3b8d4
commit 63137a3b5a

@ -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;

@ -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);

@ -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()

@ -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.

@ -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]

Loading…
Cancel
Save