7 static const float CONST_UD_MIN = -45.0;
8 static const float CONST_UD_MAX = 30.0;
9 static const float CONST_UD_CAMERA_ANGLE_OFFSET = -10.0;
12 protected TurretComponent m_pControlledTurret;
13 protected vector m_vVertAimLimits;
14 protected vector m_vHorAimLimits;
15 protected vector m_vCameraCenter;
16 protected float m_fLRAngleAdd;
18 protected float m_fDist_Min;
19 protected IEntity m_OwnerVehicle;
21 protected vector m_vLastCameraAngles;
23 void CharacterCamera3rdPersonTurret(CameraHandlerComponent pCameraHandler)
25 m_bLRAngleNoLimit =
true;
31 CompartmentAccessComponent compartmentAccess =
m_OwnerCharacter.GetCompartmentAccessComponent();
32 if (compartmentAccess && compartmentAccess.IsInCompartment())
34 auto compartment = compartmentAccess.GetCompartment();
35 m_OwnerVehicle = compartment.GetVehicle();
36 IEntity turret = compartment.GetOwner();
40 turret.GetBounds(mins, maxs);
41 m_vCameraCenter = (maxs - mins) * 0.5 + mins;
47 m_fDist_Min = vehicleCamData.m_fDist_Min;
48 m_fFOV = vehicleCamData.m_fFOV;
49 m_vCameraCenter[1] = m_vCameraCenter[1] +
m_fHeight;
50 m_vCameraCenter[2] = m_vCameraCenter[2] - m_fDist_Min;
51 m_fRollFactor = vehicleCamData.m_fRollFactor;
52 m_fPitchFactor = vehicleCamData.m_fPitchFactor;
57 if (!m_pTurretController)
60 m_pControlledTurret = m_pTurretController.GetTurretComponent();
61 if (!m_pControlledTurret)
64 m_pControlledTurret.GetAimingLimits(m_vHorAimLimits, m_vVertAimLimits);
65 m_vVertAimLimits[0] = CONST_UD_MIN;
66 m_vVertAimLimits[1] = CONST_UD_MAX;
72 override void OnActivate(ScriptedCameraItem pPrevCamera, ScriptedCameraItemResult pPrevCameraResult)
74 super.OnActivate(pPrevCamera, pPrevCameraResult);
79 override void OnUpdate(
float pDt, out ScriptedCameraItemResult pOutResult)
81 CompartmentAccessComponent compartmentAccess =
m_OwnerCharacter.GetCompartmentAccessComponent();
82 if (compartmentAccess && compartmentAccess.IsInCompartment() )
84 auto compartment = compartmentAccess.GetCompartment();
85 if (m_OwnerVehicle != compartment.GetVehicle())
91 if (!m_pControlledTurret || !m_pTurretController)
104 parentEntity.GetWorldTransform(turretMat);
106 vector charAngles = Math3D.MatrixToAngles(charMat);
107 vector lookAngles = m_CharacterHeadAimingComponent.GetLookAngles();
109 CharacterControllerComponent charController =
m_OwnerCharacter.GetCharacterController();
112 m_vLastCameraAngles = m_pControlledTurret.GetAimingDirectionWorld().VectorToAngles();
113 if (charController.IsFreeLookEnabled() || m_pTurretController.GetCanAimOnlyInADS())
115 m_vLastCameraAngles += lookAngles;
117 Math3D.AnglesToMatrix(m_vLastCameraAngles - charAngles, pOutResult.m_CameraTM);
120 vector cameraPositionLS = turretMat[3].InvMultiply4(turretMat) + Vector(0, m_vCameraCenter[1], 0);
122 CompartmentAccessComponent cac =
m_OwnerCharacter.GetCompartmentAccessComponent();
123 if (!(cac && (cac.IsGettingOut() || cac.IsGettingIn())))
126 float charHeight = (charMat[3] - turretMat[3]).InvMultiply3(turretMat)[1];
127 cameraPositionLS[1] = cameraPositionLS[1] - charHeight;
131 pOutResult.m_CameraTM[3] = cameraPositionLS;
133 const float camDist = 2.0;
136 pOutResult.m_fUseHeading = 0.0;
137 pOutResult.m_fFOV = m_fFOV;
138 pOutResult.m_fDistance = camDist;
139 pOutResult.m_bAllowInterpolation =
true;
140 pOutResult.m_pWSAttachmentReference =
null;
142 pOutResult.m_bUpdateWhenBlendOut =
false;
145 if (m_CharacterCameraHandler)
146 m_CharacterCameraHandler.AddShakeToToTransform(pOutResult.m_CameraTM, pOutResult.m_fFOV);
150 override void OnAfterCameraUpdate(
float pDt,
bool pIsKeyframe, inout vector transformMS[4])
152 AddVehiclePitchRoll(m_OwnerVehicle, pDt, transformMS);