Arma Reforger Explorer  1.1.0.42
Arma Reforger Code Explorer by Zeroy - Thanks to MisterOutofTime
CharacterCamera1stPerson.c
Go to the documentation of this file.
1 // *************************************************************************************
2 // ! CharacterCamera1stPerson - 1st person camera
3 // *************************************************************************************
5 {
6  //-----------------------------------------------------------------------------
7  static const float CONST_UD_MIN = -89.0;
8  static const float CONST_UD_MAX = 89.0;
9 
10  static const float CONST_LR_MIN = -160.0;
11  static const float CONST_LR_MAX = 160.0;
12 
13  //-----------------------------------------------------------------------------
14  void CharacterCamera1stPerson(CameraHandlerComponent pCameraHandler)
15  {
16  m_pCompartmentAccess = m_OwnerCharacter.GetCompartmentAccessComponent();
17  // in head bone space
18  m_OffsetLS = "0.0 0.03 -0.07";
19  m_ApplyHeadBob = true;
20  }
21 
22  //-----------------------------------------------------------------------------
23  override void OnActivate(ScriptedCameraItem pPrevCamera, ScriptedCameraItemResult pPrevCameraResult)
24  {
25  super.OnActivate(pPrevCamera, pPrevCameraResult);
26  m_bCameraTransition = false;
27  }
28 
29  //-----------------------------------------------------------------------------
30  override void OnUpdate(float pDt, out ScriptedCameraItemResult pOutResult)
31  {
32  //Print("m_fLeftRightAngle : " + m_fLeftRightAngle);
33 
34  pOutResult.m_vBaseAngles = m_CharacterHeadAimingComponent.GetLookAngles();
35  pOutResult.m_fUseHeading = 1.0;
36  pOutResult.m_iDirectBoneMode = EDirectBoneMode.RelativePosition;
37  pOutResult.m_iDirectBone = GetCameraBoneIndex();
39  m_fFOV = GetBaseFOV();
40  if (m_bCameraTransition)
41  {
42  pOutResult.m_fUseHeading = 0.0;
43  pOutResult.m_iDirectBoneMode = EDirectBoneMode.RelativeTransform;
44 
45  // Currently the 1pv camera bone in getin/getout needs to be investigated,
46  // so as a workaround, we use head bone directly with position only
47  if (sm_iHeadBoneIndex != -1)
48  {
49  pOutResult.m_iDirectBone = sm_iHeadBoneIndex;
50  pOutResult.m_fUseHeading = 0.0;
51  pOutResult.m_iDirectBoneMode = EDirectBoneMode.RelativePosition;
52  }
53  }
54 
55  vector additiveRotation = "0 0 0";
56  m_CharacterHeadAimingComponent.GetLookTransformationLS(pOutResult.m_iDirectBone, pOutResult.m_iDirectBoneMode, m_OffsetLS, additiveRotation, pOutResult.m_CameraTM);
57 
58  if (m_UseLookPositionOverrideLS)
59  pOutResult.m_CameraTM[3] = m_LookPositionOverrideLS;
60 
61  vector vYPR = "0 0 0";
62  if (!m_bIgnoreCharacterPitch)
63  vYPR[1] = m_OwnerCharacter.GetLocalYawPitchRoll()[1];
64  vector mat[4];
65  Math3D.AnglesToMatrix(vYPR, mat);
66  Math3D.MatrixMultiply4(mat, pOutResult.m_CameraTM, pOutResult.m_CameraTM);
67 
68  if( m_ApplyHeadBob )
69  m_CharacterCameraHandler.AddViewBobToTransform(pOutResult.m_CameraTM, 1, false);
70 
71  pOutResult.m_fFOV = m_fFOV;
72  pOutResult.m_fNearPlane = 0.0125;
73  pOutResult.m_bUpdateWhenBlendOut = true;
74  pOutResult.m_fPositionModelSpace = 0.0;
75  pOutResult.m_bAllowInterpolation = true;
76  pOutResult.m_pOwner = m_OwnerCharacter;
77  pOutResult.m_pWSAttachmentReference = null;
78 
79  // Apply shake
80  if (m_CharacterCameraHandler)
81  m_CharacterCameraHandler.AddShakeToToTransform(pOutResult.m_CameraTM, pOutResult.m_fFOV);
82  }
83 
84  //-----------------------------------------------------------------------------
85  override float GetBaseFOV()
86  {
87  CameraManager cameraManager = GetGame().GetCameraManager();
88  if (!cameraManager)
89  return 0;
90 
91  return cameraManager.GetFirstPersonFOV();
92  }
93 
94  //-----------------------------------------------------------------------------
95  protected vector m_OffsetLS;
96 
97  protected bool m_ApplyHeadBob;
98 
99  protected bool m_bCameraTransition = false;
100  protected CompartmentAccessComponent m_pCompartmentAccess;
101 
102  protected bool m_UseLookPositionOverrideLS = false;
103  protected vector m_LookPositionOverrideLS;
104 };
105 
106 class CharacterCamera1stPersonBoneTransform extends CharacterCamera1stPerson
107 {
108  override void OnUpdate(float pDt, out ScriptedCameraItemResult pOutResult)
109  {
110  super.OnUpdate(pDt, pOutResult);
111  pOutResult.m_fUseHeading = 0.0;
112  pOutResult.m_iDirectBoneMode = EDirectBoneMode.RelativeTransform;
113  vector additiveRotation = "0 0 0";
114  m_CharacterHeadAimingComponent.GetLookTransformationLS(pOutResult.m_iDirectBone, pOutResult.m_iDirectBoneMode, m_OffsetLS, additiveRotation, pOutResult.m_CameraTM);
115  }
116 }
GetGame
ArmaReforgerScripted GetGame()
Definition: game.c:1424
OnUpdate
override void OnUpdate(BaseWorld world, float timeslice)
Definition: game.c:910
CharacterCameraBase
Definition: CharacterCameraADS.c:4
m_OwnerCharacter
private SCR_ChimeraCharacter m_OwnerCharacter
Definition: CharacterCameraHandlerComponent.c:984
CharacterCamera1stPerson
Definition: CharacterCamera1stPerson.c:106