Skip to content

Commit a960ba4

Browse files
authored
freecam: Add support for changing field of view (#395)
* freecam Add field of view get from player settings * [Refactor] Add fov support to map editor
1 parent e1e5b1a commit a960ba4

File tree

5 files changed

+16
-5
lines changed

5 files changed

+16
-5
lines changed

[editor]/editor_gui/client/options_action.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ function setFreecamSpeeds()
6868
freecam.setFreecamOption ( "fastMaxSpeed", dialog.fastMove:getValue() )
6969
freecam.setFreecamOption ( "slowMaxSpeed", dialog.slowMove:getValue() )
7070
freecam.setFreecamOption ( "mouseSensitivity", dialog.mouseSensitivity:getValue() )
71+
freecam.setFreecamOption ( "fov", dialog.fov:getValue() )
7172
end
7273

7374
---This part decides whether gui should be refreshed or not

[editor]/editor_gui/client/options_backend.lua

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ local xmlVariants = {
2727
["enablePrecisionSnap"]="enableprecisionsnap",
2828
["enablePrecisionRotation"]="enableprecisionrotation",
2929
["enableColPatch"]="enablecolpatch",
30+
["fov"]="fov",
3031
}
3132
local nodeTypes = {
3233
["enableSounds"]="bool",
@@ -56,6 +57,7 @@ local nodeTypes = {
5657
["enablePrecisionRotation"]="bool",
5758
["enableXYZlines"]="bool",
5859
["enableColPatch"]="bool",
60+
["fov"]="progress",
5961
}
6062
local defaults = {
6163
["enableSounds"]=true,
@@ -84,6 +86,7 @@ local defaults = {
8486
["enablePrecisionRotation"]=false,
8587
["enableXYZlines"]=true,
8688
["enableColPatch"]=false,
89+
["fov"]=dxGetStatus()["SettingFOV"],
8790
}
8891

8992
--stuff involving xml and dumping

[editor]/editor_gui/client/options_gui.lua

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ function createOptionsDialog()
4848
guiCreateLabel ( 0.02, 0.22, 1, 0.1, "Fast camera move speed:", true, dialog.cameraTab )
4949
guiCreateLabel ( 0.02, 0.42, 1, 0.1, "Slow camera move speed:", true, dialog.cameraTab )
5050
guiCreateLabel ( 0.02, 0.72, 1, 0.1, "Look sensitivity:", true, dialog.cameraTab )
51+
guiCreateLabel ( 0.5, 0.02, 1, 0.1, "Field of View:", true, dialog.cameraTab )
5152

5253
dialog.normalMove = editingControl.slider:create{["x"]=0.02,["y"]=0.08,["width"]=0.4,["height"]=0.11,["relative"]=true,["parent"]=dialog.cameraTab,
5354
["min"]=1,
@@ -65,9 +66,13 @@ function createOptionsDialog()
6566
["min"]=0.01,
6667
["max"]=1.3,
6768
}
69+
dialog.fov = editingControl.slider:create{["x"]=0.5,["y"]=0.08,["width"]=0.4,["height"]=0.11,["relative"]=true,["parent"]=dialog.cameraTab,
70+
["min"]=70,
71+
["max"]=90,
72+
}
6873

69-
dialog.smoothCamMove = editingControl.boolean:create{["x"]=0.5,["y"]=0.06,["width"]=1,["height"]=0.1,["relative"]=true,["parent"]=dialog.cameraTab,["label"]="Smooth Camera movement"}
70-
dialog.invertMouseLook = editingControl.boolean:create{["x"]=0.5,["y"]=0.16,["width"]=1,["height"]=0.1,["relative"]=true,["parent"]=dialog.cameraTab,["label"]="Invert mouse look"}
74+
dialog.smoothCamMove = editingControl.boolean:create{["x"]=0.5,["y"]=0.22,["width"]=1,["height"]=0.1,["relative"]=true,["parent"]=dialog.cameraTab,["label"]="Smooth Camera movement"}
75+
dialog.invertMouseLook = editingControl.boolean:create{["x"]=0.5,["y"]=0.32,["width"]=1,["height"]=0.1,["relative"]=true,["parent"]=dialog.cameraTab,["label"]="Invert mouse look"}
7176
--create movement settings
7277
guiCreateLabel ( 0.02, 0.12, 1, 0.1, "Normal element movement speed:", true, dialog.movementTab )
7378
guiCreateLabel ( 0.02, 0.32, 1, 0.1, "Fast element movement speed:", true, dialog.movementTab )

[editor]/editor_main/client/controls.lua

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ addEventHandler("onClientResourceStart", root,
109109
freecam.setFreecamOption("key_backward", cc.camera_move_backwards)
110110
freecam.setFreecamOption("key_left", cc.camera_move_left)
111111
freecam.setFreecamOption("key_right", cc.camera_move_right)
112+
freecam.setFreecamOption("fov", cc.camera_move_right)
112113
elseif resource == thisResource then
113114
bindKey ("lctrl","both",blockMTAControls )
114115
processControls()

[editor]/freecam/freecam.lua

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,8 @@ local options = {
2424
key_forward_veh = "accelerate",
2525
key_backward_veh = "brake_reverse",
2626
key_left_veh = "vehicle_left",
27-
key_right_veh = "vehicle_right"
27+
key_right_veh = "vehicle_right",
28+
fov = 70
2829
}
2930

3031
local controlToKey = {
@@ -209,7 +210,7 @@ local function freecamFrame ()
209210
camTargetZ = camPosZ + freeModeAngleZ * 100
210211

211212
-- Set the new camera position and target
212-
setCameraMatrix ( camPosX, camPosY, camPosZ, camTargetX, camTargetY, camTargetZ )
213+
setCameraMatrix ( camPosX, camPosY, camPosZ, camTargetX, camTargetY, camTargetZ, 0, options.fov )
213214
end
214215

215216
local function freecamMouse (cX,cY,aX,aY)
@@ -271,7 +272,7 @@ function setFreecamEnabled (x, y, z)
271272
end
272273

273274
if (x and y and z) then
274-
setCameraMatrix ( x, y, z )
275+
setCameraMatrix ( x, y, z, nil, nil, nil, 0, options.fov )
275276
end
276277
addEventHandler("onClientRender", root, freecamFrame)
277278
addEventHandler("onClientCursorMove",root, freecamMouse)

0 commit comments

Comments
 (0)