mirror of
https://github.com/OpenMW/openmw.git
synced 2025-03-27 04:40:26 +00:00
Make vertical offset of "view over shoulder" configurable
This commit is contained in:
parent
da65a3b8d4
commit
63137a3b5a
5 changed files with 23 additions and 14 deletions
|
@ -62,7 +62,7 @@ namespace MWRender
|
||||||
mViewModeToggleQueued(false),
|
mViewModeToggleQueued(false),
|
||||||
mCameraDistance(0.f),
|
mCameraDistance(0.f),
|
||||||
mThirdPersonMode(ThirdPersonViewMode::Standard),
|
mThirdPersonMode(ThirdPersonViewMode::Standard),
|
||||||
mOverShoulderHorizontalOffset(30.0f),
|
mOverShoulderOffset(osg::Vec2f(30.0f, -10.0f)),
|
||||||
mSmoothTransitionToCombatMode(0.f)
|
mSmoothTransitionToCombatMode(0.f)
|
||||||
{
|
{
|
||||||
mVanity.enabled = false;
|
mVanity.enabled = false;
|
||||||
|
@ -120,8 +120,8 @@ namespace MWRender
|
||||||
osg::Vec3d offset(0, 0, 10.f);
|
osg::Vec3d offset(0, 0, 10.f);
|
||||||
if (mThirdPersonMode == ThirdPersonViewMode::OverShoulder && !mPreviewMode && !mVanity.enabled)
|
if (mThirdPersonMode == ThirdPersonViewMode::OverShoulder && !mPreviewMode && !mVanity.enabled)
|
||||||
{
|
{
|
||||||
float horizontalOffset = mOverShoulderHorizontalOffset * (1.f - mSmoothTransitionToCombatMode);
|
float horizontalOffset = mOverShoulderOffset.x() * (1.f - mSmoothTransitionToCombatMode);
|
||||||
float verticalOffset = mSmoothTransitionToCombatMode * 15.f + (1.f - mSmoothTransitionToCombatMode) * -10.f;
|
float verticalOffset = mSmoothTransitionToCombatMode * 15.f + (1.f - mSmoothTransitionToCombatMode) * mOverShoulderOffset.y();
|
||||||
|
|
||||||
offset.x() += horizontalOffset * cos(getYaw());
|
offset.x() += horizontalOffset * cos(getYaw());
|
||||||
offset.y() += horizontalOffset * sin(getYaw());
|
offset.y() += horizontalOffset * sin(getYaw());
|
||||||
|
@ -216,6 +216,11 @@ namespace MWRender
|
||||||
updateSmoothTransitionToCombatMode(duration);
|
updateSmoothTransitionToCombatMode(duration);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Camera::setOverShoulderOffset(float horizontal, float vertical)
|
||||||
|
{
|
||||||
|
mOverShoulderOffset = osg::Vec2f(horizontal, vertical);
|
||||||
|
}
|
||||||
|
|
||||||
void Camera::updateSmoothTransitionToCombatMode(float duration)
|
void Camera::updateSmoothTransitionToCombatMode(float duration)
|
||||||
{
|
{
|
||||||
bool combatMode = true;
|
bool combatMode = true;
|
||||||
|
|
|
@ -59,7 +59,7 @@ namespace MWRender
|
||||||
float mCameraDistance;
|
float mCameraDistance;
|
||||||
|
|
||||||
ThirdPersonViewMode mThirdPersonMode;
|
ThirdPersonViewMode mThirdPersonMode;
|
||||||
float mOverShoulderHorizontalOffset;
|
osg::Vec2f mOverShoulderOffset;
|
||||||
osg::Vec3d mFocalPointAdjustment;
|
osg::Vec3d mFocalPointAdjustment;
|
||||||
|
|
||||||
// Makes sense only if mThirdPersonMode is OverShoulder. Can be in range [0, 1].
|
// Makes sense only if mThirdPersonMode is OverShoulder. Can be in range [0, 1].
|
||||||
|
@ -77,7 +77,7 @@ namespace MWRender
|
||||||
MWWorld::Ptr getTrackingPtr() const;
|
MWWorld::Ptr getTrackingPtr() const;
|
||||||
|
|
||||||
void setThirdPersonViewMode(ThirdPersonViewMode mode) { mThirdPersonMode = mode; }
|
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
|
/// Update the view matrix of \a cam
|
||||||
void updateCamera(osg::Camera* cam);
|
void updateCamera(osg::Camera* cam);
|
||||||
|
|
|
@ -386,7 +386,11 @@ namespace MWRender
|
||||||
mCamera->setThirdPersonViewMode(Camera::ThirdPersonViewMode::OverShoulder);
|
mCamera->setThirdPersonViewMode(Camera::ThirdPersonViewMode::OverShoulder);
|
||||||
else
|
else
|
||||||
mCamera->setThirdPersonViewMode(Camera::ThirdPersonViewMode::Standard);
|
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()
|
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.
|
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
|
: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.
|
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 for the right shoulder, -30 for the left shoulder.
|
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.
|
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.
|
# If enabled then third person camera is positioned above character's shoulder and crosshair is visible.
|
||||||
view over shoulder = false
|
view over shoulder = false
|
||||||
|
|
||||||
# Makes sense only if 'view over shoulder' is true. Negative value means offset to the left.
|
# 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 horizontal offset = 30
|
view over shoulder offset = 30 -10
|
||||||
|
|
||||||
[Cells]
|
[Cells]
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue