mirror of https://github.com/OpenMW/openmw.git
Control camera settings in-game
parent
f47e64b0f8
commit
860d5899c4
@ -0,0 +1,59 @@
|
||||
Camera: "Camera"
|
||||
settingsPageDescription: "OpenMW camera settings"
|
||||
|
||||
thirdPersonSettings: "Third person mode"
|
||||
|
||||
viewOverShoulder: "View over the shoulder"
|
||||
viewOverShoulderDescription: |
|
||||
Controls third person view mode.
|
||||
No: view is centered on the character's head. Crosshair is hidden.
|
||||
Yes: in non-combat mode camera is positioned behind the character's shoulder, crosshair is always visible.
|
||||
|
||||
shoulderOffsetX: "Shoulder view horizontal offset"
|
||||
shoulderOffsetXDescription: >
|
||||
Horizontal offset of the camera in the view-over-the-shoulder mode.
|
||||
For the left shoulder use a negative value.
|
||||
|
||||
shoulderOffsetY: "Shoulder view vertical offset"
|
||||
shoulderOffsetYDescription: >
|
||||
Vertical offset of the camera in the view-over-the-shoulder mode.
|
||||
|
||||
autoSwitchShoulder: "Auto switch shoulder"
|
||||
autoSwitchShoulderDescription: >
|
||||
When player is close to an obstacle, automatically switches camera
|
||||
to the shoulder that is farther away from the obstacle.
|
||||
|
||||
zoomOutWhenMoveCoef: "Zoom out when move coef"
|
||||
zoomOutWhenMoveCoefDescription: >
|
||||
Slightly pulls camera away (or closer in case of a negative value) when the character moves.
|
||||
Works only if "view over the shoulder" is enabled. To disable set it to zero (default: 20.0).
|
||||
|
||||
previewIfStandStill: "Preview if stand still"
|
||||
previewIfStandStillDescription: >
|
||||
If enabled then the character rotation is not synchonized with the camera rotation
|
||||
while the character doesn't move and not in combat mode.
|
||||
|
||||
deferredPreviewRotation: "Deferred preview rotation"
|
||||
deferredPreviewRotationDescription: |
|
||||
If enabled then the character smoothly rotates to the view direction after exiting preview or vanity mode.
|
||||
If disabled then the camera rotates rather than the character.
|
||||
|
||||
ignoreNC: "Ignore 'No Collision' flag"
|
||||
ignoreNCDescription: >
|
||||
Prevents camera from clipping through the objects with the NC (No Collision) NIF flag.
|
||||
|
||||
|
||||
headBobbingSettings: "Head bobbing in first person view"
|
||||
|
||||
headBobbing_enabled: "Enabled"
|
||||
headBobbing_enabledDescription: ""
|
||||
|
||||
headBobbing_step: "Base step length"
|
||||
headBobbing_stepDescription: "The length of each step (default: 90.0)."
|
||||
|
||||
headBobbing_height: "Step height"
|
||||
headBobbing_heightDescription: "The amplitude of the head bobbing (default: 3.0)."
|
||||
|
||||
headBobbing_roll: "Max roll angle"
|
||||
headBobbing_rollDescription: "The maximum roll angle in degrees (default: 0.2)."
|
||||
|
@ -1,21 +1,29 @@
|
||||
local camera = require('openmw.camera')
|
||||
local self = require('openmw.self')
|
||||
local settings = require('openmw.settings')
|
||||
local util = require('openmw.util')
|
||||
local async = require('openmw.async')
|
||||
|
||||
local Actor = require('openmw.types').Actor
|
||||
|
||||
local doubleStepLength = settings._getFloatFromSettingsCfg('Camera', 'head bobbing step') * 2
|
||||
local stepHeight = settings._getFloatFromSettingsCfg('Camera', 'head bobbing height')
|
||||
local maxRoll = math.rad(settings._getFloatFromSettingsCfg('Camera', 'head bobbing roll'))
|
||||
local M = {}
|
||||
|
||||
local settings = require('scripts.omw.camera.settings').headBobbing
|
||||
|
||||
local doubleStepLength, stepHeight, maxRoll
|
||||
|
||||
local function updateSettings()
|
||||
M.enabled = settings:get('enabled')
|
||||
doubleStepLength = settings:get('step') * 2
|
||||
stepHeight = settings:get('height')
|
||||
maxRoll = math.rad(settings:get('roll'))
|
||||
end
|
||||
|
||||
updateSettings()
|
||||
settings:subscribe(async:callback(updateSettings))
|
||||
|
||||
local effectWeight = 0
|
||||
local totalMovement = 0
|
||||
|
||||
local M = {
|
||||
enabled = settings._getBoolFromSettingsCfg('Camera', 'head bobbing')
|
||||
}
|
||||
|
||||
-- Trajectory of each step is a scaled arc of 60 degrees.
|
||||
local halfArc = math.rad(30)
|
||||
local sampleArc = function(x) return 1 - math.cos(x * halfArc) end
|
@ -0,0 +1,95 @@
|
||||
local storage = require('openmw.storage')
|
||||
local async = require('openmw.async')
|
||||
local I = require('openmw.interfaces')
|
||||
|
||||
I.Settings.registerPage({
|
||||
key = 'OMWCamera',
|
||||
l10n = 'OMWCamera',
|
||||
name = 'Camera',
|
||||
description = 'settingsPageDescription',
|
||||
})
|
||||
|
||||
local thirdPersonGroup = 'SettingsOMWCameraThirdPerson'
|
||||
local headBobbingGroup = 'SettingsOMWCameraHeadBobbing'
|
||||
|
||||
local function boolSetting(prefix, key, default)
|
||||
return {
|
||||
key = key,
|
||||
renderer = 'checkbox',
|
||||
name = prefix..key,
|
||||
description = prefix..key..'Description',
|
||||
default = default,
|
||||
}
|
||||
end
|
||||
|
||||
local function floatSetting(prefix, key, default)
|
||||
return {
|
||||
key = key,
|
||||
renderer = 'number',
|
||||
name = prefix..key,
|
||||
description = prefix..key..'Description',
|
||||
default = default,
|
||||
}
|
||||
end
|
||||
|
||||
I.Settings.registerGroup({
|
||||
key = thirdPersonGroup,
|
||||
page = 'OMWCamera',
|
||||
l10n = 'OMWCamera',
|
||||
name = 'thirdPersonSettings',
|
||||
permanentStorage = true,
|
||||
order = 0,
|
||||
settings = {
|
||||
boolSetting('', 'viewOverShoulder', true),
|
||||
floatSetting('', 'shoulderOffsetX', 30),
|
||||
floatSetting('', 'shoulderOffsetY', -10),
|
||||
boolSetting('', 'autoSwitchShoulder', true),
|
||||
floatSetting('', 'zoomOutWhenMoveCoef', 20),
|
||||
boolSetting('', 'previewIfStandStill', true),
|
||||
boolSetting('', 'deferredPreviewRotation', true),
|
||||
boolSetting('', 'ignoreNC', true),
|
||||
},
|
||||
})
|
||||
|
||||
I.Settings.registerGroup({
|
||||
key = headBobbingGroup,
|
||||
page = 'OMWCamera',
|
||||
l10n = 'OMWCamera',
|
||||
name = 'headBobbingSettings',
|
||||
permanentStorage = true,
|
||||
order = 1,
|
||||
settings = {
|
||||
boolSetting('headBobbing_', 'enabled', true),
|
||||
floatSetting('headBobbing_', 'step', 90),
|
||||
floatSetting('headBobbing_', 'height', 3),
|
||||
floatSetting('headBobbing_', 'roll', 0.2),
|
||||
},
|
||||
})
|
||||
|
||||
local settings = {
|
||||
thirdPerson = storage.playerSection(thirdPersonGroup),
|
||||
headBobbing = storage.playerSection(headBobbingGroup),
|
||||
}
|
||||
|
||||
local function updateViewOverShoulderDisabled()
|
||||
local disabled = not settings.thirdPerson:get('viewOverShoulder')
|
||||
I.Settings.updateRendererArgument(thirdPersonGroup, 'shoulderOffsetX', {disabled = disabled})
|
||||
I.Settings.updateRendererArgument(thirdPersonGroup, 'shoulderOffsetY', {disabled = disabled})
|
||||
I.Settings.updateRendererArgument(thirdPersonGroup, 'autoSwitchShoulder', {disabled = disabled})
|
||||
I.Settings.updateRendererArgument(thirdPersonGroup, 'zoomOutWhenMoveCoef', {disabled = disabled})
|
||||
end
|
||||
|
||||
local function updateHeadBobbingDisabled()
|
||||
local disabled = not settings.headBobbing:get('enabled')
|
||||
I.Settings.updateRendererArgument(headBobbingGroup, 'step', {disabled = disabled, min = 1})
|
||||
I.Settings.updateRendererArgument(headBobbingGroup, 'height', {disabled = disabled})
|
||||
I.Settings.updateRendererArgument(headBobbingGroup, 'roll', {disabled = disabled, min = 0, max = 90})
|
||||
end
|
||||
|
||||
updateViewOverShoulderDisabled()
|
||||
updateHeadBobbingDisabled()
|
||||
|
||||
settings.thirdPerson:subscribe(async:callback(updateViewOverShoulderDisabled))
|
||||
settings.headBobbing:subscribe(async:callback(updateHeadBobbingDisabled))
|
||||
|
||||
return settings
|
Loading…
Reference in New Issue