public int SetKeyframeToCurrentTransform(FreeControllerAnimationTarget target, float time)
 {
     time = time.Snap();
     if (time > current.animationLength)
     {
         time = current.animationLength;
     }
     return(target.SetKeyframeToCurrentTransform(time));
 }
Esempio n. 2
0
 public void SetKeyframeToCurrentTransform(FreeControllerAnimationTarget target, float time)
 {
     time = time.Snap();
     if (time > Current.animationLength)
     {
         time = Current.animationLength;
     }
     target.SetKeyframeToCurrentTransform(time);
 }
Esempio n. 3
0
        private IEnumerator ImportRecordedCoroutine()
        {
            var containingAtom = plugin.containingAtom;
            var totalStopwatch = Stopwatch.StartNew();

            yield return(0);

            var controlCounter = 0;

            foreach (var mot in containingAtom.motionAnimationControls)
            {
                FreeControllerAnimationTarget target = null;
                FreeControllerV3 ctrl;

                _importRecordedUI.buttonText.text = $"Importing, please wait... ({++controlCounter} / {containingAtom.motionAnimationControls.Length})";

                try
                {
                    if (mot == null || mot.clip == null)
                    {
                        continue;
                    }
                    if (mot.clip.clipLength <= 0.1)
                    {
                        continue;
                    }
                    ctrl = mot.controller;
                    current.Remove(ctrl);
                    target = current.Add(ctrl);
                    target.StartBulkUpdates();
                    target.SetKeyframeToCurrentTransform(0);
                    target.SetKeyframeToCurrentTransform(current.animationLength);
                }
                catch (Exception exc)
                {
                    SuperController.LogError($"VamTimeline.{nameof(MocapScreen)}.{nameof(ImportRecordedCoroutine)}[Init]: {exc}");
                    target?.EndBulkUpdates();
                    yield break;
                }

                IEnumerator enumerator;
                try
                {
                    if (_importRecordedOptionsJSON.val == "Keyframe Reduction")
                    {
                        enumerator = ExtractFramesWithReductionTechnique(mot.clip, target, ctrl).GetEnumerator();
                    }
                    else
                    {
                        enumerator = ExtractFramesWithFpsTechnique(mot.clip, target, ctrl).GetEnumerator();
                    }
                }
                catch
                {
                    target.EndBulkUpdates();
                    throw;
                }

                while (TryMoveNext(enumerator, target))
                {
                    yield return(enumerator.Current);
                }

                target.EndBulkUpdates();
            }

            _importRecordedUI.buttonText.text     = "Import Recorded Animation (Mocap)";
            _importRecordedUI.button.interactable = true;
        }