Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
SCR_ManualCameraParam.c
Go to the documentation of this file.
1
2
4
5class SCR_ManualCameraParam
6{
7 protected const float TRACE_DIS = 250;
8
9 float timeSlice;
12 private vector cursorWorldPos;
13
15
16 vector transformOriginal[4];
17 vector transform[4];
18 vector rotOriginal;
19 vector rotDelta;
20 vector velocityOriginal;
21
22 vector multiplier;
23
24 float fovOriginal;
25 float fov;
26
27 bool isManualInputEnabled;
28 bool isManualInput;
29 bool isCursorEnabled = true;
30 bool isDirty;
31 bool isDirtyExternal;
32
33 //------------------------------------------------------------------------------------------------
36 void SetDeltaPos(vector deltaPos)
37 {
38 transform[3] = transform[3]
39 + (transform[0] * deltaPos[0]) //--- Lateral
40 + (transform[1] * deltaPos[1]) //--- Vertical
41 + (transform[2] * deltaPos[2]); //--- Longitudinal
42 }
43
44 //------------------------------------------------------------------------------------------------
48 bool GetCursorWorldPos(out vector outPos = vector.Zero)
49 {
50 //--- Return cached position
51 if (cursorWorldPos != vector.Zero)
52 {
53 outPos = cursorWorldPos;
54 return true;
55 }
56
57 //-- Calculate new position
58 WorkspaceWidget workspace = GetGame().GetWorkspace();
59 if (!workspace || !world) return false;
60
61 int mouseX, mouseY;
62 if (GetGame().GetInputManager().IsUsingMouseAndKeyboard())
63 {
64 WidgetManager.GetMousePos(mouseX, mouseY);
65 }
66 else
67 {
68 mouseX = workspace.GetWidth();
69 mouseY = workspace.GetHeight();
70 mouseX /= 2;
71 mouseY /= 2;
72 }
73
74 vector outDir;
75 vector startPos = workspace.ProjScreenToWorld(workspace.DPIUnscale(mouseX), workspace.DPIUnscale(mouseY), outDir, world, -1);
76 outDir *= TRACE_DIS;
77
78 autoptr TraceParam trace = new TraceParam();
79 trace.Start = startPos;
80 trace.End = startPos + outDir;
81 trace.Flags = TraceFlags.WORLD | TraceFlags.OCEAN | TraceFlags.ENTS;
82 trace.LayerMask = EPhysicsLayerPresets.Projectile;
83
84 float traceDis = world.TraceMove(trace, null);
85 if (traceDis == 1) return false;
86
87 if (trace.TraceEnt && !trace.TraceEnt.IsInherited(GenericTerrainEntity)) target = trace.TraceEnt;
88 cursorWorldPos = startPos + outDir * traceDis;
89 outPos = cursorWorldPos;
90 return true;
91 }
92
93 //------------------------------------------------------------------------------------------------
95 void SetCursorWorldPos(vector pos)
96 {
97 cursorWorldPos = pos;
98 }
99
100 //------------------------------------------------------------------------------------------------
103 void ShowDebug(SCR_ManualCamera camera)
104 {
105 DbgUI.Begin("SCR_ManualCameraParam", 0, 0);
106
107 DbgUI.Text(string.Format("GetParent() = %1", camera.GetParent()));
108 DbgUI.Text("flag = ");
109 array<int> flagValues = new array<int>;
110 SCR_Enum.BitToIntArray(flag, flagValues);
111 foreach (int i: flagValues)
112 {
113 DbgUI.Text(" " + typename.EnumToString(EManualCameraFlag, i));
114 }
115 DbgUI.Text(string.Format("target = %1", target));
116 DbgUI.Text("isDirty = " + isDirty.ToString());
117 DbgUI.Text("isManualInput = " + isManualInput.ToString());
118 DbgUI.Text("isManualInputEnabled = " + isManualInputEnabled.ToString());
119 DbgUI.Text("isCursorEnabled = " + isCursorEnabled.ToString());
120 DbgUI.Text("multiplier = " + multiplier.ToString());
121 DbgUI.Text("fov = " + fov.ToString());
122 DbgUI.Text("rotOriginal = " + rotOriginal.ToString());
123 DbgUI.Text("rotDelta = " + rotDelta.ToString());
124 DbgUI.Text("posDelta = " + (transform[3] - transformOriginal[3]).ToString());
125 DbgUI.Text("transformOriginal: ");
126 DbgUI.Text("o[0] = " + transformOriginal[0].ToString());
127 DbgUI.Text("o[1] = " + transformOriginal[1].ToString());
128 DbgUI.Text("o[2] = " + transformOriginal[2].ToString());
129 DbgUI.Text("o[3] = " + transformOriginal[3].ToString());
130 DbgUI.Text("transform: ");
131 DbgUI.Text("[0] = " + transform[0].ToString());
132 DbgUI.Text("[1] = " + transform[1].ToString());
133 DbgUI.Text("[2] = " + transform[2].ToString());
134 DbgUI.Text("[3] = " + transform[3].ToString());
135 DbgUI.Text("velocityOriginal = " + velocityOriginal.ToString());
136
137 DbgUI.Spacer(30);
138 bool showGraphs;
139 DbgUI.Check("Show Graphs", showGraphs);
140 if (showGraphs)
141 {
142 DbgUI.Spacer(20);
143 DbgUI.Text("multiplier");
144 DbgUI.PlotLive("multiplier0", 500, 50, multiplier[0], 0.01, 100, ARGBF(1, 1, 0, 0));
145 DbgUI.PlotLive("multiplier1", 500, 50, multiplier[1], 0.01, 100, ARGBF(1, 0, 1, 0));
146 DbgUI.PlotLive("multiplier2", 500, 50, multiplier[2], 0.01, 100, ARGBF(1, 0, 0, 1));
147
148 DbgUI.Spacer(20);
149 DbgUI.Text("transformDelta");
150 DbgUI.PlotLive("transform0", 500, 50, transform[3][0] - transformOriginal[3][0], 0.01, 100, ARGBF(1, 1, 0, 0));
151 DbgUI.PlotLive("transform1", 500, 50, transform[3][1] - transformOriginal[3][1], 0.01, 100, ARGBF(1, 0, 1, 0));
152 DbgUI.PlotLive("transform2", 500, 50, transform[3][2] - transformOriginal[3][2], 0.01, 100, ARGBF(1, 0, 0, 1));
153
154 DbgUI.Spacer(20);
155 DbgUI.Text("rotDelta");
156 DbgUI.PlotLive("rotDelta0", 500, 50, rotDelta[0], 0.01, 100, ARGBF(1, 1, 0, 0));
157 DbgUI.PlotLive("rotDelta1", 500, 50, rotDelta[1], 0.01, 100, ARGBF(1, 0, 1, 0));
158 DbgUI.PlotLive("rotDelta2", 500, 50, rotDelta[2], 0.01, 100, ARGBF(1, 0, 0, 1));
159 }
160 DbgUI.End();
161 }
162
163 //------------------------------------------------------------------------------------------------
165 void ProcessTransform()
166 {
167 //--- Rotation (prevent from looking straigh up or down)
168 vector angles = Math3D.MatrixToAngles(transform);
169 angles += rotDelta * timeSlice;
170 angles[1] = Math.Clamp(angles[1], -89, 89);
171 Math3D.AnglesToMatrix(angles, transform);
172 }
173
174 //------------------------------------------------------------------------------------------------
175 // constructor
183 void SCR_ManualCameraParam(vector transformOriginalIn[4], float timeSliceIn, BaseWorld worldIn, float fovIn, bool isManualInputEnabledIn, vector velocityOriginalIn, EManualCameraFlag flagIn)
184 {
185 timeSlice = timeSliceIn;
186 //isDirty = timeSlice != 0;
187 multiplier[0] = timeSliceIn;
188 multiplier[1] = timeSliceIn;
189 flag = flagIn;
190 isManualInputEnabled = isManualInputEnabledIn;
191 fov = fovIn;
192 fovOriginal = fovIn;
193 world = worldIn;
194 transformOriginal = transformOriginalIn;
195 velocityOriginal = velocityOriginalIn;
196 Math3D.MatrixCopy(transformOriginal, transform);
197 rotOriginal = Math3D.MatrixToAngles(transformOriginal);
198 }
199}
ArmaReforgerScripted GetGame()
Definition game.c:1398
ref array< string > angles
InputManager GetInputManager()
bool GetCursorWorldPos(out vector worldPos, bool isNormalized=false, TraceFlags flags=-1)
void ShowDebug()
float timeSlice
Frame time slice.
IEntity target
Entity under cursor.
BaseWorld world
World in which the camera exists.
EPhysicsLayerPresets
Enum is filled by C++ by data in project config PhysicsSettings.LayerPresets.
Definition gameLib.c:19
EManualCameraFlag
proto external string ToString()
Plain C++ pointer, no weak pointers, no memory management.
TraceFlags
Definition TraceFlags.c:13
proto int ARGBF(float fa, float fr, float fg, float fb)
Converts <0.0, 1.0> ARGB into color.