8 protected TurretComponent m_pControlledTurret;
10 protected vector m_vVertAimLimits;
11 protected vector m_vHorAimLimits;
12 protected float m_fLRAngleAdd;
13 protected vector m_vPrevEyePosition;
14 protected IEntity m_OwnerVehicle;
16 protected vector m_vLastCameraAngles;
19 void CharacterCamera1stPersonTurret(CameraHandlerComponent pCameraHandler)
21 m_ApplyHeadBob =
false;
23 m_OffsetLS =
"0.0 0.1 0.0";
24 m_bLRAngleNoLimit =
true;
28 override void OnActivate(ScriptedCameraItem pPrevCamera, ScriptedCameraItemResult pPrevCameraResult)
30 super.OnActivate(pPrevCamera, pPrevCameraResult);
32 if (m_pCompartmentAccess && m_pCompartmentAccess.IsInCompartment())
34 BaseCompartmentSlot compartment = m_pCompartmentAccess.GetCompartment();
37 m_OwnerVehicle = compartment.GetVehicle();
42 m_fRollFactor = vehicleCamData.m_fRollFactor;
43 m_fPitchFactor = vehicleCamData.m_fPitchFactor;
47 if (!m_pTurretController)
51 m_pControlledTurret = m_pTurretController.GetTurretComponent();
52 if (!m_pControlledTurret)
55 m_pControlledTurret.GetAimingLimits(m_vHorAimLimits, m_vVertAimLimits);
62 m_CharacterHeadAimingComponent.SetPitchLimitReductionMultiplier(1.25);
65 static float UpdateAngleWithTarget(out
float pAngle, out
float pAngleAdd, out
float addVelocity, vector limits,
float pDt,
float target,
float change,
bool freeLook)
69 pAngle = Math.Clamp(pAngle, limits[0], limits[1]);
71 pAngleAdd = Math.SmoothCD(pAngleAdd, 0, addVelocity, 0.14, 1000, pDt);
73 return Math.Clamp(pAngle + pAngleAdd, limits[0], limits[1]);
76 override void OnUpdate(
float pDt, out ScriptedCameraItemResult pOutResult)
79 if (!m_pControlledTurret)
82 pOutResult.m_pWSAttachmentReference =
null;
84 pOutResult.m_fPositionModelSpace = 1.0;
85 pOutResult.m_fFOV = m_fFOV;
86 pOutResult.m_fNearPlane = 0.04;
87 pOutResult.m_bAllowInterpolation =
true;
88 pOutResult.m_bUpdateWhenBlendOut =
true;
89 pOutResult.m_fUseHeading = 0.0;
90 pOutResult.m_iDirectBoneMode = EDirectBoneMode.None;
91 pOutResult.m_iDirectBone = -1;
93 vector offset = m_OffsetLS;
94 if (m_pCompartment && m_pCompartment.IsDirectAimMode() && m_pTurretController.GetCanAimOnlyInADS())
99 CharacterControllerComponent charController =
m_OwnerCharacter.GetCharacterController();
102 m_vLastCameraAngles = m_pControlledTurret.GetAimingDirectionWorld().VectorToAngles();
103 if (charController.IsFreeLookEnabled() || m_pTurretController.GetCanAimOnlyInADS())
106 float turretPitch = m_pControlledTurret.GetAimingRotation()[1];
107 float downLimit = -40.0;
108 if (turretPitch < 0.0)
109 downLimit -= turretPitch;
110 float upLimit = 89.9;
111 if (turretPitch > 0.0)
112 upLimit -= turretPitch;
114 float turretYaw = m_pControlledTurret.GetAimingRotation()[0];
115 float leftLimit = -160.0;
117 leftLimit -= turretYaw;
118 float rightLimit = 160.0;
120 rightLimit -= turretYaw;
122 m_CharacterHeadAimingComponent.SetLimitAnglesOverride(downLimit, upLimit, leftLimit, rightLimit);
124 vector lookAnglesOverriden = m_CharacterHeadAimingComponent.GetLookAngles();
125 m_vLastCameraAngles += lookAnglesOverriden;
127 m_CharacterHeadAimingComponent.ResetLimitAnglesOverride();
133 vector charAngles = Math3D.MatrixToAngles(charMat);
135 Math3D.AnglesToMatrix(m_vLastCameraAngles - charAngles, pOutResult.m_CameraTM);
138 m_vPrevEyePosition = vector.Lerp(m_vPrevEyePosition,
m_OwnerCharacter.EyePositionModel(), 0.25);
139 pOutResult.m_CameraTM[3] = m_vPrevEyePosition + offset;
142 if (m_CharacterCameraHandler)
143 m_CharacterCameraHandler.AddShakeToToTransform(pOutResult.m_CameraTM, pOutResult.m_fFOV);
147 override void OnAfterCameraUpdate(
float pDt,
bool pIsKeyframe, inout vector transformMS[4])
149 AddVehiclePitchRoll(m_OwnerVehicle, pDt, transformMS);
153 override float GetBaseFOV()
155 CameraManager cameraManager =
GetGame().GetCameraManager();
159 return cameraManager.GetVehicleFOV();