7 static const float CONST_UD_MIN = -89.0;
8 static const float CONST_UD_MAX = 89.0;
10 static const float CONST_LR_MIN = -160.0;
11 static const float CONST_LR_MAX = 160.0;
20 override void OnActivate(ScriptedCameraItem pPrevCamera, ScriptedCameraItemResult pPrevCameraResult)
22 super.OnActivate(pPrevCamera, pPrevCameraResult);
26 m_fShoulderLRPrefered = GetShoulderLastActive();
28 m_fFOVFilter = pPrevCameraResult.m_fFOV;
32 override void OnUpdate(
float pDt, out ScriptedCameraItemResult pOutResult)
34 pOutResult.m_vBaseAngles = GetBaseAngles();
37 m_fFOV = GetBaseFOV();
40 vector lookAngles = m_CharacterHeadAimingComponent.GetLookAngles();
42 if (!m_bIgnoreCharacterPitch)
46 Math3D.AnglesToMatrix(lookAngles, pOutResult.m_CameraTM);
49 if (m_iBoneIndex != -1)
53 pOutResult.m_CameraTM[3] = boneMatrix[3];
57 pOutResult.m_CameraTM[3] =
"0 0 0";
63 m_fShoulderLRPrefered = -1;
64 else if( leaning > 0.1 )
65 m_fShoulderLRPrefered = 1;
67 m_fShoulderLROffset = Math.SmoothCD(m_fShoulderLROffset, m_fShoulderLRPrefered, m_fCameraLRShoulderVel, 0.14, 1000, pDt);
70 float shoulderDist = GetShoulderDistance();
73 vector msOffset = m_CameraOffsetMS;
74 vector lsOffset = m_CameraOffsetLS;
77 lsOffset[0] = lsOffset[0] + shoulderDist;
81 msOffset[0] = msOffset[0] + shoulderDist;
90 velocity = velocity.InvMultiply3(charMat);
91 for (
int i = 0; i < 3; i++)
93 velocity[i] = Math.Clamp(velocity[i], -m_vMaxVelocity[i], m_vMaxVelocity[i]);
95 m_v3rd_VelocityAdd += (velocity - m_v3rd_VelocityAdd) * pDt * 2;
97 msOffset = msOffset + m_v3rd_VelocityAdd * -0.05;
99 pOutResult.m_CameraTM[3] = pOutResult.m_CameraTM[3] + pOutResult.m_CameraTM[0] * lsOffset[0] + pOutResult.m_CameraTM[1] * lsOffset[1] + pOutResult.m_CameraTM[2] * lsOffset[2] + msOffset;
101 float currY = pOutResult.m_CameraTM[3][1];
102 if (m_fYoffsetPrevFrame == 0)
104 m_fYoffsetPrevFrame = currY;
106 m_fYoffsetPrevFrame = Math.Lerp(m_fYoffsetPrevFrame, currY, 0.01);
108 if (m_fYoffsetPrevFrame != 0)
110 yDelta = Math.Pow(currY/m_fYoffsetPrevFrame, 2);
113 pOutResult.m_CameraTM[3][1] = m_fYoffsetPrevFrame * yDelta;
115 m_fBobScale = m_CharacterCameraHandler.AddViewBobToTransform(pOutResult.m_CameraTM, 1,
true);
119 pOutResult.m_iDirectBoneMode = EDirectBoneMode.None;
120 pOutResult.m_fUseHeading = 1.0;
121 pOutResult.m_fShoulderDist = m_fShoulderLROffset;
122 pOutResult.m_fNearPlane = 0.04;
123 pOutResult.m_fPositionModelSpace = 1.0;
124 pOutResult.m_pWSAttachmentReference =
null;
127 m_fFOVFilter = Math.SmoothCD(m_fFOVFilter, pOutResult.m_fFOV, m_fFOVFilterVel, 0.2, 1000, pDt);
128 pOutResult.m_fFOV = m_fFOVFilter;
132 override float GetBaseFOV()
134 CameraManager cameraManager =
GetGame().GetCameraManager();
138 return cameraManager.GetThirdPersonFOV();
144 int GetActiveShoulder()
146 return m_fShoulderLRPrefered;
150 override float GetShoulderDistance()
152 return m_fShoulderLROffset * m_fShoulderWidth + m_fLeanDistance * m_fLeaningOffset;
156 protected int m_iBoneIndex = -1;
157 protected vector m_CameraOffsetMS;
158 protected vector m_CameraOffsetLS;
160 protected float m_fShoulderWidth;
161 protected bool m_bShoulderInLS;
162 protected float m_fLeanDistance;
163 protected vector m_vMaxVelocity =
"2 2 2";
165 protected float m_fBobScale;
167 protected int m_fShoulderLRPrefered = 1;
168 protected float m_fShoulderLROffset;
169 protected float m_fLeaningOffset;
170 protected float m_fCameraLRShoulderVel;
171 protected float m_fLeaningOffsetVel;
172 protected vector m_v3rd_VelocityAdd = vector.Zero;
173 protected float m_fYoffsetPrevFrame = 0.0;