5 while (pAngle > Math.PI)
8 while (pAngle < -Math.PI)
33 m_fFOV = GetBaseFOV();
35 m_CharacterCameraHandler = SCR_CharacterCameraHandlerComponent.Cast(
m_CameraHandler);
36 m_OwnerCharacter = ChimeraCharacter.Cast(pCameraHandler.GetOwner());
38 m_Input = m_ControllerComponent.GetInputContext();
39 if (sm_TagFPCamera == -1)
43 if (sm_TagADSTransitionIn == -1)
47 if (sm_TagADSTransitionOut == -1)
49 sm_TagADSTransitionOut =
GameAnimationUtils.RegisterAnimationTag(
"TagTransitionADSOut");
51 if (sm_TagLyingCamera == -1)
55 if (sm_TagItemUpdateCols == -1)
57 sm_TagItemUpdateCols =
GameAnimationUtils.RegisterAnimationTag(
"TagItemUpdateColliders");
59 if (sm_iCameraBoneIndex == -1)
61 Animation anim = m_OwnerCharacter.GetAnimation();
62 sm_iHeadBoneIndex = anim.GetBoneIndex(
"Head");
63 sm_iCameraBoneIndex = anim.GetBoneIndex(
"Camera");
65 m_CharacterAnimationComponent = CharacterAnimationComponent.Cast(m_OwnerCharacter.FindComponent(CharacterAnimationComponent));
66 CharacterCommandHandlerComponent cmdHandler = CharacterCommandHandlerComponent.Cast(m_CharacterAnimationComponent.FindComponent(CharacterCommandHandlerComponent));
67 m_CharacterHeadAimingComponent = CharacterHeadAimingComponent.Cast(m_OwnerCharacter.FindComponent(CharacterHeadAimingComponent));
68 m_CommandWeapons = cmdHandler.GetCommandModifier_Weapon();
69 m_CompartmentAccessComponent = m_OwnerCharacter.GetCompartmentAccessComponent();
70 m_CmdHandler = cmdHandler;
74 float UpdateUDAngle(out
float pAngle,
float pMin,
float pMax,
float pDt)
76 pAngle = Math.Clamp(m_CharacterHeadAimingComponent.GetAimingRotation()[1], pMin, pMax);
79 if (m_CompartmentAccessComponent && !m_CompartmentAccessComponent.IsInCompartment())
80 pAngle += m_ControllerComponent.GetInputContext().GetAimingAngles()[1];
86 float UpdateLRAngle(
float pAngle,
float pMin,
float pMax,
float pDt)
88 bool bCompartmentForcesFreeLook =
false;
89 if (m_CompartmentAccessComponent && m_CompartmentAccessComponent.IsInCompartment())
90 bCompartmentForcesFreeLook = m_CompartmentAccessComponent.GetCompartment().GetForceFreeLook();
93 if (m_ControllerComponent.IsFreeLookEnabled() || m_ControllerComponent.IsTrackIREnabled() || m_bForceFreeLook || bCompartmentForcesFreeLook)
95 pAngle = m_CharacterHeadAimingComponent.GetAimingRotation()[0];
97 if (!m_bLRAngleNoLimit)
99 pAngle = Math.Clamp(pAngle, pMin, pMax);
110 pAngle = Math.SmoothCD(pAngle, 0, m_fLRAngleVel, 0.14, 1000, pDt);
117 override void OnUpdate(
float pDt, out ScriptedCameraItemResult pOutResult);
120 override void OnActivate(ScriptedCameraItem pPrevCamera, ScriptedCameraItemResult pPrevCameraResult)
136 m_CameraHandler.SetLensFlareSet(CameraLensFlareSetType.ThirdPerson,
"");
140 m_CameraHandler.SetLensFlareSet(CameraLensFlareSetType.FirstPerson,
"");
146 m_fPitchSmooth = prevCameraBase.m_fPitchSmooth;
147 m_fPitchSmoothVel = prevCameraBase.m_fPitchSmoothVel;
148 m_fRollSmooth = prevCameraBase.m_fRollSmooth;
149 m_fRollSmoothVel = prevCameraBase.m_fRollSmoothVel;
152 m_CharacterHeadAimingComponent.SetPitchLimitReductionMultiplier(1.0);
153 m_CharacterHeadAimingComponent.ResetLimitAnglesOverride();
157 void ForceFreelook(
bool state)
159 m_bForceFreeLook = state;
165 int GetShoulderLastActive()
167 return m_fShoulderLastActive;
173 float GetShoulderDistance()
181 float GetInterpolatedUDTransformAngle(
float pDt)
183 vector physTransform[4];
184 m_OwnerCharacter.GetLocalTransform(physTransform);
185 m_fTransformUDAngle = Math.SmoothCD(m_fTransformUDAngle, physTransform[2][1], m_fTransformUDAngleVel, 0.14, 1000, pDt);
186 return m_fTransformUDAngle * Math.RAD2DEG;
195 void AddPitchRoll(vector yawPitchRoll,
float pitchFactor,
float rollFactor, inout vector transformMS[4])
198 vector cameraForward = transformMS[2];
199 cameraForward[1] = 0.0;
200 cameraForward.Normalize();
203 vector cameraAside = transformMS[0];
205 cameraAside.Normalize();
208 float rollAmount = vector.Dot(cameraForward, vector.Forward);
209 float pitchAmount = vector.Dot(cameraAside, vector.Forward);
211 float pitch = yawPitchRoll[1];
212 float roll = yawPitchRoll[2];
214 float newPitch = pitchFactor * (pitch * rollAmount - roll * pitchAmount);
215 float newRoll = rollFactor * (roll * rollAmount - pitch * pitchAmount);
218 vector newPitchRoll = Vector(0, newPitch, newRoll);
220 Math3D.AnglesToMatrix(newPitchRoll, rotMat);
223 Math3D.MatrixMultiply3(transformMS, rotMat, transformMS);
227 protected void AddVehiclePitchRoll(IEntity vehicle,
float pDt, inout vector transformMS[4])
233 vehicle.GetTransform(vehMat);
236 vector yawPitchRoll = Math3D.MatrixToAngles(vehMat);
237 m_fPitchSmooth = Math.SmoothCD(m_fPitchSmooth, -yawPitchRoll[1], m_fPitchSmoothVel, 0.14, 1000, pDt);
238 m_fRollSmooth = Math.SmoothCD(m_fRollSmooth, -yawPitchRoll[2], m_fRollSmoothVel, 0.14, 1000, pDt);
240 yawPitchRoll[1] = m_fPitchSmooth;
241 yawPitchRoll[2] = m_fRollSmooth;
243 float rollMask = Math.Max(0, vehMat[1][1]);
244 AddPitchRoll(yawPitchRoll, m_fPitchFactor, rollMask * m_fRollFactor, transformMS);
248 protected float m_fUpDownAngle;
249 protected float m_fUpDownAngleAdd;
250 protected float m_fLeftRightAngle = 0.0;
253 override void SetBaseAngles(out vector angles)
260 override vector GetBaseAngles()
262 return m_CharacterHeadAimingComponent.GetLookAngles();
269 protected TNodeId GetCameraBoneIndex()
271 if (m_CharacterAnimationComponent.IsPrimaryTag(sm_TagFPCamera))
273 return sm_iCameraBoneIndex;
275 return sm_iHeadBoneIndex;
278 protected float m_fFOV;
280 protected float m_fLRAngleVel;
281 protected float m_fUDAngleVel;
282 protected float m_fTransformUDAngleVel;
283 protected float m_fTransformUDAngle;
284 protected bool m_bForceFreeLook;
285 protected bool m_bLRAngleNoLimit;
287 protected bool m_bIgnoreCharacterPitch;
289 protected float m_fFOVFilter;
290 protected float m_fFOVFilterVel;
292 protected int m_fShoulderLastActive = 1;
294 protected float m_fRollFactor;
295 protected float m_fRollSmooth;
296 protected float m_fRollSmoothVel;
297 protected float m_fPitchFactor;
298 protected float m_fPitchSmooth;
299 protected float m_fPitchSmoothVel;
301 protected ChimeraCharacter m_OwnerCharacter;
304 protected SCR_CharacterCameraHandlerComponent m_CharacterCameraHandler;
305 protected CharacterAnimationComponent m_CharacterAnimationComponent;
306 protected CharacterHeadAimingComponent m_CharacterHeadAimingComponent;
308 protected CompartmentAccessComponent m_CompartmentAccessComponent;
309 protected CharacterCommandHandlerComponent m_CmdHandler;
310 protected float m_fShakeProgress;
311 protected float m_fShakeVelocity;
312 protected static TNodeId sm_iCameraBoneIndex = -1;
313 protected static TNodeId sm_iHeadBoneIndex = -1;
314 protected static AnimationTagID sm_TagFPCamera = -1;
315 protected static AnimationTagID sm_TagLyingCamera = -1;
316 protected static AnimationTagID sm_TagItemUpdateCols = -1;
317 protected static AnimationTagID sm_TagADSTransitionOut = -1;
318 protected static AnimationTagID sm_TagADSTransitionIn = -1;