3 using Microsoft.Xna.Framework;
20 private float bendRight;
23 get {
return bendRight; }
24 set { bendRight = MathHelper.Clamp(value, -MaxRotationInRadians, MaxRotationInRadians); }
29 private float bendLeft;
32 get {
return bendLeft; }
33 set { bendLeft = MathHelper.Clamp(value, -MaxRotationInRadians, MaxRotationInRadians); }
40 get {
return bendUp; }
41 set { bendUp = MathHelper.Clamp(value, -MaxRotationInRadians, MaxRotationInRadians); }
45 private float bendDown;
48 get {
return bendDown; }
49 set { bendDown = MathHelper.Clamp(value, -MaxRotationInRadians, MaxRotationInRadians); }
53 public Vector2
Scale = Vector2.Zero;
59 protected override void GetDeformation(out Vector2[,] deformation, out
float multiplier,
bool inverse)
65 public override void Update(
float deltaTime)
67 Vector2 normalizedPos = Vector2.Zero;
70 normalizedPos.X = x / (float)(
Resolution.X - 1);
73 normalizedPos.Y = y / (float)(
Resolution.Y - 1);
78 float strength = 1.0f - normalizedPos.X;
79 strength = (strength - 0.5f) * 2.0f;
83 Vector2 offset = rotatedP - normalizedPos;
90 float strength = normalizedPos.X;
91 strength = (strength - 0.5f) * 2.0f;
95 Vector2 offset = rotatedP - normalizedPos;
101 if (Math.Abs(
BendUp) > 0.001f)
103 float strength = 1.0f - normalizedPos.Y;
104 strength = (strength - 0.5f) * 2.0f;
108 Vector2 offset = rotatedP - normalizedPos;
115 float strength = normalizedPos.Y;
116 strength = (strength - 0.5f) * 2.0f;
120 Vector2 offset = rotatedP - normalizedPos;
136 Vector2 dir = point - target;
137 var x = (cos * dir.X) - (sin * dir.Y) + target.X;
138 var y = (sin * dir.X) + (cos * dir.Y) + target.Y;
139 return new Vector2(x, y);