172 cameraData.m_vLookAngles[1] =
Math.Clamp(cameraData.m_vLookAngles[1] + parentPitch, CONST_UD_MIN, CONST_UD_MAX);
178 vector sightsRelativeMatrix[4];
179 Math3D.MatrixInvMultiply4(headMatrix, cameraData.m_mSightsLocalMat, sightsRelativeMatrix);
187 vector headPlane = cameraData.m_vSightsOffset;
188 headPlane[2] = headPlane[2] - recoilPortion;
191 Math3D.AnglesToMatrix(cameraData.m_vLookAngles, pOutResult.m_CameraTM);
194 vector resultPosition =
SCR_Math3D.IntersectPlane(sightsRelativeMatrix[3], -sightsRelativeMatrix[2], headPlane,
vector.Forward);
197 pOutResult.m_CameraTM[3] = resultPosition;
198 pOutResult.m_fFOV = cameraData.m_fFOV;
199 pOutResult.m_fDistance = 0;
200 pOutResult.m_fNearPlane = 0.0125;
201 pOutResult.m_bAllowInterpolation =
true;
202 pOutResult.m_bUpdateWhenBlendOut =
true;
212 float fUseHeading = 1.0;
233 muzzleType = currentWeapon.GetCurrentMuzzle().GetMuzzleType();
235 bUseProneADSMethod =
false;
238 if (
m_WeaponManager.GetCurrentWeapon().GetCurrentSightsZeroingTransform(zeroingLS))
239 Math3D.MatrixMultiply4(cameraData.m_mSightsLocalMat, zeroingLS, cameraData.m_mSightsLocalMat);
241 if (bUseProneADSMethod)
247 cameraData.m_mSightsLocalMat[0] = camUpMS * cameraData.m_mSightsLocalMat[2];
248 cameraData.m_mSightsLocalMat[1] = cameraData.m_mSightsLocalMat[2] * cameraData.m_mSightsLocalMat[0];
251 weaponType = currentWeapon.GetWeaponType();
256 Math3D.MatrixInvMultiply4(propBoneMS, cameraData.m_mSightsLocalMat, sightsMS);
258 float targetFOV = cameraData.m_fFOV;
275 m_LastMuzzleType = muzzleType;
304 m_LastMuzzleType = muzzleType;
314 Math3D.MatrixToQuat(sightsMS, qt);
315 Math3D.QuatLerp(qb, qb, qt, alpha);
316 Math3D.QuatToMatrix(qb, interpBuffer);
322 Math3D.MatrixCopy(interpBuffer, sightsMS);
338 Math3D.MatrixMultiply4(propBoneMS, sightsMS, sightsMS);
359 vector pureSightsFwd = sightsMS[2];
361 vector projectedPosMS =
SCR_Math3D.IntersectPlane(sightsMS[3], -sightsMS[2], cameraBoneMS[3], cameraBoneMS[2]);
362 vector projToSightMS = projectedPosMS - sightsMS[3];
363 vector projToSightsDirMS = projToSightMS.Normalized();
370 vector aimingTranslationMS;
371 for (
int i = 0; i < 3; i++)
373 aimingTranslationMS += aimingTranslationWeaponLS[i] * sightsMS[i];
381 vector extraTranslation = recoilPortion * sightsMS[2];
384 sightsMS[3] = sightsMS[3] - aimingTranslationMS - extraTranslation;
388 vector aimingAnglesMS = cameraData.m_vLookAngles;
389 aimingAnglesMS[1] = aimingAnglesMS[1] +
m_OwnerCharacter.GetLocalYawPitchRoll()[1];
394 aimingAnglesMS[0] = aimingAnglesMS[0] +
m_OwnerCharacter.GetAimRotationModel()[0] *
Math.RAD2DEG;
398 aimingAnglesMS[1] = aimingAnglesMS[1] -
m_OwnerCharacter.GetYawPitchRoll()[1];
399 aimingAnglesMS[2] = aimingAnglesMS[2] -
m_OwnerCharacter.GetYawPitchRoll()[2];
404 if (weaponType ==
EWeaponType.WT_HANDGUN && bUseProneADSMethod)
406 if (m_fPronePistolBlend < 1.0)
408 if (!
m_OwnerCharacter.GetCharacterController().IsWeaponRaised() || m_fPronePistolBlend > 0.0)
410 const float cameraVerticalOffset = 0.2;
411 m_fPronePistolBlend =
Math.Clamp(m_fPronePistolBlend + pDt*2, 0.0, 1.0);
412 sightsMS[3][1] =
Math.Lerp(cameraBoneMS[3][1] + cameraVerticalOffset, sightsMS[3][1], m_fPronePistolBlend);
418 Math3D.AnglesToMatrix(aimingAnglesMS, sightsMS);
420 const float alphaEpsilon = 0.0005;
422 vector resultPosition = sightsMS[3];
423 bool isUnstable =
false;
486 vector lookAimingDir = aimingAnglesMS.AnglesToVector();
487 float blendAlpha = 1.0 - (
vector.Dot(weaponAimingDir, lookAimingDir) + 1.0) * 0.5;
488 const float blendOutSpeed = 3.0;
490 if (cameraData.m_bFreeLook)
499 vector additiveRotation =
"0 0 0";
501 Math3D.MatrixMultiply4(cameraBoneMS, mat, mat);
502 vector goal = mat[3] +
"0 0.035 -0.045";
517 sightsMS[3] = resultPosition;
523 if (!shouldStabilize)
525 Math3D.MatrixInvMultiply4(propBoneMS, sightsMS, pOutResult.m_CameraTM);
533 pOutResult.m_CameraTM[3] = sightsMS[3];
534 Math3D.AnglesToMatrix(aimingAnglesMS, pOutResult.m_CameraTM);
536 m_OwnerCharacter.GetAnimation().GetBoneMatrix(pOutResult.m_iDirectBone, directTM);
537 Math3D.MatrixInvMultiply4(directTM, pOutResult.m_CameraTM, pOutResult.m_CameraTM);
541 pOutResult.m_fDistance = 0;
542 pOutResult.m_fNearPlane = 0.0125;
543 pOutResult.m_bAllowInterpolation = allowInterpolation;
544 pOutResult.m_fUseHeading = fUseHeading;
545 pOutResult.m_bUpdateWhenBlendOut =
true;
546 pOutResult.m_fPositionModelSpace = 0;
558 cameraData.m_vLookAngles[1] =
Math.Clamp(cameraData.m_vLookAngles[1] + parentPitch, CONST_UD_MIN, CONST_UD_MAX);
564 vector sightsRelativeMatrix[4];
565 Math3D.MatrixInvMultiply4(headMatrix, cameraData.m_mSightsLocalMat, sightsRelativeMatrix);
573 vector headPlane = cameraData.m_vSightsOffset;
574 headPlane[2] = headPlane[2] - recoilPortion;
577 vector resultPosition =
SCR_Math3D.IntersectPlane(sightsRelativeMatrix[3], -sightsRelativeMatrix[2], headPlane,
vector.Forward);
584 vector relativeSightsMatrix[4];
586 Math3D.MatrixInvMultiply4(handMatrix, cameraData.m_mSightsLocalMat, relativeSightsMatrix);
589 Math3D.AnglesToMatrix(cameraData.m_vLookAngles, pOutResult.m_CameraTM);
591 bool isUnstable =
false;
615 vector headRelativePosition =
"0 0 0";
616 resultPosition =
vector.Lerp(resultPosition, headRelativePosition, t);
619 if (!isUnstable && obstructedAlpha < 0.001)
625 resultPosition = resultPosition.Multiply4(headMatrix);
626 resultPosition = resultPosition.InvMultiply4(handMatrix);
629 pOutResult.m_CameraTM[3] = resultPosition;
630 pOutResult.m_fFOV = cameraData.m_fFOV;
631 pOutResult.m_fDistance = 0;
632 pOutResult.m_fNearPlane = 0.0125;
633 pOutResult.m_bAllowInterpolation = allowInterpolation;
634 pOutResult.m_bUpdateWhenBlendOut =
true;
637 pOutResult.m_fPositionModelSpace = 0.0;
651 if (sights2D && weapon && weapon.IsSightADSActive())
653 IEntity sightOwner = sights2D.GetOwner();
655 vector sightsOffset = sights2D.GetSightsFrontPosition(
true) + sightData.
GetCameraOffset() - sights2D.GetSightsOffset();
656 vector cameraOffset = sightsOffset.Multiply3(cameraData.m_mSightsLocalMat);
657 cameraData.m_mSightsLocalMat[3] = cameraData.m_mSightsLocalMat[3] + cameraOffset;
662 sights2D.GetSightsTransform(sightMat,
true);
666 Math3D.MatrixMultiply3(ownerMat, sightMat, sightMat);
671 Math3D.MatrixMultiply3(ownerMat, opticMat, opticMat);
675 Math3D.MatrixInvMultiply3(opticMat, sightMat, cameraMat);
677 cameraAngles =
Math3D.MatrixToAngles(cameraMat);
680 SCR_2DPIPSightsComponent sightsPIP = SCR_2DPIPSightsComponent.Cast(sights2D);
682 cameraData.m_fFOV = sightsPIP.GetMainCameraFOV();
685 pOutResult.m_fFOV =
Math.Min(GetBaseFOV(), cameraData.m_fFOV);
688 vector adjustedLookAngles = cameraData.m_vLookAngles;
698 adjustedLookAngles = aiming.GetAimingRotation();
702 vector offset = aiming.GetModifiedAimingTranslation() * pOutResult.m_fFOV;
703 adjustedLookAngles = adjustedLookAngles +
Vector(offset[1], offset[2], 0);
709 adjustedLookAngles = adjustedLookAngles - cameraAngles;
710 Math3D.AnglesToMatrix(adjustedLookAngles, lookRot);
717 Math3D.MatrixInvMultiply4(handBoneTM, cameraData.m_mSightsLocalMat, pOutResult.m_CameraTM);
718 vector finalPos = pOutResult.m_CameraTM[3];
721 if (bUseProneADSMethod)
727 lookRot[0] = camUpMS * lookRot[2];
728 lookRot[1] = lookRot[2] * lookRot[0];
731 m_fProneBlend =
Math.Clamp(m_fProneBlend + 3.0 * pDt, 0.0, 1.0);
733 vector adjustedLookAnglesProne =
Math3D.MatrixToAngles(lookRot);
734 adjustedLookAngles =
vector.Lerp(adjustedLookAngles, adjustedLookAnglesProne, m_fProneBlend);
735 Math3D.AnglesToMatrix(adjustedLookAngles, lookRot);
738 pOutResult.m_bInterpolateOrientation =
false;
739 if (m_fProneBlend < 1.0)
740 pOutResult.m_bInterpolateOrientation =
true;
745 Math3D.MatrixInvMultiply4(handBoneTM, lookRot, pOutResult.m_CameraTM);
748 pOutResult.m_CameraTM[3] = finalPos;
753 pOutResult.m_bUpdateWhenBlendOut =
true;
754 pOutResult.m_fDistance = 0;
755 pOutResult.m_fUseHeading = 0;
756 pOutResult.m_fNearPlane = 0.025;
757 pOutResult.m_bBlendFOV =
true;
773 bool canFreelook = sights && sights.CanFreelook();
797 m_pCameraData.m_fCamRecoilAmount = sights.GetCameraRecoilAmount();
813 if (currentWeapon.GetCurrentSightsZeroingTransform(zeroingMatrix))
816 zeroingMatrix[3] = -zeroingMatrix[3];
822 CameraBase overlayCamera;
826 SCR_2DPIPSightsComponent pip = SCR_2DPIPSightsComponent.Cast(sights);
835 pOutResult.m_pWSAttachmentReference = null;
841 overlayCamera = pip.GetPIPCamera();
855 if (solveMethod == 1)
857 else if (solveMethod == 2)
859 else if (solveMethod == 3)
867 CameraManager cameraMgr =
GetGame().GetCameraManager();
868 if (cameraMgr != null)
874 cameraMgr.SetOverlayCamera(null);
876 else if (overlayCamera)
879 cameraMgr.SetOverlayCamera(overlayCamera);
884 pOutResult.m_pWSAttachmentReference = null;
893 vector offset = pip.GetMainCameraOffset();
894 pOutResult.m_CameraTM[3] = pOutResult.m_CameraTM[3] - offset;