Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
CharacterCamera3rdPersonVehicle.c
Go to the documentation of this file.
1// *************************************************************************************
2// ! CharacterCamera3rdPersonVehicle - 3rd person camera when character is in vehicle
3// *************************************************************************************
4//---- REFACTOR NOTE START: This code will need to be refactored as current implementation is not conforming to the standards ----
6{
7 //-----------------------------------------------------------------------------
8 static const float CONST_UD_MIN = -60.0;
9 static const float CONST_UD_MAX = 60.0;
10
11 static const float CONST_LR_MIN = -360.0;
12 static const float CONST_LR_MAX = 360.0;
13
14 static const float STEERING_DEGREES = 5;
15 static const float ANGULAR_INERTIA = 5;
16 protected float m_fSteeringAngle;
17 protected float m_fInertiaAngle;
18
19 //------------------------------------------------------------------------------------------------
20 protected float m_fHeight;
21 protected float m_fDist_Desired;
22 protected float m_fDist_Min;
23 protected float m_fDist_Max;
24 protected float m_fFOV_SpeedAdjustMax;
25 protected float m_fBobScale;
26 protected float m_fShakeScale;
27 protected float m_fSpeedMax;
28
31 protected vector m_vCameraCenter; // In vehicle space
32
33 protected vector m_vLastVel;
36
37 protected bool m_bForceBasedCamera;
41 protected float m_fCameraHorizontalLag;
43 protected bool m_bDollyZoomEffect;
44 protected float m_fCamVelocity;
45 protected float m_fCamDist;
46 protected float m_fCamDistTarget;
47 protected float m_fZoomTargetWidth;
48 protected float m_fCamFOV;
49
50 protected float m_f3rd_TraceClipPct;
51 protected float m_fBob_FastUp;
52 protected float m_fBob_FastRight;
53 protected float m_fBob_SlowUp;
54 protected float m_fBob_SlowRight;
55 protected float m_fBob_ScaleFast;
56 protected float m_fBob_ScaleSlow;
57 protected float m_fBob_Acceleration;
58
59 //rad
60 protected float m_fAngleThirdPerson;
61
65 protected bool m_bUseNoParent;
66
67 protected bool m_bViewBob = true;
69
70 //------------------------------------------------------------------------------------------------
72 {
73 m_fFOV = GetBaseFOV();
74 m_bLRAngleNoLimit = true;
75 }
76
77 //------------------------------------------------------------------------------------------------
79 {
80 CompartmentAccessComponent compartmentAccess = m_OwnerCharacter.GetCompartmentAccessComponent();
81 if (compartmentAccess && compartmentAccess.IsInCompartment())
82 {
83 m_pCompartment = compartmentAccess.GetCompartment();
84
85 IEntity compartmentOwner = m_pCompartment.GetOwner();
86 IEntity vehicle = compartmentOwner.GetRootParent();
87 if (vehicle)
88 {
89 m_OwnerVehicle = vehicle;
90
91 SCR_VehicleCameraDataComponent vehicleCamDataComp = SCR_VehicleCameraDataComponent.Cast(vehicle.FindComponent(SCR_VehicleCameraDataComponent));
92 // Can owner replace Vehicle's camera data?
93 SCR_VehicleCameraDataComponent ownerCamDataComp = SCR_VehicleCameraDataComponent.Cast(compartmentOwner.FindComponent(SCR_VehicleCameraDataComponent));
95 if (ownerCamDataComp)
96 vehicleCamData = SCR_VehicleCameraDataComponentClass.Cast(ownerCamDataComp.GetComponentData(compartmentOwner));
97
98 if (!vehicleCamData || !vehicleCamData.m_bOverrideVehicleSettings)
99 vehicleCamData = SCR_VehicleCameraDataComponentClass.Cast(vehicleCamDataComp.GetComponentData(vehicle));
100
101 if(vehicleCamData)
102 {
103 m_fHeight = vehicleCamData.m_fHeight;
104 m_fDist_Desired = vehicleCamData.m_fDist_Desired;
105 m_fDist_Min = vehicleCamData.m_fDist_Min;
106 m_fDist_Max = vehicleCamData.m_fDist_Max;
107 //m_fFOV = vehicleCamData.m_fFOV;
108 m_fFOV_SpeedAdjustMax = vehicleCamData.m_fFOV_SpeedAdjustMax;
109 m_fBobScale = vehicleCamData.m_fBobScale;
110 m_fShakeScale = vehicleCamData.m_fShakeScale;
111 m_fSpeedMax = vehicleCamData.m_fSpeedMax;
112 m_pCameraAimpointData = vehicleCamData.m_pCameraAimpointData;
113 m_pCameraAlignData = vehicleCamData.m_pCameraAlignData;
114 m_fRollFactor = vehicleCamData.m_3rdPersonRollFactor;
115 m_fPitchFactor = vehicleCamData.m_3rdPersonPitchFactor;
116 m_fAngleThirdPerson = vehicleCamData.m_fAngleThirdPerson * Math.DEG2RAD;
117 m_pCameraPivot = vehicleCamData.m_pPivot;
118 m_bUseNoParent = vehicleCamData.m_bNoParent;
119 m_bForceBasedCamera = vehicleCamData.m_UseForceBased_3PVCamera;
120 m_fCameraMovementForceFactor = vehicleCamData.m_MovementForceFactor;
121 m_fCameraMovementForceThreshold = vehicleCamData.m_MovementForceThreshold;
122 m_fCameraSpringForceFactor = vehicleCamData.m_SpringForceFactor;
123 m_bDollyZoomEffect = vehicleCamData.m_3PVDollyZoomEffect;
124 m_fCameraHorizontalLag = vehicleCamData.m_HorizontalSpringLag;
125 m_fCameraHorizontalLagMax = vehicleCamData.m_HorizontalSpringLagMaxAngle;
126
129 m_fZoomTargetWidth = m_fCamDist * 2 * Math.Tan(0.5 * m_fFOV * Math.DEG2RAD);
130 }
131
132 if (m_pCameraPivot)
133 {
134 vector matrix[4];
135 m_pCameraPivot.GetLocalTransform(matrix);
136 m_vCameraCenter = matrix[3];
137 }
138 else
139 {
140 Physics physics = vehicle.GetPhysics();
141 if (physics)
142 {
143 m_vCameraCenter = physics.GetCenterOfMass();
144 }
145 else
146 {
147 vector mins, maxs;
148 vehicle.GetBounds(mins, maxs);
149 m_vCameraCenter = (maxs - mins) * 0.5 + mins;
150 }
151 }
152 }
153 }
154 }
155
156 //------------------------------------------------------------------------------------------------
157 override void OnActivate(ScriptedCameraItem pPrevCamera, ScriptedCameraItemResult pPrevCameraResult)
158 {
159 super.OnActivate(pPrevCamera, pPrevCameraResult);
160
161 m_CharacterHeadAimingComponent.SetLimitAnglesOverride(CONST_UD_MIN, CONST_UD_MAX, CONST_LR_MIN, CONST_LR_MAX);
162
163 if (pPrevCamera)
164 {
165 vector f = pPrevCamera.GetBaseAngles();
166 m_fUpDownAngle = f[0];
167 m_fLeftRightAngle = f[1];
168 }
169
171
172 CharacterCamera1stPersonVehicle characterCamera1stPersonVehicle = CharacterCamera1stPersonVehicle.Cast(pPrevCamera);
173 if (characterCamera1stPersonVehicle)
174 {
175 m_fRollSmooth = characterCamera1stPersonVehicle.m_fRollSmooth;
176 m_fRollSmoothVel = characterCamera1stPersonVehicle.m_fRollSmoothVel;
177 m_fPitchSmooth = characterCamera1stPersonVehicle.m_fPitchSmooth;
178 m_fPitchSmoothVel = characterCamera1stPersonVehicle.m_fPitchSmoothVel;
179
181 {
182 // Offset rotation of 3rd person camera if player is sitting sideways in vehicle
183 float thirdPersonCameraOffset = (m_OwnerVehicle.GetYawPitchRoll()[0] - m_OwnerCharacter.GetYawPitchRoll()[0]) * Math.DEG2RAD;
184
185 if (!float.AlmostEqual(thirdPersonCameraOffset, 0))
186 {
187 vector angles = m_Input.GetLookAtAngles();
188 angles[0] = angles[0] + thirdPersonCameraOffset;
189 m_Input.SetLookAtAngles(angles);
190 }
191 }
192 }
193
194 m_CharacterCameraHandler.SetTraceCharacters(false);
195 }
196
197 //------------------------------------------------------------------------------------------------
198 override void OnDeactivate(ScriptedCameraItem pNextCamera)
199 {
200 super.OnDeactivate(pNextCamera);
201 m_CharacterCameraHandler.SetTraceCharacters(true);
202 }
203
204 //------------------------------------------------------------------------------------------------
205 override void OnUpdate(float pDt, out ScriptedCameraItemResult pOutResult)
206 {
207 CompartmentAccessComponent compartmentAccess = m_OwnerCharacter.GetCompartmentAccessComponent();
208 if (compartmentAccess && compartmentAccess.IsInCompartment())
209 {
210 m_pCompartment = compartmentAccess.GetCompartment();
211 IEntity vehicle = m_pCompartment.GetOwner().GetRootParent();
212 if (vehicle && vehicle != m_OwnerVehicle)
213 {
215 }
216 }
217
218 m_CharacterHeadAimingComponent.SetPitchLimitReductionMultiplier(0.0); // Remove pitch reduction.
219
221 m_fUpDownAngleCurrent = UpdateUDAngle(m_fUpDownAngle, CONST_UD_MIN, CONST_UD_MAX, pDt);
222 m_fLeftRightAngle = UpdateLRAngle(m_fLeftRightAngle, CONST_LR_MIN, CONST_LR_MAX, pDt);
223
224 pOutResult.m_vBaseAngles = GetBaseAngles();
225
227 m_fFOV = GetBaseFOV();
228
229 // phx speed
230 vector characterOffset = vector.Zero;
231 vector localVelocity = vector.Zero;
232 vector localAngVelocity = vector.Zero;
233 float steeringAngle;
234 vector vehMat[4];
235
236 bool bCharacterAttached = true;
237
238 if (m_OwnerVehicle)
239 {
240 m_OwnerVehicle.GetTransform(vehMat);
241
242 vector charaMat[4];
243 if (EntityUtils.GetAncestorToChildTransform(m_OwnerCharacter, m_OwnerVehicle, charaMat))
244 {
245 characterOffset = m_vCameraCenter.Multiply4(charaMat);
246 }
247 else
248 {
249 m_OwnerCharacter.GetTransform(charaMat);
250 characterOffset = m_vCameraCenter.Multiply4(vehMat).InvMultiply4(charaMat);
251 bCharacterAttached = false;
252 }
253
254 Physics physics = m_OwnerVehicle.GetPhysics();
255 if (physics)
256 {
257 localVelocity = physics.GetVelocity().InvMultiply3(vehMat);
258 localAngVelocity = physics.GetAngularVelocity().InvMultiply3(vehMat);
259 }
260
261 if (compartmentAccess && PilotCompartmentSlot.Cast(compartmentAccess.GetCompartment()))
262 {
264 if (simulation)
265 steeringAngle = simulation.GetSteering();
266 }
267 }
268 else
269 {
270 Math3D.MatrixIdentity4(vehMat);
271 }
272
273 // To smoothen out jittering a bit
274 vector smoothVelocity = vector.Lerp(m_vLastVel, localVelocity, pDt);
275 vector smoothAngVelocity = vector.Lerp(m_vLastAngVel, localAngVelocity, pDt);
276
277 m_fInertiaAngle = Math.Lerp(m_fInertiaAngle, smoothAngVelocity[0] * ANGULAR_INERTIA, pDt); //smoothAngVelocity[0] is actually pitch
278 m_fSteeringAngle = Math.Lerp(m_fSteeringAngle, steeringAngle * STEERING_DEGREES, pDt);
279
280 UpdateCameraDistanceAndFOV(localVelocity, m_vLastVel, pDt);
281
282 // store phx values
283 m_vLastVel = localVelocity;
284 m_vLastAngVel = localAngVelocity;
285
286 vector yawPitchRoll = Math3D.MatrixToAngles(vehMat);
287
288 // update auto align
290 {
291 bool isFocused = false;
292 if (m_CharacterCameraHandler && m_CharacterCameraHandler.GetFocusMode() > 0)
293 isFocused = true;
294
295 vector aimChange = m_Input.GetAimChange();
296 vector newAngles;
297 if (m_pCameraAlignData.Update(aimChange, Vector(m_fLeftRightAngle, m_fUpDownAngleCurrent, 0.0), smoothVelocity, isFocused, pDt, newAngles))
298 {
299 vector v = Vector(GetGame().GetInputManager().GetActionValue("CharacterFreelookHorizontal"), GetGame().GetInputManager().GetActionValue("CharacterFreelookVertical"), 0.0);
300 if (float.AlmostEqual(v.LengthSq(), 0.0))
301 m_Input.AccumulateFreelookAdjustment(Math.DEG2RAD * (newAngles - Vector(m_fLeftRightAngle, m_fUpDownAngleCurrent, 0.0)));
302 }
303 }
304
305 vector charMat[4];
306 m_OwnerCharacter.GetTransform(charMat);
307 vector anglesChar = Math3D.MatrixToAngles(charMat);
308 CalculateLookAngles(yawPitchRoll, anglesChar, pOutResult);
309
310 // raise camera when zooming in
311 float focusLevel = 0;
313 focusLevel = m_CharacterCameraHandler.GetFocusMode();
314 float camHeight = m_fHeight + focusLevel;
315
317 if (bCharacterAttached)
318 {
319 float rollAngle;
320 if (!m_bUseNoParent)
321 {
323 vector orientation[3];
324 Math3D.AnglesToMatrix(Vector(0, 0, -yawPitchRoll[2]), orientation);
325 Math3D.MatrixMultiply3(orientation, pOutResult.m_CameraTM, pOutResult.m_CameraTM);
326
328 rollAngle = yawPitchRoll[2] * m_fRollFactor * Math.DEG2RAD * pOutResult.m_CameraTM[2][2];
329
330 // Camera offset
331 float heightSign = vehMat[1][1]; // Adjust the sign of the height direction as the vehicle rolls.
332 characterOffset = characterOffset + Vector(0, heightSign * camHeight, 0);
333 }
334 else
335 {
337 rollAngle = yawPitchRoll[2] * (1.0 - m_fRollFactor) * Math.DEG2RAD * pOutResult.m_CameraTM[2][2];
338
339 // Camera offset
340 characterOffset = characterOffset + Vector(0, camHeight, 0);
341 vector pitchRollMat[3];
342 Math3D.AnglesToMatrix({0, yawPitchRoll[1], yawPitchRoll[2]}, pitchRollMat);
343 characterOffset = characterOffset.Multiply3(pitchRollMat); // apply vehicle pitch and roll to camera center
344 }
345
346 float rollMask = Math.Max(0, vehMat[1][1]); // Do not apply roll factor when the vehicle is upside-down.
347 SCR_Math3D.RotateAround(pOutResult.m_CameraTM, vector.Zero, pOutResult.m_CameraTM[2], -rollAngle * rollMask, pOutResult.m_CameraTM);
348
349 pOutResult.m_CameraTM[3] = characterOffset;
350 }
351 else
352 {
353 pOutResult.m_CameraTM[3] = characterOffset + Vector(0, camHeight, 0);
354 }
355
356 // viewbob update
357 UpdateViewBob(pDt, localVelocity, localAngVelocity);
358
359 // Translate camera aimpoint based on aimpoing curve data
361 {
362 vector translation = m_pCameraAimpointData.Sample(smoothVelocity[2] * METERS_PER_SEC_TO_KILOMETERS_PER_HOUR);
363 translation[0] = m_pCameraAimpointData.SampleAside(localAngVelocity[1] * METERS_PER_SEC_TO_KILOMETERS_PER_HOUR);
364 pOutResult.m_CameraTM[3] = pOutResult.m_CameraTM[3] + translation;
365 }
366
367 if (m_OwnerVehicle)
368 {
369 bool applyCharAngle = true;
370 if (sm_TagLyingCamera != -1)
371 {
372 CharacterAnimationComponent characterAnimationComponent = m_OwnerCharacter.GetAnimationComponent();
373 if (characterAnimationComponent && characterAnimationComponent.IsPrimaryTag(sm_TagLyingCamera))
374 applyCharAngle = false;
375 }
376 if (applyCharAngle)
377 {
378 if (m_bUseNoParent)
379 SCR_Math3D.RotateAround(pOutResult.m_CameraTM, pOutResult.m_CameraTM[3], pOutResult.m_CameraTM[0], m_fAngleThirdPerson - (1.0 - m_fPitchFactor) * yawPitchRoll[1] * Math.DEG2RAD, pOutResult.m_CameraTM);
380 else
381 SCR_Math3D.RotateAround(pOutResult.m_CameraTM, pOutResult.m_CameraTM[3], pOutResult.m_CameraTM[0], m_fAngleThirdPerson - m_fPitchFactor * yawPitchRoll[1] * Math.DEG2RAD, pOutResult.m_CameraTM);
382 }
383 else
384 SCR_Math3D.RotateAround(pOutResult.m_CameraTM, pOutResult.m_CameraTM[3], pOutResult.m_CameraTM[0], 0, pOutResult.m_CameraTM);
385 }
386
387 //angle camera slightly when focus
388 if (focusLevel > 0)
389 {
390 vector camAngles = Math3D.MatrixToAngles(pOutResult.m_CameraTM);
391 camAngles[1] = camAngles[1] - camAngles[1]*0.65 * focusLevel;
392 Math3D.AnglesToMatrix(camAngles, pOutResult.m_CameraTM);
393 }
394
395 // other parameters
396 pOutResult.m_fUseHeading = 0.0;
397 pOutResult.m_fFOV = m_fCamFOV;
398 pOutResult.m_fDistance = m_fCamDist;
399 pOutResult.m_pWSAttachmentReference = null;
400 pOutResult.m_pOwner = m_OwnerCharacter;
401 pOutResult.m_bAllowCollisionSolver = bCharacterAttached;
402 pOutResult.m_bNoParent = m_bUseNoParent;
403 pOutResult.m_bAllowInterpolation = true;
404
405 // Apply shake
407 m_CharacterCameraHandler.AddShakeToToTransform(pOutResult.m_CameraTM, pOutResult.m_fFOV);
408 }
409
410 void UpdateCameraDistanceAndFOV(vector localVelocity, vector lastLocalVelocity, float pDt)
411 {
412 float speed = localVelocity.Length();
413 float speedScale = Math.Clamp(speed / (m_fSpeedMax * KILOMETERS_PER_HOUR_TO_METERS_PER_SEC), 0, 1);
414
416 {
417 float speedDelta = speed - lastLocalVelocity.Length();
418
419 if (speedDelta < m_fCameraMovementForceThreshold)
420 speedDelta = 0;
421
422 // Calculate camera movement local force
423 float fMovementForce = 0;
424 if (speedDelta > 0) // When vehicle is accelerating
425 fMovementForce = m_fCameraMovementForceFactor; // Move the camera away from the vehicle
426 else if (speedDelta < 0) // When vehicle is decelerating
427 fMovementForce = -m_fCameraMovementForceFactor; // MOve the camera towards the vehicle
428
429 if (localVelocity[2] < 0) // When going reverse
430 fMovementForce *= -1;
431
432 // Local force on the camera from an imaginary spring trying to bring it back to the m_fDist_Desired
434
435 // Apply the forces on the camera and Update its velocity
436 m_fCamVelocity += fMovementForce * pDt;
437 m_fCamVelocity += fSpringForce * pDt;
438
439 // Update camera target position and clamp it
441
442 // Add friction and limits to the camera velocity
443 m_fCamVelocity = Math.Clamp(0.5 * m_fCamVelocity, -1.25, 1.25);
444
445 // Smoothen out camera distance
447 }
448 else
449 {
451 }
452
454 {
455 m_fCamFOV = 2.0 * Math.RAD2DEG * Math.Atan2(0.5 * m_fZoomTargetWidth, m_fCamDist);
456 m_fCamFOV = Math.Clamp(m_fCamFOV, 60, 90);
457 }
458 else
459 {
460 m_fCamFOV = m_fFOV + speedScale * m_fFOV_SpeedAdjustMax;
461 }
462 }
463
464 void CalculateLookAngles(vector vehicleAngles, vector characterAngles, out ScriptedCameraItemResult pOutResult)
465 {
466 // Horizontal 3rd person camera lag
467 float horizontalLag = Math.Clamp(-m_vLastAngVel[1] * m_fCameraHorizontalLag, -m_fCameraHorizontalLagMax, m_fCameraHorizontalLagMax); //m_vLastAngVel[1] is actually yaw angular velocity
468
470 vector lookAngles;
471 lookAngles[0] = m_fLeftRightAngle + horizontalLag;
472 lookAngles[1] = m_fUpDownAngleCurrent + m_fInertiaAngle;
473 lookAngles[2] = 0.0;
474
476 Math3D.AnglesToMatrix(lookAngles, pOutResult.m_CameraTM);
477 }
478
479 //------------------------------------------------------------------------------------------------
480 private void UpdateViewBob(float pDt, vector localVelocity, vector localAngularVelocity)
481 {
482 if (!m_bViewBob)
483 return;
484 if (pDt <= 0)
485 return;
486
487 vector velDiff = localVelocity - m_vLastVel;
488 vector angVelDiff = localAngularVelocity - m_vLastAngVel;
489 float speed = localVelocity.Length();
490 float accel = velDiff.Length() * (1 / pDt) + angVelDiff.Length() * (1 / pDt);
491 if (accel > m_fBob_Acceleration)
492 m_fBob_Acceleration += (accel - m_fBob_Acceleration) * Math.Clamp(pDt * 12, 0, 1);
493 else
494 m_fBob_Acceleration += (accel - m_fBob_Acceleration) * Math.Clamp(pDt * 7, 0, 1);
495
496 // Add bobbing based on speed
497 m_fBob_ScaleSlow += (Math.Clamp(speed / (m_fSpeedMax * KILOMETERS_PER_HOUR_TO_METERS_PER_SEC), 0, 1) - m_fBob_ScaleSlow) * (pDt * 4);
498 float slowTimeSlice = (m_fBob_ScaleSlow * m_fBob_ScaleSlow * 1.5 + 1) * pDt;
499 m_fBob_SlowUp += Math.Clamp(slowTimeSlice, 0, 1);
500 if (m_fBob_SlowUp >= 1)
501 m_fBob_SlowUp -= 1;
502 m_fBob_SlowRight += Math.Clamp(slowTimeSlice * 0.75, 0, 1);
503 if (m_fBob_SlowRight >= 1)
504 m_fBob_SlowRight -= 1;
505
506 // Add bobbing based on acceleration
507 m_fBob_ScaleFast = Math.Clamp(m_fBob_Acceleration * 0.03, 0, 1);
508 float fastTimeSlice = m_fBob_ScaleFast * 5 * pDt;
509 if (m_fBob_ScaleFast < 0.01)
510 {
511 m_fBob_FastUp *= 1 - pDt;
512 m_fBob_FastRight *= 1 - pDt;
513 }
514 else
515 {
516 m_fBob_FastUp += Math.Clamp(fastTimeSlice, 0, 1);
517 if (m_fBob_FastUp >= 1)
518 m_fBob_FastUp -= 1;
519 m_fBob_FastRight += Math.Clamp(fastTimeSlice * 1.4, 0, 1);
520 if (m_fBob_FastRight >= 1)
521 m_fBob_FastRight -= 1;
522 }
523 }
524
525 //------------------------------------------------------------------------------------------------
526 private void AddViewBobToTransform(inout vector outTransform[4])
527 {
528 float bobFastScale = m_fBob_ScaleFast * m_fShakeScale;
529 float bobSlowScale = m_fBob_ScaleSlow * m_fBob_ScaleSlow * m_fBobScale;
530
531 float bobFw = Math.Sin(m_fBob_FastUp * 360 * Math.DEG2RAD) * -0.05 * bobFastScale;
532 float bobUp = Math.Sin(m_fBob_FastUp * 360 * Math.DEG2RAD) * 0.05 * bobFastScale;
533 float bobRt = Math.Sin(m_fBob_FastRight * 360 * Math.DEG2RAD) * 0.05 * bobFastScale;
534 float bobYaw = Math.Sin(m_fBob_FastRight * 360 * Math.DEG2RAD) * 0.3 * bobFastScale;
535 float bobPitch = Math.Sin(m_fBob_FastUp * 360 * Math.DEG2RAD) * 0.3 * bobFastScale;
536 float bobRoll = Math.Sin(m_fBob_FastRight * 360 * Math.DEG2RAD) * 0.4 * bobFastScale;
537 bobFw += Math.Sin(m_fBob_SlowUp * 360 * Math.DEG2RAD) * -0.025 * bobSlowScale;
538 bobUp += Math.Sin(m_fBob_SlowUp * 360 * Math.DEG2RAD) * 0.05 * bobSlowScale;
539 bobRt += Math.Sin(m_fBob_SlowRight * 360 * Math.DEG2RAD) * 0.05 * bobSlowScale;
540 bobYaw += Math.Sin(m_fBob_SlowRight * 360 * Math.DEG2RAD) * 0.2 * bobSlowScale;
541 bobPitch += Math.Sin(m_fBob_SlowUp * 360 * Math.DEG2RAD) * 0.2 * bobSlowScale;
542 bobRoll += Math.Sin(m_fBob_SlowRight * 360 * Math.DEG2RAD) * 0.45 * bobSlowScale;
543
544 vector angBobMat[3], endBobmat[3];
545 Math3D.AnglesToMatrix(Vector(bobPitch, bobYaw, bobRoll), angBobMat);
546 Math3D.MatrixMultiply3(outTransform, angBobMat, endBobmat);
547 outTransform[0] = endBobmat[0];
548 outTransform[1] = endBobmat[1];
549 outTransform[2] = endBobmat[2];
550 outTransform[3] = Vector(bobRt, bobUp, bobFw).Multiply3(outTransform) + outTransform[3];
551 }
552
553 //------------------------------------------------------------------------------------------------
554 override float GetBaseFOV()
555 {
556 CameraManager cameraManager = GetGame().GetCameraManager();
557 if (!cameraManager)
558 return 0;
559
560 return cameraManager.GetVehicleFOV();
561 }
562}
563//---- REFACTOR NOTE END ----
const float KILOMETERS_PER_HOUR_TO_METERS_PER_SEC
Definition Constants.c:6
const float METERS_PER_SEC_TO_KILOMETERS_PER_HOUR
Contains various global constants.
Definition Constants.c:5
ArmaReforgerScripted GetGame()
Definition game.c:1398
ref array< string > angles
InputManager GetInputManager()
override void CalculateLookAngles(vector vehicleAngles, vector characterAngles, out ScriptedCameraItemResult pOutResult)
float m_fUpDownAngle
runtime values
void UpdateCameraDistanceAndFOV(vector localVelocity, vector lastLocalVelocity, float pDt)
float m_fLeftRightAngle
left right angle in rad
CharacterInputContext m_Input
SCR_VehicleCameraAimpoint m_pCameraAimpointData
override void OnActivate(ScriptedCameraItem pPrevCamera, ScriptedCameraItemResult pPrevCameraResult)
CharacterHeadAimingComponent m_CharacterHeadAimingComponent
override void OnUpdate(float pDt, out ScriptedCameraItemResult pOutResult)
void CharacterCamera3rdPersonVehicle(CameraHandlerComponent pCameraHandler)
ChimeraCharacter m_OwnerCharacter
SCR_CharacterCameraHandlerComponent m_CharacterCameraHandler
override vector GetBaseAngles()
void CalculateLookAngles(vector vehicleAngles, vector characterAngles, out ScriptedCameraItemResult pOutResult)
static AnimationTagID sm_TagLyingCamera
override void OnDeactivate(ScriptedCameraItem pNextCamera)
SCR_VehicleCameraAlignment m_pCameraAlignData
proto external Managed FindComponent(typename typeName)
proto external Physics GetPhysics()
proto external void GetBounds(out vector mins, out vector maxs)
proto external IEntity GetRootParent()
Definition Math.c:13
PointInfo - allows to define position.
Definition PointInfo.c:9
Contains various scripted 3D math functions.
Definition SCR_Math3D.c:3
proto native vector Vector(float x, float y, float z)