Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
CharacterCameraADSVehicle.c
Go to the documentation of this file.
1 // *************************************************************************************
2 // ! CharacterCameraADSVehicle - ADS camera when character is in vehicle
3 // *************************************************************************************
4 class CharacterCameraADSVehicle extends CharacterCameraADS
5 {
7  private IEntity m_OwnerVehicle;
8  private bool m_bUseCameraSlot;
9 
10  //------------------------------------------------------------------------------------------------
11  // constructor
13  void CharacterCameraADSVehicle(CameraHandlerComponent pCameraHandler)
14  {
15  m_WeaponManager = null;
16 
17  CompartmentAccessComponent compartmentAccess = m_OwnerCharacter.GetCompartmentAccessComponent();
18  if (compartmentAccess && compartmentAccess.IsInCompartment())
19  {
20  BaseCompartmentSlot compartment = compartmentAccess.GetCompartment();
21  if (compartment)
22  {
23  m_OwnerVehicle = compartment.GetVehicle();
24 
25  SCR_VehicleCameraDataComponent vehicleCamData = SCR_VehicleCameraDataComponent.Cast(m_OwnerVehicle.FindComponent(SCR_VehicleCameraDataComponent));
26  if (vehicleCamData)
27  {
28  m_fRollFactor = vehicleCamData.m_fRollFactor;
29  m_fPitchFactor = vehicleCamData.m_fPitchFactor;
30  }
31 
32  BaseControllerComponent controller = compartment.GetController();
33  if (controller)
34  {
37  m_WeaponManager = m_TurretController.GetWeaponManager();
38  }
39  }
40  }
41  }
42 
43  //------------------------------------------------------------------------------------------------
44  override void OnBlendIn()
45  {
46  OnBlendingIn(1.0);
47  }
48 
49  //------------------------------------------------------------------------------------------------
50  override void OnBlendOut()
51  {
52  OnBlendingOut(1.0);
53  }
54 
55  //------------------------------------------------------------------------------------------------
56  override protected void OnBlendingIn(float blendAlpha)
57  {
58  if (m_TurretController && blendAlpha >= GetSightsADSActivationPercentage())
59  {
60  if (!m_TurretController.GetCurrentSightsADS()) // Only enable if not enabled yet
61  m_TurretController.SetCurrentSightsADS(true);
62  }
63  }
64 
65  //------------------------------------------------------------------------------------------------
66  override protected void OnBlendingOut(float blendAlpha)
67  {
68  if (m_TurretController && blendAlpha >= GetSightsADSDeactivationPercentage())
69  {
70  if (m_TurretController.GetCurrentSightsADS()) // Only disable if enabled
71  m_TurretController.SetCurrentSightsADS(false);
72  }
73  }
74 
75  //------------------------------------------------------------------------------------------------
76  override void OnUpdate(float pDt, out ScriptedCameraItemResult pOutResult)
77  {
78  if (m_CameraHandler && m_CameraHandler.IsCameraBlending())
79  {
80  if (m_CameraHandler.GetCurrentCamera() == this)
81  OnBlendingIn(m_CameraHandler.GetBlendAlpha(this));
82  else
83  OnBlendingOut(m_CameraHandler.GetBlendAlpha(m_CameraHandler.GetCurrentCamera()));
84  }
85 
86  TurretComponent turret = m_TurretController.GetTurretComponent();
87  vector aimingTranslationWeaponLS = turret.GetRawAimingTranslation();
88 
90  vector sightWSMat[4];
91  m_TurretController.GetCurrentSightsCameraTransform(sightWSMat, pOutResult.m_fFOV);
92 
93  PointInfo cameraSlot = turret.GetCameraAttachmentSlot();
94  if (cameraSlot)
95  {
96  m_bUseCameraSlot = true;
97 
98  pOutResult.m_CameraTM[3] = aimingTranslationWeaponLS;
99  pOutResult.m_iDirectBone = -1;
100  pOutResult.m_iDirectBoneMode = EDirectBoneMode.None;
101  pOutResult.m_bUpdateWhenBlendOut = false;
102  pOutResult.m_fDistance = 0;
103  pOutResult.m_fUseHeading = 0;
104  pOutResult.m_fNearPlane = 0.025;
105  pOutResult.m_bAllowInterpolation = true;
106  pOutResult.m_pWSAttachmentReference = cameraSlot;
107 
108  // Apply shake
109  if (m_CharacterCameraHandler)
110  m_CharacterCameraHandler.AddShakeToToTransform(pOutResult.m_CameraTM, pOutResult.m_fFOV);
111  return;
112  }
113 
114  // character matrix
115  vector charMat[4];
116  m_OwnerCharacter.GetTransform(charMat);
117 
118  //Add translation
119  vector aimingTranslationWeapon = aimingTranslationWeaponLS.Multiply3(sightWSMat);
120  sightWSMat[3] = sightWSMat[3] - aimingTranslationWeapon;
121 
122  Math3D.MatrixInvMultiply4(charMat, sightWSMat, pOutResult.m_CameraTM);
123 
124  pOutResult.m_iDirectBone = -1;
125  pOutResult.m_iDirectBoneMode = EDirectBoneMode.None;
126  pOutResult.m_bUpdateWhenBlendOut = false;
127  pOutResult.m_fDistance = 0;
128  pOutResult.m_fUseHeading = 0;
129  pOutResult.m_fNearPlane = 0.025;
130  pOutResult.m_bAllowInterpolation = true;
131  pOutResult.m_pOwner = m_OwnerCharacter;
132  pOutResult.m_pWSAttachmentReference = null;
133 
134  // Apply shake
135  if (m_CharacterCameraHandler)
136  m_CharacterCameraHandler.AddShakeToToTransform(pOutResult.m_CameraTM, pOutResult.m_fFOV);
137 
138  SCR_2DSightsComponent sights = SCR_2DSightsComponent.Cast(turret.GetSights());
139  if (sights)
140  {
141  SCR_SightsZoomFOVInfo fovInfo = SCR_SightsZoomFOVInfo.Cast(sights.GetFOVInfo());
142  if (fovInfo)
143  fovInfo.ForceUpdate(m_TurretController.GetOwner(), sights, pDt);
144  }
145  }
146 
147  //------------------------------------------------------------------------------------------------
148  override void OnAfterCameraUpdate(float pDt, bool pIsKeyframe, inout vector transformMS[4])
149  {
150  IEntity owner = m_OwnerVehicle;
151  if (m_TurretController)
152  owner = m_TurretController.GetOwner();
153 
154  if (m_bUseCameraSlot)
155  {
156  m_fPitchFactor = 0;
157  AddVehiclePitchRoll(owner, pDt, transformMS);
158  }
159  }
160 };
OnUpdate
override void OnUpdate(BaseWorld world, float timeslice)
Definition: game.c:910
m_WeaponManager
protected BaseWeaponManagerComponent m_WeaponManager
Definition: SCR_CharacterCommandHandler.c:120
CharacterCameraADS
Definition: CharacterCameraADSVehicle.c:4
SCR_SightsZoomFOVInfo
Definition: SCR_SightsZoomFOVInfo.c:6
m_CameraHandler
protected SCR_CharacterCameraHandlerComponent m_CameraHandler
Definition: SCR_InfoDisplayExtended.c:26
m_OwnerCharacter
private SCR_ChimeraCharacter m_OwnerCharacter
Definition: CharacterCameraHandlerComponent.c:984
OnAfterCameraUpdate
override void OnAfterCameraUpdate(float pDt, bool pIsKeyframe, inout vector transformMS[4], inout vector transformWS[4])
after camera update
Definition: CharacterCameraHandlerComponent.c:535
TurretControllerComponent
Definition: TurretControllerComponent.c:12
m_TurretController
protected TurretControllerComponent m_TurretController
Definition: SCR_2DSightsComponent.c:35
SCR_VehicleCameraDataComponent
Definition: SCR_VehicleCameraDataComponent.c:7