예제 #1
0
 /// <summary>
 /// 判断两个 Vector3 是否相等
 /// </summary>
 /// <param name="pos">Vector3</param>
 /// <param name="n">对比到小数后多少位</param>
 /// <returns></returns>
 public static bool CampareVector3(Vector3 pos1, Vector3 pos2, int n = 2)
 {
     if (MathExtendUtils.Round(pos1.x, n) == MathExtendUtils.Round(pos2.x, n) &&
         MathExtendUtils.Round(pos1.y, n) == MathExtendUtils.Round(pos2.y, n) &&
         MathExtendUtils.Round(pos1.z, n) == MathExtendUtils.Round(pos2.z, n)
         )
     {
         return(true);
     }
     return(false);
 }
예제 #2
0
        private void applyTranslation(float progress)
        {
            float   valueAt;
            Vector3 zero = Vector3.zero;

            if (this.m_animation != null)
            {
                valueAt = this.m_animation.Evaluate(progress);
            }
            else
            {
                valueAt = this._translation.easing(0, 1, progress);
            }
            if (this._translation.algorithm == TranslationAlgorithm.LINEAR)
            {
                zero = this._translation.start +
                       ((Vector3)((this._translation.target - this._translation.start) * valueAt));
            }
            else if (this._translation.algorithm == TranslationAlgorithm.CATMULL_ROM)
            {
                zero = MathExtendUtils.CatmullRom(valueAt, this._translation.start + this._translation.cp0,
                                                  this._translation.start, this._translation.target,
                                                  this._translation.target + this._translation.cp1);
            }
            else if (this._translation.algorithm == TranslationAlgorithm.QUADRATIC_BEZIER)
            {
                zero = MathExtendUtils.QuadraticBezier(valueAt, this._translation.start, this._translation.cp0,
                                                       this._translation.target);
            }
            else if (this._translation.algorithm == TranslationAlgorithm.CUBIC_BEZIER)
            {
                zero = MathExtendUtils.CubicBezier(valueAt, this._translation.start, this._translation.cp0,
                                                   this._translation.cp1, this._translation.target);
            }
            else if (this._translation.algorithm == TranslationAlgorithm.QUARTIC_BEZIER)
            {
                zero = MathExtendUtils.QuarticBezier(valueAt, this._translation.start, this._translation.cp0,
                                                     this._translation.cp1, this._translation.cp2, this._translation.target);
            }
            if (this._translation.local)
            {
                this._transform.localPosition =
                    new Vector3(!this._translation.axis[0] ? this._transform.localPosition.x : zero.x,
                                !this._translation.axis[1] ? this._transform.localPosition.y : zero.y,
                                !this._translation.axis[2] ? this._transform.localPosition.z : zero.z);
            }
            else
            {
                this._transform.position =
                    new Vector3(!this._translation.axis[0] ? this._transform.position.x : zero.x,
                                !this._translation.axis[1] ? this._transform.position.y : zero.y,
                                !this._translation.axis[2] ? this._transform.position.z : zero.z);
            }
        }