Exemplo n.º 1
0
        private float CalculateDistance()
        {
            // Orbit distance
            var v1 = Utilities.Project2D(ValueOriginal.inverse.GetPosition(), Vector3.forward);

            v1.Normalize();

            var v2 = Utilities.Project2D(ValueTarget.inverse.GetPosition(), Vector3.forward);

            v2.Normalize();

            var angle = Mathf.Abs(Vector3.Angle(v1, v2));

            // Rotate distance
            v1 = Utilities.Project2D(ValueOriginal.GetPosition(), Vector3.forward);
            v1.Normalize();

            v2 = Utilities.Project2D(ValueTarget.GetPosition(), Vector3.forward);
            v2.Normalize();

            var angle2 = Mathf.Abs(Vector3.Angle(v1, v2));

            if (angle2 > angle)
            {
                angle = angle2;
            }

            var radius = (ValueOriginal.inverse.GetPosition().magnitude + ValueTarget.inverse.GetPosition().magnitude) / 2;

            var arcDist  = radius * angle;
            var lineDist = (ValueTarget.inverse.GetPosition() - ValueOriginal.inverse.GetPosition()).magnitude;

            return((lineDist > arcDist) ? lineDist : arcDist);
        }
Exemplo n.º 2
0
        public override void Apply()
        {
            //Notifier.AddMessage(StepCountTotal.ToString());
            var f = Mathf.SmoothStep(0, 1, DurationCurrent / Duration);
            //var f = (float)_step / _steps;
            var l = Mathf.Lerp(beginLength, endLength, f);

            var d = Vector3.Lerp(valueBegin.GetPosition(), valueEnd.GetPosition(), f);

            d.Normalize();
            d *= l;

            ValueCurrent =
                MatrixUtilities.CreateRotationMatrix(Quaternion.Slerp(ValueOriginal.GetRotation(), ValueTarget.GetRotation(), f))
                * MatrixUtilities.CreateTranslationMatrix(d);

            transform.position = d;
            transform.rotation = Quaternion.Slerp(ValueOriginal.GetRotation(), ValueTarget.GetRotation(), f);
        }
Exemplo n.º 3
0
 public override void Revert()
 {
     transform.position = ValueOriginal.GetPosition();
     transform.rotation = ValueOriginal.GetRotation();
 }
Exemplo n.º 4
0
 public override void Revert()
 {
     transform.SetPosition(ValueOriginal.GetPosition(), SetGlobal);
     transform.SetRotation(ValueOriginal.GetRotation(), SetGlobal);
 }