7 [
Attribute(
"0.01", UIWidgets.Slider,
params:
"0.001 1.0 0.001", precision: 3,
category:
"Camera Shake",
desc:
"Time rate of shake blending in.")]
9 [
Attribute(
"0.175", UIWidgets.Slider,
params:
"0.001 1.0 0.001", precision: 3,
category:
"Camera Shake",
desc:
"Time rate of shake blending out.")]
10 float m_fBlendOutTime;
11 [
Attribute(
"15.0", UIWidgets.Slider,
params:
"0.0 60.0 0.001", precision: 3,
category:
"Camera Shake",
desc:
"Maximum smoothing velocity.")]
17 [
Attribute(
"0.0375", UIWidgets.Slider,
params:
"0.0 1.0 0.001", precision: 3,
category:
"Camera Shake",
desc:
"Distance of translation at which recoil is deemed at maximum scale.")]
18 float m_fRecoilTarget;
19 [
Attribute(
"1.25", UIWidgets.Slider,
params:
"0.0 3.0 0.001", precision: 3,
category:
"Camera Shake",
desc:
"Maximum percentage of recoil applied based on current vs target recoil translation.")]
20 float m_fMaximumPercentage;
28 [
Attribute(
"0.0005 0.00050.0", UIWidgets.EditBox, precision: 3,
category:
"Camera Shake",
desc:
"Minimum range to pick translation values from. +right +up +forward in meters.")]
29 protected vector m_vTranslationMin;
35 [
Attribute(
"0.006 0.006 0.0", UIWidgets.EditBox, precision: 3,
category:
"Camera Shake",
desc:
"Maximum range to pick translation values from. +right +up +forward in meters.")]
36 protected vector m_vTranslationMax;
41 [
Attribute(
"0.975", UIWidgets.EditBox, precision: 3,
category:
"Camera Shake",
desc:
"Percentage of field of view when shake is at peak value.")]
42 protected float m_fFOVModifier;
49 [
Attribute(
"0.005 0.005 1.0", UIWidgets.EditBox, precision: 3,
category:
"Camera Shake",
desc:
"On top of the continuous shake there is an impulse which is stronger and has single direction for the entirety or most of the underlying shake duration. This value defines the minimum rotation range of this impulse. +pitch +yaw +roll in in degrees.")]
50 protected vector m_vRotationImpulseMin;
57 [
Attribute(
"0.012 0.012 1.5", UIWidgets.EditBox, precision: 3,
category:
"Camera Shake",
desc:
"On top of the continuous shake there is an impulse which is stronger and has single direction for the entirety or most of the underlying shake duration. This value defines the maximum rotation range of this impulse. +pitch +yaw +roll in degrees.")]
58 protected vector m_vRotationImpulseMax;
63 [
Attribute(
"0.04", UIWidgets.EditBox, precision: 3,
category:
"Camera Shake",
desc:
"The minimum recoil delta that can trigger impulses.")]
64 float m_fMinImpulseThreshold;
69 [
Attribute(
"0.333", UIWidgets.EditBox, precision: 3,
category:
"Camera Shake",
desc:
"The minimum rate at which impulses can be added. (0.1 == up to 0.1 impulses per second, 1.0 == up to 1 impulses per second.")]
70 float m_fMinImpulseRate;
75 [
Attribute(
"0.8", UIWidgets.EditBox, precision: 3,
category:
"Camera Shake",
desc:
"Impulse magnitude multiplier for when character is crouching.",
params:
"0 1 0.01")]
76 float m_fImpulseCrouchMagnitudeModifier;
81 [
Attribute(
"0.6", UIWidgets.EditBox, precision: 3,
category:
"Camera Shake",
desc:
"Impulse magnitude multiplier for when character is crouching.",
params:
"0 1 0.01")]
82 float m_fImpulseProneMagnitudeModifier;
87 [
Attribute(
"0.8", UIWidgets.EditBox, precision: 3,
category:
"Camera Shake",
desc:
"Continuous magnitude multiplier for when character is crouching.",
params:
"0 1 0.01")]
88 float m_fCrouchMagnitudeModifier;
93 [
Attribute(
"0.6", UIWidgets.EditBox, precision: 3,
category:
"Camera Shake",
desc:
"Continuous magnitude multiplier for when character is crouching.",
params:
"0 1 0.01")]
94 float m_fProneMagnitudeModifier;
99 protected ref RandomGenerator m_pRandomGenerator =
new RandomGenerator();
105 float GetStanceImpulseMagnitude(
float dynamicStance)
107 return GetMagnitude(dynamicStance, m_fImpulseCrouchMagnitudeModifier, m_fImpulseProneMagnitudeModifier, 1.0);
114 float GetStanceMagnitude(
float dynamicStance)
116 return GetMagnitude(dynamicStance, m_fCrouchMagnitudeModifier, m_fProneMagnitudeModifier, 1.0);
119 protected float GetMagnitude(
float stance,
float crouch,
float prone,
float erect)
124 float t = (stance * 2) - 1.0;
125 return Math.Lerp(crouch, erect, t);
129 float t = (stance * 2);
130 return Math.Lerp(prone, crouch, t);
136 protected float RandomFloat(
float min,
float max)
138 if (min < 0.00001 || max < 0.00001)
148 protected vector RandomVector(vector min, vector max)
151 result[0] = RandomFloat(min[0], max[0]);
152 result[1] = RandomFloat(min[1], max[1]);
153 result[2] = RandomFloat(min[2], max[2]);
160 protected vector RandomVectorSphere(vector min, vector max,
bool uniform =
true)
163 vector res =
m_pRandomGenerator.GenerateRandomPointInRadius(min.Length(), max.Length(), vector.Zero, uniform);
164 res[0] = Math.Clamp(res[0], min[0], max[0]);
165 res[1] = Math.Clamp(res[1], min[1], max[1]);
166 res[2] = Math.Clamp(res[2], min[2], max[2]);
173 float GetFovScale(
float progress01)
175 progress01 = Math.Clamp(progress01, 0.0, 1.0);
176 return Math.Lerp(1.0, m_fFOVModifier, progress01);
182 vector GetRandomTranslation(
bool onSphere =
false)
185 return RandomVectorSphere(m_vTranslationMin, m_vTranslationMax);
187 return RandomVector(m_vTranslationMin, m_vTranslationMax);
193 vector GetRandomAnglesImpulse(
bool onSphere =
false)
196 return RandomVectorSphere(m_vRotationImpulseMin, m_vRotationImpulseMax);
198 return RandomVector(m_vRotationImpulseMin, m_vRotationImpulseMax);
204 vector GetRandomYawPitchRollImpulse(
bool onSphere =
false)
206 vector angles = GetRandomAnglesImpulse(onSphere);
207 return Vector(angles[1], angles[0], angles[2]);