Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_MoveManualCameraComponent.c
Go to the documentation of this file.
1
2
4[BaseContainerProps(), SCR_BaseManualCameraComponentTitle()]
6{
7 [Attribute(defvalue: "27", desc: "Speed coefficient.")]
8 private float m_fSpeed;
9
10 protected bool m_bBlockedByRadialMenu;
11
12#ifdef ENABLE_DIAG
13 protected const float DEBUG_DISTANCE_EXTENSION = 2000;
14#endif
15
16 //------------------------------------------------------------------------------------------------
18 {
19 vector transform[4];
20 GetCameraEntity().GetWorldTransform(transform);
21 vector angles = Math3D.MatrixToAngles(transform);
22
23 data.m_aValues = {
24 transform[3][0], transform[3][1], transform[3][2], //--- Pos
25 angles[0], angles[1] //--- Yaw, pitch (don't save roll, this component cannot change)
26 };
27 }
28
29 //------------------------------------------------------------------------------------------------
31 {
32 if (!data.m_aValues || data.m_aValues.Count() < 5)
33 return;
34
35 vector transform[4];
36 transform[3] = Vector(data.m_aValues[0], data.m_aValues[1], data.m_aValues[2]);
37 Math3D.AnglesToMatrix(Vector(data.m_aValues[3], data.m_aValues[4], 0), transform);
38
39 GetCameraEntity().SetWorldTransform(transform);
40 }
41
42 //------------------------------------------------------------------------------------------------
44 {
45 if (!param.isManualInputEnabled)
46 return;
47
48 bool radialMenu = !m_InputManager.IsUsingMouseAndKeyboard() && (m_InputManager.GetActionValue("RadialX") || m_InputManager.GetActionValue("RadialY"));
49 if (radialMenu)
51
52 float lateral = m_InputManager.GetActionValue("ManualCameraMoveLateral");
53 float vertical = m_InputManager.GetActionValue("ManualCameraMoveVertical");
54 float longitudinal = m_InputManager.GetActionValue("ManualCameraMoveLongitudinal");
55 if (lateral == 0 && vertical == 0 && longitudinal == 0)
56 {
57 if (!radialMenu)
59
60 return;
61 }
62
63 //--- Radial menu was just closed - block the input until player releases left stick
65 return;
66
67 //--- Make sure that horizontal input is not bigger than 1 (happens on gamepad when moving diagonally)
68 vector newDir = Vector(lateral, 0, longitudinal);
69 if (newDir.LengthSq() > 1)
70 newDir.Normalize();
71
72 //--- Get horizontal vector
73 vector currentDir = param.transform[2];
74 currentDir[1] = 0;
75 currentDir.Normalize();
76
77 float horizontalSpeedCoef = param.multiplier[0] * m_fSpeed;
78 param.transform[3] = param.transform[3] + Vector(
79 (currentDir[0] * newDir[2] + currentDir[2] * newDir[0]) * horizontalSpeedCoef,
80 vertical * param.multiplier[1] * m_fSpeed,
81 (currentDir[2] * newDir[2] - currentDir[0] * newDir[0]) * horizontalSpeedCoef,
82 );
83
84 // Limit position to avoid large numbers
85 vector mins, maxs;
86 GetGame().GetWorldEntity().GetTerrain(0, 0).GetTerrainBoundBox(mins, maxs); // bounds are in world space
87 vector worldPos = CoordFromCamera(param.transform[3]); // translate to world space coordinates
88
89#ifdef ENABLE_DIAG
90 mins -= vector.One * DEBUG_DISTANCE_EXTENSION; // its useful to be able to fly a bit further than world bounds
91 maxs += vector.One * DEBUG_DISTANCE_EXTENSION; // especially in case of MpTest world
92#endif
93
94 worldPos[0] = Math.Clamp(worldPos[0], mins[0], maxs[0]);
95 worldPos[1] = Math.Clamp(worldPos[1], -8000.0, 8000.0);
96 worldPos[2] = Math.Clamp(worldPos[2], mins[2], maxs[2]);
97 param.transform[3] = CoordToCamera(worldPos); // translate back to camera local space
98
99 param.isManualInput = true;
100 param.isDirty = true;
101 }
102
103 //------------------------------------------------------------------------------------------------
104 override bool EOnCameraInit()
105 {
106 return true;
107 }
108}
ArmaReforgerScripted GetGame()
Definition game.c:1398
ref array< string > angles
SCR_AIAnimation_Loitering BaseContainerProps
Commanding menu commanding element class.
Get all prefabs that have the spawner data
UI Textures DeployMenu Briefing conflict_HintBanner_1_UI desc
Definition Math.c:13
Parent class from which all SCR_ManualCamera components inherit.
Parameter for carrying information between individual camera components.
Camera movement above sea level.
override void EOnCameraLoad(SCR_ManualCameraComponentSave data)
override void EOnCameraSave(SCR_ManualCameraComponentSave data)
override void EOnCameraFrame(SCR_ManualCameraParam param)
SCR_FieldOfViewSettings Attribute
proto native vector Vector(float x, float y, float z)