Esempio n. 1
0
 public static FP Distance(FP value1, FP value2)
 {
     return(FP.Abs(value1 - value2));
 }
Esempio n. 2
0
 /**
  *  @brief Rotates game object based on provided axis and angle of rotation.
  **/
 public void RotateAround(TSVector axis, FP angle)
 {
     Rotate(axis, angle);
 }
Esempio n. 3
0
 /**
  *  @brief Rotates game object based on provided axis angles of rotation and a relative space.
  *
  *  If relative space is SELF then the game object will rotate based on its forward vector.
  **/
 public void Rotate(FP xAngle, FP yAngle, FP zAngle, Space relativeTo)
 {
     Rotate(new TSVector(xAngle, yAngle, zAngle), relativeTo);
 }
Esempio n. 4
0
 public void Negate()
 {
     this.x = -this.x;
     this.y = -this.y;
     this.z = -this.z;
 }
Esempio n. 5
0
 /**
  *  @brief Moves game object based on provided axis values and a relative space.
  *
  *  If relative space is SELF then the game object will move based on its forward vector.
  **/
 public void Translate(FP x, FP y, FP z, Space relativeTo)
 {
     Translate(new TSVector(x, y, z), relativeTo);
 }
Esempio n. 6
0
 public static TSVector3 Lerp(TSVector3 from, TSVector3 to, FP percent)
 {
     return(from + (to - from) * percent);
 }
Esempio n. 7
0
 public void MakeZero()
 {
     x = FP.Zero;
     y = FP.Zero;
     z = FP.Zero;
 }
Esempio n. 8
0
        public static FP SmoothDamp(FP current, FP target, ref FP currentVelocity, FP smoothTime, FP maxSpeed, FP deltaTime)
        {
            smoothTime = Max(FP.EN4, smoothTime);
            FP num  = (FP)2f / smoothTime;
            FP num2 = num * deltaTime;
            FP num3 = FP.One / (((FP.One + num2) + (((FP)0.48f * num2) * num2)) + ((((FP)0.235f * num2) * num2) * num2));
            FP num4 = current - target;
            FP num5 = target;
            FP max  = maxSpeed * smoothTime;

            num4   = Clamp(num4, -max, max);
            target = current - num4;
            FP num7 = (currentVelocity + (num * num4)) * deltaTime;

            currentVelocity = (currentVelocity - (num * num7)) * num3;
            FP num8 = target + ((num4 + num7) * num3);

            if (((num5 - current) > FP.Zero) == (num8 > num5))
            {
                num8            = num5;
                currentVelocity = (num8 - num5) / deltaTime;
            }
            return(num8);
        }
Esempio n. 9
0
 /// <summary>
 /// Gets the square root.
 /// </summary>
 /// <param name="number">The number to get the square root from.</param>
 /// <returns></returns>
 #region public static FP Sqrt(FP number)
 public static FP Sqrt(FP number)
 {
     return(FP.Sqrt(number));
 }
Esempio n. 10
0
 public static FP MoveTowardsAngle(FP current, FP target, float maxDelta)
 {
     target = current + DeltaAngle(current, target);
     return(MoveTowards(current, target, maxDelta));
 }
Esempio n. 11
0
        public static FP SmoothDamp(FP current, FP target, ref FP currentVelocity, FP smoothTime, FP maxSpeed)
        {
            FP deltaTime = FP.EN2;

            return(SmoothDamp(current, target, ref currentVelocity, smoothTime, maxSpeed, deltaTime));
        }
Esempio n. 12
0
 public static FP Repeat(FP t, FP length)
 {
     return(t - (Floor(t / length) * length));
 }
Esempio n. 13
0
 /// <summary>
 /// Returns the natural logarithm of a specified number.
 /// Provides at least 7 decimals of accuracy.
 /// </summary>
 /// <exception cref="ArgumentOutOfRangeException">
 /// The argument was non-positive
 /// </exception>
 public static FP Ln(FP x)
 {
     return(FP.FastMul(Log2(x), FP.Ln2));
 }
Esempio n. 14
0
 public static FP Lerp(FP value1, FP value2, FP amount)
 {
     return(value1 + (value2 - value1) * Clamp01(amount));
 }
Esempio n. 15
0
 public void Set(FP x, FP y, FP z)
 {
     this.x = x;
     this.y = y;
     this.z = z;
 }
Esempio n. 16
0
 /// <summary>
 /// Gets the maximum number of two values.
 /// </summary>
 /// <param name="val1">The first value.</param>
 /// <param name="val2">The second value.</param>
 /// <returns>Returns the largest value.</returns>
 #region public static FP Max(FP val1, FP val2)
 public static FP Max(FP val1, FP val2)
 {
     return((val1 > val2) ? val1 : val2);
 }
Esempio n. 17
0
 public TSVector3(FP xyz)
 {
     this.x = xyz;
     this.y = xyz;
     this.z = xyz;
 }
Esempio n. 18
0
 /// <summary>
 /// Gets the minimum number of two values.
 /// </summary>
 /// <param name="val1">The first value.</param>
 /// <param name="val2">The second value.</param>
 /// <returns>Returns the smallest value.</returns>
 #region public static FP Min(FP val1, FP val2)
 public static FP Min(FP val1, FP val2)
 {
     return((val1 < val2) ? val1 : val2);
 }
Esempio n. 19
0
 public static FP Distance2D(TSVector3 v1, TSVector3 v2)
 {
     return(FP.Sqrt((v1.x - v2.x) * (v1.x - v2.x) + (v1.z - v2.z) * (v1.z - v2.z)));
 }
Esempio n. 20
0
 public static void Multiply(ref TSVector3 value1, FP scaleFactor, out TSVector3 result)
 {
     result.x = value1.x * scaleFactor;
     result.y = value1.y * scaleFactor;
     result.z = value1.z * scaleFactor;
 }
Esempio n. 21
0
 public static void Divide(ref TSVector3 value1, FP scaleFactor, out TSVector3 result)
 {
     result.x = value1.x / scaleFactor;
     result.y = value1.y / scaleFactor;
     result.z = value1.z / scaleFactor;
 }
Esempio n. 22
0
 public static TSVector3 Abs(TSVector3 other)
 {
     return(new TSVector3(FP.Abs(other.x), FP.Abs(other.y), FP.Abs(other.z)));
 }
Esempio n. 23
0
 /**
  *  @brief Moves game object based on provided axis values.
  **/
 public void Translate(FP x, FP y, FP z)
 {
     Translate(x, y, z, Space.Self);
 }
Esempio n. 24
0
 public TSVector3(int x, int y, int z)
 {
     this.x = (FP)x;
     this.y = (FP)y;
     this.z = (FP)z;
 }
Esempio n. 25
0
 /**
  *  @brief Moves game object based on provided axis values and a relative {@link TSTransform}.
  *
  *  The game object will move based on TSTransform's forward vector.
  **/
 public void Translate(FP x, FP y, FP z, TSTransform relativeTo)
 {
     Translate(new TSVector(x, y, z), relativeTo);
 }
Esempio n. 26
0
 public TSVector3(FP x, FP y, FP z)
 {
     this.x = x;
     this.y = y;
     this.z = z;
 }
Esempio n. 27
0
 /**
  *  @brief Rotates game object based on provided axis angles of rotation.
  **/
 public void Rotate(FP xAngle, FP yAngle, FP zAngle)
 {
     Rotate(new TSVector(xAngle, yAngle, zAngle), Space.Self);
 }
Esempio n. 28
0
 public void Scale(TSVector3 other)
 {
     this.x = x * other.x;
     this.y = y * other.y;
     this.z = z * other.z;
 }
Esempio n. 29
0
 /**
  *  @brief Rotates game object based on provided axis and angle of rotation.
  **/
 public void Rotate(TSVector axis, FP angle)
 {
     Rotate(axis, angle, Space.Self);
 }
Esempio n. 30
0
 public static FP Barycentric(FP value1, FP value2, FP value3, FP amount1, FP amount2)
 {
     return(value1 + (value2 - value1) * amount1 + (value3 - value1) * amount2);
 }