Arma Reforger Explorer 1.7.0.54
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
Loading...
Searching...
No Matches
CharacterCameraBase.c
Go to the documentation of this file.
1class CharacterCameraBase : ScriptedCameraItem
2{
3 //------------------------------------------------------------------------------------------------
5 void CharacterCameraBase(CameraHandlerComponent pCameraHandler)
6 {
9 m_fFOV = GetBaseFOV();
10
11 m_CharacterCameraHandler = SCR_CharacterCameraHandlerComponent.Cast(m_CameraHandler);
12 m_OwnerCharacter = ChimeraCharacter.Cast(pCameraHandler.GetOwner());
14 m_Input = m_ControllerComponent.GetInputContext();
15 if (sm_TagFPCamera == -1)
16 {
17 sm_TagFPCamera = GameAnimationUtils.RegisterAnimationTag("TagFPCamera");
18 }
19 if (sm_TagADSTransitionIn == -1)
20 {
21 sm_TagADSTransitionIn = GameAnimationUtils.RegisterAnimationTag("TagTransitionADSIn");
22 }
23 if (sm_TagADSTransitionOut == -1)
24 {
25 sm_TagADSTransitionOut = GameAnimationUtils.RegisterAnimationTag("TagTransitionADSOut");
26 }
27 if (sm_TagLyingCamera == -1)
28 {
29 sm_TagLyingCamera = GameAnimationUtils.RegisterAnimationTag("TagLyingCamera");
30 }
31 if (sm_TagItemUpdateCols == -1)
32 {
33 sm_TagItemUpdateCols = GameAnimationUtils.RegisterAnimationTag("TagItemUpdateColliders");
34 }
35 if (sm_iCameraBoneIndex == -1)
36 {
37 Animation anim = m_OwnerCharacter.GetAnimation();
38 sm_iHeadBoneIndex = anim.GetBoneIndex("Head");
39 sm_iCameraBoneIndex = anim.GetBoneIndex("Camera");
40 s_iNeckBoneIndex = anim.GetBoneIndex("Neck1");
41 }
44 m_CharacterHeadAimingComponent = CharacterHeadAimingComponent.Cast(m_OwnerCharacter.FindComponent(CharacterHeadAimingComponent));
45 m_CommandWeapons = cmdHandler.GetCommandModifier_Weapon();
46 m_CompartmentAccessComponent = m_OwnerCharacter.GetCompartmentAccessComponent();
47 m_CmdHandler = cmdHandler;
48 }
49
50 //------------------------------------------------------------------------------------------------
51 float UpdateUDAngle(out float pAngle, float pMin, float pMax, float pDt)
52 {
53 pAngle = Math.Clamp(m_CharacterHeadAimingComponent.GetAimingRotation()[1], pMin, pMax);
54
55 //On Foot
57 pAngle += m_ControllerComponent.GetInputContext().GetAimingAngles()[1];
58
59 return pAngle;
60 }
61
62 //------------------------------------------------------------------------------------------------
63 float UpdateLRAngle(float pAngle, float pMin, float pMax, float pDt)
64 {
65 bool bCompartmentForcesFreeLook = false;
67 bCompartmentForcesFreeLook = m_CompartmentAccessComponent.GetCompartment().GetForceFreeLook();
68
70 if (m_ControllerComponent.IsFreeLookEnabled() || m_ControllerComponent.IsTrackIREnabled() || m_bForceFreeLook || bCompartmentForcesFreeLook)
71 {
72 pAngle = m_CharacterHeadAimingComponent.GetAimingRotation()[0];
73
75 {
76 pAngle = Math.Clamp(pAngle, pMin, pMax);
77 }
78 else
79 {
80 pAngle = SCR_Math.FixAngle(pAngle, 180);
81 }
82
83 m_fLRAngleVel = 0; // reset filter
84 }
85 else
86 {
87 pAngle = Math.SmoothCD(pAngle, 0, m_fLRAngleVel, 0.14, 1000, pDt);
88 }
89
90 return pAngle;
91 }
92
93 //------------------------------------------------------------------------------------------------
94 override void OnUpdate(float pDt, out ScriptedCameraItemResult pOutResult);
95
96 //------------------------------------------------------------------------------------------------
97 override void OnActivate(ScriptedCameraItem pPrevCamera, ScriptedCameraItemResult pPrevCameraResult)
98 {
99 // Save shoulder state if camera was 3rd person or pass on last state
100 if (pPrevCamera)
101 {
102 if ( pPrevCamera.IsInherited(CharacterCamera3rdPersonBase) )
103 {
104 m_fShoulderLastActive = CharacterCamera3rdPersonBase.Cast(pPrevCamera).GetActiveShoulder();
105 }
106 else if ( pPrevCamera.IsInherited(CharacterCameraBase) )
107 {
108 m_fShoulderLastActive = CharacterCameraBase.Cast(pPrevCamera).GetShoulderLastActive();
109 }
110 }
111 if (IsInherited(CharacterCamera3rdPersonBase) || IsInherited(CharacterCamera3rdPersonVehicle))
112 {
113 m_CameraHandler.SetLensFlareSet(CameraLensFlareSetType.ThirdPerson, "");
114 }
115 else
116 {
117 m_CameraHandler.SetLensFlareSet(CameraLensFlareSetType.FirstPerson, "");
118 }
119
120 CharacterCameraBase prevCameraBase = CharacterCameraBase.Cast(pPrevCamera);
121 if (prevCameraBase)
122 {
123 m_fPitchSmooth = prevCameraBase.m_fPitchSmooth;
124 m_fPitchSmoothVel = prevCameraBase.m_fPitchSmoothVel;
125 m_fRollSmooth = prevCameraBase.m_fRollSmooth;
126 m_fRollSmoothVel = prevCameraBase.m_fRollSmoothVel;
127 }
128
129 m_CharacterHeadAimingComponent.SetPitchLimitReductionMultiplier(1.0);
130 m_CharacterHeadAimingComponent.ResetLimitAnglesOverride();
131 }
132
133 //------------------------------------------------------------------------------------------------
134 void ForceFreelook(bool state)
135 {
136 m_bForceFreeLook = state;
137 }
138
139 //-----------------------------------------------------------------------------
142 int GetShoulderLastActive()
143 {
145 }
146
147 //------------------------------------------------------------------------------------------------
150 float GetShoulderDistance()
151 {
152 return 0.0;
153 }
154
155 //------------------------------------------------------------------------------------------------
158 float GetInterpolatedUDTransformAngle(float pDt)
159 {
160 vector physTransform[4];
161 m_OwnerCharacter.GetLocalTransform(physTransform);
162 m_fTransformUDAngle = Math.SmoothCD(m_fTransformUDAngle, physTransform[2][1], m_fTransformUDAngleVel, 0.14, 1000, pDt);
163 return m_fTransformUDAngle * Math.RAD2DEG;
164 }
165
166 //------------------------------------------------------------------------------------------------
172 void AddPitchRoll(vector yawPitchRoll, float pitchFactor, float rollFactor, inout vector transformMS[4])
173 {
174 // Get camera forward, without height
175 vector cameraForward = transformMS[2];
176 cameraForward[1] = 0.0;
177 cameraForward.Normalize();
178
179 // Get camera right, without height
180 vector cameraAside = transformMS[0];
181 cameraAside[1] = 0;
182 cameraAside.Normalize();
183
184 // See how much of individual components to apply
185 float rollAmount = vector.Dot(cameraForward, vector.Forward);
186 float pitchAmount = vector.Dot(cameraAside, vector.Forward);
187
188 float pitch = yawPitchRoll[1];
189 float roll = yawPitchRoll[2];
190
191 float newPitch = pitchFactor * (pitch * rollAmount - roll * pitchAmount);
192 float newRoll = rollFactor * (roll * rollAmount - pitch * pitchAmount);
193
194 // Create rotation matrix
195 vector newPitchRoll = Vector(0, newPitch, newRoll);
196 vector rotMat[3];
197 Math3D.AnglesToMatrix(newPitchRoll, rotMat);
198
199 // Apply matrix to final transformation
200 Math3D.MatrixMultiply3(transformMS, rotMat, transformMS);
201 }
202
203 //------------------------------------------------------------------------------------------------
204 protected void AddVehiclePitchRoll(IEntity vehicle, float pDt, inout vector transformMS[4])
205 {
206 if (!vehicle)
207 return;
208
209 vector vehMat[4];
210 vehicle.GetTransform(vehMat);
211
212 // Compensate for roll after camera is updated
213 vector yawPitchRoll = Math3D.MatrixToAngles(vehMat);
214 m_fPitchSmooth = Math.SmoothCD(m_fPitchSmooth, -yawPitchRoll[1], m_fPitchSmoothVel, 0.14, 1000, pDt);
215 m_fRollSmooth = Math.SmoothCD(m_fRollSmooth, -yawPitchRoll[2], m_fRollSmoothVel, 0.14, 1000, pDt);
216 yawPitchRoll[0] = 0;
217 yawPitchRoll[1] = m_fPitchSmooth;
218 yawPitchRoll[2] = m_fRollSmooth;
219
220 float rollMask = Math.Max(0, vehMat[1][1]); // Do not apply roll factor when the vehicle is upside-down.
221 AddPitchRoll(yawPitchRoll, m_fPitchFactor, rollMask * m_fRollFactor, transformMS);
222 }
223
225 protected float m_fUpDownAngle;
226 protected float m_fUpDownAngleAdd;
227 protected float m_fLeftRightAngle = 0.0;
228
229 //-----------------------------------------------------------------------------
230 override void SetBaseAngles(out vector angles)
231 {
234 }
235
236 //-----------------------------------------------------------------------------
238 {
239 return m_CharacterHeadAimingComponent.GetLookAngles();
240 }
241
242 //------------------------------------------------------------------------------------------------
247 {
249 {
250 return sm_iCameraBoneIndex;
251 }
252 return sm_iHeadBoneIndex;
253 }
254
255 protected float m_fFOV;
256
257 protected float m_fLRAngleVel;
258 protected float m_fUDAngleVel;
259 protected float m_fTransformUDAngleVel;
260 protected float m_fTransformUDAngle;
261 protected bool m_bForceFreeLook;
262 protected bool m_bLRAngleNoLimit;
263
265
266 protected float m_fFOVFilter;
267 protected float m_fFOVFilterVel;
268
269 protected int m_fShoulderLastActive = 1;
270
271 protected float m_fRollFactor;
272 protected float m_fRollSmooth;
273 protected float m_fRollSmoothVel;
274 protected float m_fPitchFactor;
275 protected float m_fPitchSmooth;
276 protected float m_fPitchSmoothVel;
277
281 protected SCR_CharacterCameraHandlerComponent m_CharacterCameraHandler;
283 protected CharacterHeadAimingComponent m_CharacterHeadAimingComponent;
285 protected CompartmentAccessComponent m_CompartmentAccessComponent;
287 protected float m_fShakeProgress;
288 protected float m_fShakeVelocity;
289 protected static TNodeId sm_iCameraBoneIndex = -1;
290 protected static TNodeId sm_iHeadBoneIndex = -1;
291 protected static TNodeId s_iNeckBoneIndex = -1;
292 protected static AnimationTagID sm_TagFPCamera = -1;
293 protected static AnimationTagID sm_TagLyingCamera = -1; // beware: very deceitful!
294 protected static AnimationTagID sm_TagItemUpdateCols = -1; // beware: very deceitful!
297}
int AnimationTagID
ref array< string > angles
override void OnActivate()
override void OnUpdate()
proto native external bool IsInherited(typename type)
static AnimationTagID sm_TagADSTransitionIn
static AnimationTagID sm_TagFPCamera
float m_fUpDownAngleAdd
up down angle in rad
float m_fUpDownAngle
runtime values
CharacterCommandWeapon m_CommandWeapons
int m_fShoulderLastActive
saved active shoulder for 3rd person cam (1 - right, -1 left)
SCR_CharacterControllerComponent m_ControllerComponent
float m_fLeftRightAngle
left right angle in rad
CharacterInputContext m_Input
static TNodeId sm_iHeadBoneIndex
CharacterAnimationComponent m_CharacterAnimationComponent
static TNodeId s_iNeckBoneIndex
CompartmentAccessComponent m_CompartmentAccessComponent
CharacterHeadAimingComponent m_CharacterHeadAimingComponent
override void SetBaseAngles(out vector angles)
void CharacterCamera3rdPersonVehicle(CameraHandlerComponent pCameraHandler)
ChimeraCharacter m_OwnerCharacter
static AnimationTagID sm_TagItemUpdateCols
SCR_CharacterCameraHandlerComponent m_CharacterCameraHandler
CharacterCommandHandlerComponent m_CmdHandler
override vector GetBaseAngles()
static AnimationTagID sm_TagLyingCamera
static AnimationTagID sm_TagADSTransitionOut
static TNodeId sm_iCameraBoneIndex
void AddVehiclePitchRoll(IEntity vehicle, float pDt, inout vector transformMS[4])
proto external void GetTransform(out vector mat[])
Definition Math.c:13
static float FixAngle(float angle, float units=Math.PI)
Definition SCR_Math.c:280
proto external GenericEntity GetOwner()
Get owner entity.
CameraHandlerComponent m_CameraHandler
data
int TNodeId
Node global id is a hash of name of the node.
Definition EnEntity.c:18
proto native vector Vector(float x, float y, float z)
CameraLensFlareSetType
Type of the camera lens flare set.