7 protected const float TRACE_DIS = 250;
12 private vector cursorWorldPos;
16 vector transformOriginal[4];
20 vector velocityOriginal;
27 bool isManualInputEnabled;
29 bool isCursorEnabled =
true;
36 void SetDeltaPos(vector deltaPos)
38 transform[3] = transform[3]
39 + (transform[0] * deltaPos[0])
40 + (transform[1] * deltaPos[1])
41 + (transform[2] * deltaPos[2]);
48 bool GetCursorWorldPos(out vector outPos = vector.Zero)
51 if (cursorWorldPos != vector.Zero)
53 outPos = cursorWorldPos;
58 WorkspaceWidget workspace =
GetGame().GetWorkspace();
59 if (!workspace || !world)
return false;
64 WidgetManager.GetMousePos(mouseX, mouseY);
68 mouseX = workspace.GetWidth();
69 mouseY = workspace.GetHeight();
75 vector startPos = workspace.ProjScreenToWorld(workspace.DPIUnscale(mouseX), workspace.DPIUnscale(mouseY), outDir, world, -1);
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;
84 float traceDis = world.TraceMove(trace,
null);
85 if (traceDis == 1)
return false;
87 if (trace.TraceEnt && !trace.TraceEnt.IsInherited(GenericTerrainEntity)) target = trace.TraceEnt;
88 cursorWorldPos = startPos + outDir * traceDis;
89 outPos = cursorWorldPos;
95 void SetCursorWorldPos(vector pos)
105 DbgUI.Begin(
"SCR_ManualCameraParam", 0, 0);
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)
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());
139 DbgUI.Check(
"Show Graphs", showGraphs);
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));
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));
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));
165 void ProcessTransform()
168 vector angles = Math3D.MatrixToAngles(transform);
169 angles += rotDelta * timeSlice;
170 angles[1] = Math.Clamp(angles[1], -89, 89);
171 Math3D.AnglesToMatrix(angles, transform);
183 void SCR_ManualCameraParam(vector transformOriginalIn[4],
float timeSliceIn, BaseWorld worldIn,
float fovIn,
bool isManualInputEnabledIn, vector velocityOriginalIn,
EManualCameraFlag flagIn)
185 timeSlice = timeSliceIn;
187 multiplier[0] = timeSliceIn;
188 multiplier[1] = timeSliceIn;
190 isManualInputEnabled = isManualInputEnabledIn;
194 transformOriginal = transformOriginalIn;
195 velocityOriginal = velocityOriginalIn;
196 Math3D.MatrixCopy(transformOriginal, transform);
197 rotOriginal = Math3D.MatrixToAngles(transformOriginal);