Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
CharacterCameraADSVehicle.c
Go to the documentation of this file.
1// *************************************************************************************
2// ! CharacterCameraADSVehicle - ADS 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 ----
5class CharacterCameraADSVehicle extends CharacterCameraADS
6{
10
11 //------------------------------------------------------------------------------------------------
12 // constructor
15 {
16 m_WeaponManager = null;
17 m_OwnerVehicle = null;
18 m_TurretController = null;
19
21 return;
22
23 CompartmentAccessComponent compartmentAccess = m_OwnerCharacter.GetCompartmentAccessComponent();
24 if (!compartmentAccess || !compartmentAccess.IsInCompartment())
25 return;
26
27 BaseCompartmentSlot compartment = compartmentAccess.GetCompartment();
28 if (!compartment)
29 return;
30
31 m_TurretController = TurretControllerComponent.Cast(compartment.GetController());
33 m_TurretController = compartment.GetAttachedTurret();
34
36 m_WeaponManager = m_TurretController.GetWeaponManager();
37
38 m_OwnerVehicle = compartment.GetVehicle();
39 if (!m_OwnerVehicle)
40 return;
41
42 SCR_VehicleCameraDataComponent vehicleCamDataComp = SCR_VehicleCameraDataComponent.Cast(m_OwnerVehicle.FindComponent(SCR_VehicleCameraDataComponent));
43 if (!vehicleCamDataComp)
44 return;
45
46 SCR_VehicleCameraDataComponentClass vehicleCamData = SCR_VehicleCameraDataComponentClass.Cast(vehicleCamDataComp.GetComponentData(m_OwnerVehicle));
47 if (!vehicleCamData)
48 return;
49
50 m_fRollFactor = vehicleCamData.m_fRollFactor;
51 m_fPitchFactor = vehicleCamData.m_fPitchFactor;
52 }
53
54 //------------------------------------------------------------------------------------------------
55 override void OnBlendIn()
56 {
57 OnBlendingIn(1.0);
58 }
59
60 //------------------------------------------------------------------------------------------------
61 override void OnBlendOut()
62 {
63 OnBlendingOut(1.0);
64 }
65
66 //------------------------------------------------------------------------------------------------
67 override protected void OnBlendingIn(float blendAlpha)
68 {
69 if (blendAlpha < GetSightsADSActivationPercentage())
70 return;
71
72 // Only enable if not enabled
73 if (m_TurretController && !m_TurretController.GetCurrentSightsADS())
74 {
75 m_TurretController.SetCurrentSightsADS(true);
76
77 SCR_OptimizedMuzzleEffectComponent.OptimizeMuzzleEffect(true, m_TurretController);
78
79 }
80 }
81
82 //------------------------------------------------------------------------------------------------
83 override protected void OnBlendingOut(float blendAlpha)
84 {
85 if (blendAlpha < GetSightsADSDeactivationPercentage())
86 return;
87
88 // Only disable if enabled
89 if (m_TurretController && m_TurretController.GetCurrentSightsADS())
90 {
91 m_TurretController.SetCurrentSightsADS(false);
92
93 SCR_OptimizedMuzzleEffectComponent.OptimizeMuzzleEffect(false, m_TurretController);
94 }
95 }
96
97 //------------------------------------------------------------------------------------------------
98 override void OnUpdate(float pDt, out ScriptedCameraItemResult pOutResult)
99 {
100 if (m_CameraHandler && m_CameraHandler.IsCameraBlending())
101 {
102 if (m_CameraHandler.GetCurrentCamera() == this)
103 OnBlendingIn(m_CameraHandler.GetBlendAlpha(this));
104 else
105 OnBlendingOut(m_CameraHandler.GetBlendAlpha(m_CameraHandler.GetCurrentCamera()));
106 }
107
108 BaseSightsComponent sights;
109
111 {
112 TurretComponent turret = m_TurretController.GetTurretComponent();
113 vector aimingTranslationWeaponLS = turret.GetRawAimingTranslation();
114
115 // Disable recoil camera translation of turret mounted weapons
116 aimingTranslationWeaponLS -= turret.GetCurrentRecoilTranslation();
117
118 // Sight camera slot
119 sights = turret.GetSights();
120 PointInfo cameraSlot;
121 if (sights)
122 cameraSlot = sights.GetPositionPointInfo();
123
124 // Legacy camera slot of TurretComponent
125 if (!cameraSlot)
126 cameraSlot = turret.GetCameraAttachmentSlot();
127
128 if (cameraSlot != m_CameraSlot)
129 m_CameraSlot = cameraSlot;
130
132 if (cameraSlot)
133 {
134 vector sightLSMat[4];
135 m_TurretController.GetCurrentSightsCameraLocalTransform(sightLSMat, pOutResult.m_fFOV);
136 sightLSMat[3] = sightLSMat[3] - aimingTranslationWeaponLS;
137
138 vector cameraSlotMat[4];
139 cameraSlot.GetModelTransform(cameraSlotMat);
140
141 pOutResult.m_CameraTM[3] = (sightLSMat[3] - cameraSlotMat[3]).InvMultiply3(cameraSlotMat);
142 pOutResult.m_pWSAttachmentReference = cameraSlot;
143 pOutResult.m_pOwner = m_OwnerCharacter;
144 }
145 else
146 {
147 //Add translation
148 vector sightWSMat[4];
149 m_TurretController.GetCurrentSightsCameraTransform(sightWSMat, pOutResult.m_fFOV);
150 sightWSMat[3] = sightWSMat[3] - aimingTranslationWeaponLS.Multiply3(sightWSMat);
151
152 // character matrix
153 vector charMat[4];
154 m_OwnerCharacter.GetTransform(charMat);
155 Math3D.MatrixInvMultiply4(charMat, sightWSMat, pOutResult.m_CameraTM);
156
157 pOutResult.m_pWSAttachmentReference = null;
158 pOutResult.m_pOwner = m_OwnerCharacter;
159 }
160 }
161
162 pOutResult.m_iDirectBone = -1;
163 pOutResult.m_iDirectBoneMode = EDirectBoneMode.None;
164 pOutResult.m_bUpdateWhenBlendOut = false;
165 pOutResult.m_fDistance = 0;
166 pOutResult.m_fUseHeading = 0;
167 pOutResult.m_fNearPlane = 0.025;
168 pOutResult.m_bAllowInterpolation = true;
169
170 // Apply unroll
171 IEntity owner = m_OwnerVehicle;
173 owner = m_TurretController.GetOwner();
174
175 m_fPitchFactor = 0;
176 AddVehiclePitchRoll(owner, pDt, pOutResult.m_CameraTM);
177
178 // Apply shake
180 m_CharacterCameraHandler.AddShakeToToTransform(pOutResult.m_CameraTM, pOutResult.m_fFOV);
181
182 if (!sights)
183 return;
184
185 SCR_SightsZoomFOVInfo fovInfo = SCR_SightsZoomFOVInfo.Cast(sights.GetFOVInfo());
186 if (fovInfo)
187 fovInfo.ForceUpdate(m_TurretController.GetOwner(), sights, pDt);
188 }
189}
190//---- REFACTOR NOTE END ----
EDirectBoneMode
float GetSightsADSDeactivationPercentage()
override void OnUpdate(float pDt, out ScriptedCameraItemResult pOutResult)
void OnBlendingIn(float blendAlpha)
BaseWeaponManagerComponent m_WeaponManager
float GetSightsADSActivationPercentage()
TurretControllerComponent m_TurretController
void OnBlendingOut(float blendAlpha)
void CharacterCameraADSVehicle(CameraHandlerComponent pCameraHandler)
ChimeraCharacter m_OwnerCharacter
SCR_CharacterCameraHandlerComponent m_CharacterCameraHandler
void AddVehiclePitchRoll(IEntity vehicle, float pDt, inout vector transformMS[4])
PointInfo - allows to define position.
Definition PointInfo.c:9
void ForceUpdate(IEntity owner, BaseSightsComponent sights, float timeSlice)
CameraHandlerComponent m_CameraHandler
data