7 protected IEntity m_OwnerVehicle;
8 protected float m_fAngleFirstPerson;
9 protected float m_fAngleFirstPersonScale;
14 m_ApplyHeadBob =
false;
18 override void OnActivate(ScriptedCameraItem pPrevCamera, ScriptedCameraItemResult pPrevCameraResult)
20 super.OnActivate(pPrevCamera, pPrevCameraResult);
22 CharacterCamera3rdPersonVehicle characterCamera3rdPersonVehicle = CharacterCamera3rdPersonVehicle.Cast(pPrevCamera);
23 if (characterCamera3rdPersonVehicle)
25 m_fRollSmooth = characterCamera3rdPersonVehicle.m_fRollSmooth;
26 m_fRollSmoothVel = characterCamera3rdPersonVehicle.m_fRollSmoothVel;
27 m_fPitchSmooth = characterCamera3rdPersonVehicle.m_fPitchSmooth;
28 m_fPitchSmoothVel = characterCamera3rdPersonVehicle.m_fPitchSmoothVel;
31 if (m_pCompartmentAccess)
33 BaseCompartmentSlot compartment = m_pCompartmentAccess.GetCompartment();
36 m_OwnerVehicle = compartment.GetOwner();
43 m_fRollFactor = vehicleCamData.m_fRollFactor;
44 m_fPitchFactor = vehicleCamData.m_fPitchFactor;
45 m_fAngleFirstPerson = vehicleCamData.m_fAngleFirstPerson * Math.DEG2RAD;
49 m_fAngleFirstPersonScale = 0;
51 m_fAngleFirstPersonScale = 1;
56 m_bCameraTransition =
false;
61 override void OnUpdate(
float pDt, out ScriptedCameraItemResult pOutResult)
63 if (!m_bCameraTransition)
65 m_UseLookPositionOverrideLS =
true;
68 float yawOffset = -0.5 * m_CharacterHeadAimingComponent.GetLookAngles()[0];
69 vector additiveYaw = { yawOffset, 0.0, 0.0 };
72 const float OneBy90 = 1.0 / 90.0;
73 float zOffset = -0.07 - 0.13 * Math.Clamp(Math.AbsFloat(additiveYaw[0] * OneBy90), 0.0, 1.0);
74 vector offsetLS = { m_OffsetLS[0], m_OffsetLS[1], zOffset };
77 m_CharacterHeadAimingComponent.GetLookTransformationLS(GetCameraBoneIndex(), EDirectBoneMode.RelativePosition, offsetLS, additiveYaw, resultTM);
78 m_LookPositionOverrideLS = resultTM[3];
80 m_CharacterHeadAimingComponent.SetPitchLimitReductionMultiplier(0.5);
83 super.OnUpdate(pDt, pOutResult);
84 pOutResult.m_fUseHeading = 0.0;
85 AddVehiclePitchRoll(m_OwnerVehicle, pDt, pOutResult.m_CameraTM);
90 if (sm_TagLyingCamera != -1 && sm_TagItemUpdateCols != -1)
92 CharacterAnimationComponent characterAnimationComponent =
m_OwnerCharacter.GetAnimationComponent();
93 if (characterAnimationComponent && characterAnimationComponent.IsPrimaryTag(sm_TagLyingCamera))
97 pOutResult.m_vBaseAngles = m_CharacterHeadAimingComponent.GetAimingRotation();
98 pOutResult.m_fUseHeading = 0.0;
99 pOutResult.m_iDirectBoneMode = EDirectBoneMode.RelativePosition;
100 pOutResult.m_iDirectBone = GetCameraBoneIndex();
101 pOutResult.m_bAllowInterpolation =
true;
103 vector additiveRotation =
"0 0 0";
104 vector offset = m_OffsetLS;
105 m_CharacterHeadAimingComponent.GetLookTransformationLS(pOutResult.m_iDirectBone, pOutResult.m_iDirectBoneMode, offset, additiveRotation, pOutResult.m_CameraTM);
107 m_CharacterCameraHandler.AddViewBobToTransform(pOutResult.m_CameraTM, 1,
false);
110 if (!characterAnimationComponent.IsPrimaryTag(sm_TagItemUpdateCols))
111 Math3D.AnglesToMatrix(Vector(0, 90, 0), rotMat);
116 vector camAngles = Math3D.MatrixToAngles(camMatrix);
117 Math3D.AnglesToMatrix(Vector(0, -camAngles[1], 0), rotMat);
121 Math3D.MatrixMultiply3(rotMat, pOutResult.m_CameraTM, pOutResult.m_CameraTM);
127 if (
float.AlmostEqual(m_fAngleFirstPerson, 0))
131 Vehicle vehicle = Vehicle.Cast(m_OwnerVehicle);
136 m_fAngleFirstPersonScale -= pDt * 3;
138 m_fAngleFirstPersonScale += pDt * 3;
140 m_fAngleFirstPersonScale = Math.Clamp(m_fAngleFirstPersonScale, 0, 1);
142 SCR_Math3D.RotateAround(pOutResult.m_CameraTM, pOutResult.m_CameraTM[3], pOutResult.m_CameraTM[0], m_fAngleFirstPerson * m_fAngleFirstPersonScale, pOutResult.m_CameraTM);
146 override void OnAfterCameraUpdate(
float pDt,
bool pIsKeyframe, inout vector transformMS[4])
151 override float GetBaseFOV()
153 CameraManager cameraManager =
GetGame().GetCameraManager();
157 return cameraManager.GetVehicleFOV();
165 private bool m_isExiting =
false;
168 override void OnActivate(ScriptedCameraItem pPrevCamera, ScriptedCameraItemResult pPrevCameraResult)
170 super.OnActivate(pPrevCamera, pPrevCameraResult);
171 m_bCameraTransition =
true;
175 override void OnUpdate(
float pDt, out ScriptedCameraItemResult pOutResult)
177 super.OnUpdate(pDt, pOutResult);
178 if (m_pCompartmentAccess)
180 if (m_pCompartmentAccess.IsGettingOut())
183 if (!m_pCompartmentAccess.IsInCompartment() && m_isExiting)
185 pOutResult.m_bAllowInterpolation =
false;
186 pOutResult.m_fUseHeading = 1.0;