Exemple #1
0
 void Update()
 {
     try {
         foreach (var tracked in TrackedMorphs)
         {
             if (!tracked.Enabled)
             {
                 continue;
             }
             tracked.Sync();
         }
     }
     catch (Exception e) {
         SuperController.LogError("Exception caught: " + e);
     }
 }
 public override void Init()
 {
     Log("### Init ###");
     try
     {
         base.Init();
         _triggers = new TriggerManager(this);
         InitStorables();
         InitFileManager();
         StartCoroutine(DeferredInit());
     }
     catch (Exception e)
     {
         SuperController.LogError($"AudioMate.{nameof(AudioMateController)}.{nameof(Init)}: {e}");
     }
 }
Exemple #3
0
        private void OnAnimationParametersChanged()
        {
            try
            {
                scrubberJSON.max           = animationEditContext.current.animationLength;
                scrubberJSON.valNoCallback = animationEditContext.clipTime;
                timeJSON.valNoCallback     = animationEditContext.playTime;
                speedJSON.valNoCallback    = animation.speed;

                BroadcastToControllers(nameof(IRemoteControllerPlugin.OnTimelineAnimationParametersChanged));
            }
            catch (Exception exc)
            {
                SuperController.LogError($"Timeline.{nameof(AtomPlugin)}.{nameof(OnAnimationParametersChanged)}: {exc}");
            }
        }
        public override void Init()
        {
            try
            {
                defautHeight           = new JSONStorableFloat("Default height", heightByDef, 0.0f, 2.0f, true);
                defautHeight.storeType = JSONStorableParam.StoreType.Full;
                RegisterFloat(defautHeight);
                CreateSlider(defautHeight, true);

                StartCoroutine(Setup());
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
Exemple #5
0
 public AtomStorableSelector(
     MVRScript plug, CallbackAction call, string startAtom = "None") : base(call)
 {
     try
     {
         atomSelected    = new AtomSelector(plug, this.SyncAtom, startAtom);
         storableChooser = new JSONStorableStringChooser("element", null, null, "Element", SyncStorable);
         plug.RegisterStringChooser(storableChooser);
         UIDynamicPopup dp = plug.CreateScrollablePopup(storableChooser);
         dp.popupPanelHeight = 960f;
     }
     catch (Exception e)
     {
         SuperController.LogError("Exception caught: " + e);
     }
 }
    public override JSONClass GetJSON(bool includePhysical = true, bool includeAppearance = true, bool forceStore = false)
    {
        var json = base.GetJSON(includePhysical, includeAppearance, forceStore);

        try
        {
            json["actions"] = _customCommands.GetJSON();
            needsStore      = true;
        }
        catch (Exception exc)
        {
            SuperController.LogError($"Keybindings: {nameof(CustomActions)}.{nameof(GetJSON)}: {exc}");
        }

        return(json);
    }
    public override void Init()
    {
        try
        {
            // TODO: Implement this!
            SuperController.LogMessage("Plugin installed");

#if (VAM_DIAGNOSTICS)
            SuperController.LogMessage("This will only appear in debug mode");
#endif
        }
        catch (Exception e)
        {
            SuperController.LogError("Failed to initialize plugin: " + e);
        }
    }
        public AtomClipboardEntry Start(float clipTime, IEnumerable <FreeControllerAnimationTarget> targets)
        {
            // ReSharper disable once RedundantEnumerableCastCall
            var snapshot = AtomAnimationClip.Copy(clipTime, targets.Cast <IAtomAnimationTarget>().ToList());

            if (snapshot.controllers.Count == 0)
            {
                SuperController.LogError($"Timeline: Cannot offset, no keyframes were found at time {clipTime}.");
                return(null);
            }
            if (snapshot.controllers.Select(c => _clip.targetControllers.First(t => t.controller == c.controller)).Any(t => !t.EnsureParentAvailable(false)))
            {
                return(null);
            }
            return(snapshot);
        }
Exemple #9
0
 public void OnDisable()
 {
     try
     {
         if (animation?.IsPlaying() ?? false)
         {
             animation.Stop();
         }
         _ui?.Disable();
         DestroyControllerPanel();
     }
     catch (Exception exc)
     {
         SuperController.LogError($"VamTimeline.{nameof(AtomPlugin)}.{nameof(OnDisable)}: " + exc);
     }
 }
Exemple #10
0
        private IEnumerator StopWhenPlaybackIsComplete()
        {
            var waitFor = plugin.animation.Clips.Sum(c => c.NextAnimationTime.IsSameFrame(0) ? c.animationLength : c.NextAnimationTime);

            yield return(new WaitForSeconds(waitFor));

            try
            {
                SuperController.singleton.motionAnimationMaster.StopRecord();
                plugin.animation.Stop();
            }
            catch (Exception exc)
            {
                SuperController.LogError($"VamTimeline.{nameof(AdvancedScreen)}.{nameof(StopWhenPlaybackIsComplete)}: {exc}");
            }
        }
Exemple #11
0
 public AudioMateClipCollection(JSONNode jn, AudioMateController controller)
 {
     if (jn == null || jn.AsObject == null)
     {
         return;
     }
     try
     {
         _controller = controller;
         Parse(jn);
     }
     catch (Exception e)
     {
         SuperController.LogError($"AudioMate.{nameof(AudioMateClipCollection)}.{nameof(AudioMateClipCollection)} (JSON): {e}");
     }
 }
Exemple #12
0
        private void InitFloatParamsUI()
        {
            _addStorableListJSON = new JSONStorableStringChooser("Animate storable", new List <string>(), "", "Animate Storable", (string name) =>
            {
                RefreshStorableFloatsList();
                _addParamListJSON.valNoCallback = _addParamListJSON.choices.FirstOrDefault() ?? "";
            });
            _addStorableListUI = prefabFactory.CreateScrollablePopup(_addStorableListJSON);
            _addStorableListUI.popupPanelHeight           = 700f;
            _addStorableListUI.popup.onOpenPopupHandlers += RefreshStorablesList;

            _addParamListJSON = new JSONStorableStringChooser("Animate param", new List <string>(), "", "Animate param");
            _addParamListUI   = prefabFactory.CreateScrollablePopup(_addParamListJSON);
            _addParamListUI.popup.onOpenPopupHandlers += RefreshStorableFloatsList;
            _addParamListUI.popupPanelHeight           = 600f;

            _toggleFloatParamUI = prefabFactory.CreateButton("Add param");
            _toggleFloatParamUI.button.onClick.AddListener(() => AddAnimatedFloatParam());

            RefreshStorablesList();
            RefreshStorableFloatsList();

            var character = plugin.containingAtom.GetComponentInChildren <DAZCharacterSelector>();

            if (character != null)
            {
                prefabFactory.CreateSpacer();
                var makeMorphsAnimatableUI = prefabFactory.CreateButton("<i>Go to <b>morphs</b> (animatable)</i>");
                makeMorphsAnimatableUI.button.onClick.AddListener(() =>
                {
                    SuperController.singleton.SelectController(plugin.containingAtom.freeControllers.First(f => f.name == "control"));
                    var selector = plugin.containingAtom.gameObject.GetComponentInChildren <UITabSelector>();
                    if (selector == null)
                    {
                        SuperController.LogError("Could not find the tabs selector");
                    }
                    else if (character.selectedCharacter.isMale)
                    {
                        selector.SetActiveTab("Male Morphs");
                    }
                    else
                    {
                        selector.SetActiveTab("Female Morphs");
                    }
                });
            }
        }
Exemple #13
0
    public void Update()
    {
        try
        {
            if (!_active)
            {
                if (_toggleKey != KeyCode.None && Input.GetKeyDown(_toggleKey))
                {
                    _activeJSON.val = true;
                    return;
                }

                return;
            }

            if (!HealthCheck())
            {
                return;
            }

            if (Input.GetKeyDown(KeyCode.Escape) || _toggleKey != KeyCode.None && Input.GetKeyDown(_toggleKey))
            {
                _activeJSON.val = false;
                return;
            }

            var navigationRig = SuperController.singleton.navigationRig;

            if (_follower != null)
            {
                PossessRotation();
            }
            else if (_rotationLockJSON.val)
            {
                UpdateRotation(navigationRig, _rotationSmoothingJSON.val);
            }

            if (_positionLockJSON.val)
            {
                UpdatePosition(navigationRig, _positionSmoothingJSON.val);
            }
        }
        catch (Exception e)
        {
            SuperController.LogError("Failed to update: " + e);
        }
    }
        private void UpdateAnimationLength(float newLength)
        {
            if (animation.isPlaying)
            {
                _lengthJSON.valNoCallback = current.animationLength;
                return;
            }

            newLength = newLength.Snap(animation.snap);
            if (newLength < 0.1f)
            {
                newLength = 0.1f;
            }
            var time = animation.clipTime.Snap();

            switch (_lengthModeJSON.val)
            {
            case ChangeLengthModeStretch:
                operations.Resize().Stretch(newLength);
                break;

            case ChangeLengthModeCropExtendEnd:
                operations.Resize().CropOrExtendEnd(newLength);
                break;

            case ChangeLengthModeCropExtendBegin:
                operations.Resize().CropOrExtendAt(newLength, 0f);
                break;

            case ChangeLengthModeCropExtendAtTime:
                operations.Resize().CropOrExtendAt(newLength, time);
                break;

            case ChangeLengthModeLoop:
                operations.Resize().Loop(newLength);
                break;

            default:
                SuperController.LogError($"VamTimeline: Unknown animation length type: {_lengthModeJSON.val}");
                break;
            }

            _lengthJSON.valNoCallback = current.animationLength;
            current.DirtyAll();

            animation.clipTime = Math.Min(time, newLength);
        }
 public override bool Validate()
 {
     if (context.containingAtom.GetStorableIDs().Any(id => id.EndsWith("Glance")))
     {
         return(false);
     }
     Rescan();
     if (controlAutoFocusPoint.val)
     {
         _autoFocusPoint = SuperController.singleton.GetAtoms().FirstOrDefault(a => a.type == "Empty" && a.uid == "AutoFocusPoint")?.mainController.control;
         if (_autoFocusPoint == null)
         {
             SuperController.LogError("Embody: There is no AutoFocusPoint atom of type Empty in your scene.");
         }
     }
     return(_mirrors.Count > 0 || _objects.Count > 0 || _autoFocusPoint != null);
 }
Exemple #16
0
        public void ChangeAnimation(string animationName)
        {
            if (string.IsNullOrEmpty(animationName))
            {
                return;
            }

            try
            {
                animation.SelectAnimation(animationName);
                animationJSON.valNoCallback = animation.current.animationName;
            }
            catch (Exception exc)
            {
                SuperController.LogError($"VamTimeline.{nameof(AtomPlugin)}.{nameof(ChangeAnimation)}: {exc}");
            }
        }
Exemple #17
0
 void Update()
 {
     try
     {
         if (Input.GetKey(KeyCode.LeftControl) || Input.GetKey(KeyCode.RightControl))
         {
             if (Input.GetKeyDown(KeyCode.D))
             {
                 CloneSelected();
             }
         }
     }
     catch (Exception e)
     {
         SuperController.LogError("Exception caught: " + e);
     }
 }
    public static void DebugLog(string condition, string stackTrace, LogType type)
    {
        if (condition == null || condition.StartsWith("Log ") || string.IsNullOrEmpty(stackTrace))
        {
            return;
        }
        var msg = $"{type} {condition} {stackTrace}";

        if (type == LogType.Error || type == LogType.Exception)
        {
            SuperController.LogError(msg);
        }
        else
        {
            SuperController.LogMessage(msg);
        }
    }
Exemple #19
0
        public override JSONClass GetJSON(bool includePhysical = true, bool includeAppearance = true, bool forceStore = false)
        {
            var json = base.GetJSON(includePhysical, includeAppearance, forceStore);

            try
            {
                json["Animation"] = serializer.SerializeAnimation(animation);
                json["Options"]   = AtomAnimationSerializer.SerializeEditContext(animationEditContext);
                needsStore        = true;
            }
            catch (Exception exc)
            {
                SuperController.LogError($"Timeline.{nameof(AtomPlugin)}.{nameof(GetJSON)} (Serialize): {exc}");
            }

            return(json);
        }
Exemple #20
0
        private void EnableAllTargets()
        {
            try
            {
                var allControllers = plugin.animation.Clips.SelectMany(c => c.TargetControllers).Select(t => t.controller).Distinct().ToList();
                var h = new HashSet <JSONStorableFloat>();
                var allFloatParams = plugin.animation.Clips.SelectMany(c => c.TargetFloatParams).Where(t => h.Add(t.floatParam)).Select(t => new FloatParamRef {
                    Storable = t.storable, FloatParam = t.floatParam
                }).ToList();

                foreach (var clip in plugin.animation.Clips)
                {
                    foreach (var controller in allControllers)
                    {
                        if (!clip.TargetControllers.Any(t => t.controller == controller))
                        {
                            var target = clip.Add(controller);
                            if (target != null)
                            {
                                target.SetKeyframeToCurrentTransform(0f);
                                target.SetKeyframeToCurrentTransform(clip.animationLength);
                            }
                        }
                    }
                    clip.TargetControllers.Sort(new FreeControllerAnimationTarget.Comparer());

                    foreach (var floatParamRef in allFloatParams)
                    {
                        if (!clip.TargetFloatParams.Any(t => t.floatParam == floatParamRef.FloatParam))
                        {
                            var target = clip.Add(floatParamRef.Storable, floatParamRef.FloatParam);
                            if (target != null)
                            {
                                target.SetKeyframe(0f, floatParamRef.FloatParam.val);
                                target.SetKeyframe(clip.animationLength, floatParamRef.FloatParam.val);
                            }
                        }
                    }
                    clip.TargetFloatParams.Sort(new FloatParamAnimationTarget.Comparer());
                }
            }
            catch (Exception exc)
            {
                SuperController.LogError($"VamTimeline.{nameof(TargetsScreen)}.{nameof(EnableAllTargets)}: {exc}");
            }
        }
Exemple #21
0
 // FixedUpdate is called with each physics simulation frame by Unity
 void FixedUpdate()
 {
     try
     {
         if (containingAtom.type != "Person")
         {
             return;
         }
         DAZCharacterSelector dcs = containingAtom.GetComponentInChildren <DAZCharacterSelector>();
         BreastsFixedUpdate(dcs);
         GlutesFixedUpdate(dcs);
     }
     catch (Exception e)
     {
         SuperController.LogError("Exception caught FixedUpdate(): " + e);
     }
 }
Exemple #22
0
 public override void Init()
 {
     try
     {
         _atom = GetAtom();
         InitStorables();
         InitCustomUI();
         if (!_hideJSON.val)
         {
             OnEnable();
         }
     }
     catch (Exception exc)
     {
         SuperController.LogError($"VamTimeline.{nameof(ControllerPlugin)}.{nameof(Init)}: " + exc);
     }
 }
    public override void Init()
    {
        try
        {
            _step = containingAtom.parentAtom.GetComponentInChildren <AnimationStep>();
            if (_step == null)
            {
                throw new Exception("Can only apply DirectorStep on AnimationStep");
            }

            InitControls();
        }
        catch (Exception e)
        {
            SuperController.LogError("Failed to initialize plugin: " + e);
        }
    }
 private void Import()
 {
     try
     {
         #if (VAM_GT_1_20)
         FileManagerSecure.CreateDirectory(_saveFolder);
         var shortcuts = FileManagerSecure.GetShortCutsForDirectory(_saveFolder);
         SuperController.singleton.GetMediaPathDialog(ImportFileSelected, _saveExt, _saveFolder, false, true, false, null, false, shortcuts);
         #else
         SuperController.singleton.GetMediaPathDialog(ImportFileSelected, _saveExt, _saveFolder);
         #endif
     }
     catch (Exception exc)
     {
         SuperController.LogError($"Timeline: Failed to open file dialog: {exc}");
     }
 }
Exemple #25
0
 /**
  * Set the audio source controller which plays the clips
  */
 public void SyncAudioReceiver()
 {
     if (ReceiverAtom == null || ReceiverNode == null)
     {
         return;
     }
     try
     {
         Receiver =
             SuperController.singleton.GetAtomByUid(ReceiverAtom)?.GetStorableByID(ReceiverNode)
             as AudioSourceControl;
     }
     catch (Exception e)
     {
         SuperController.LogError($"AudioMate.{nameof(AudioMateController)}.{nameof(SyncAudioReceiver)}: {e}");
     }
 }
Exemple #26
0
        public void OnTimelineEvent(object[] e)
        {
            if (_receiving)
            {
                throw new InvalidOperationException("Already syncing, infinite loop avoided!");
            }

            _receiving = true;
            try
            {
                switch ((string)e[0])
                {
                case nameof(SendPlaybackState):
                    ReceivePlaybackState(e);
                    break;

                case nameof(SendTime):
                    ReceiveTime(e);
                    break;

                case nameof(SendCurrentAnimation):
                    ReceiveCurrentAnimation(e);
                    break;

                case nameof(SendScreen):
                    ReceiveScreen(e);
                    break;

                case nameof(SendSyncAnimation):
                    ReceiveSyncAnimation(e);
                    break;

                default:
                    SuperController.LogError($"Received message name {e[0]} but no handler exists for that event");
                    break;
                }
            }
            catch (Exception exc)
            {
                SuperController.LogError($"VamTimeline.{nameof(PeerManager)}.{nameof(OnTimelineEvent)}: {exc}");
            }
            finally
            {
                _receiving = false;
            }
        }
Exemple #27
0
        private JSONClass GetCollectionsJSON()
        {
            var json = new JSONClass();

            try
            {
                foreach (var collection in _collections.Where(collection => collection != null && collection.Count != 0))
                {
                    json[collection.Name] = collection.ToJSON();
                }
            }
            catch (Exception e)
            {
                SuperController.LogError($"AudioMate.{nameof(AudioMateCollectionManager)}.{nameof(GetCollectionsJSON)}: {e}");
            }
            return(json);
        }
Exemple #28
0
        private void StartRecordOffset()
        {
            if (current.clipTime < _startJSON.val || current.clipTime > _endJSON.val)
            {
                SuperController.LogError($"VamTimeline: Cannot offset, current time is outside of the bounds of the selection");
                return;
            }
            _offsetSnapshot = current.Copy(current.clipTime, current.GetAllOrSelectedTargets().OfType <FreeControllerAnimationTarget>().Cast <IAtomAnimationTarget>());
            if (_offsetSnapshot.controllers.Count == 0)
            {
                SuperController.LogError($"VamTimeline: Cannot offset, no keyframes were found at time {current.clipTime}.");
                return;
            }

            _offsetControllerUI.label = _offsetControllerUIOfsettingLabel;
            _offsetting = true;
        }
Exemple #29
0
    public override void Init()
    {
        try
        {
            _atom = GetAtom();

            _labelJSON = new JSONStorableString("Label", "My Slider", label =>
            {
                if (_ui == null)
                {
                    return;
                }
                _ui.label = label;
            });
            RegisterString(_labelJSON);
            CreateTextInput(_labelJSON);

            _valueJSON = new JSONStorableFloat(_labelJSON.val, 0f, v => UpdateValue(v), 0f, 10f, false);
            RegisterFloat(_valueJSON);

            OnEnable();

            _atomJSON = new JSONStorableStringChooser("Target atom", SuperController.singleton.GetAtomUIDs(), "", "Target atom", uid => OnTargetAtomChanged(uid));
            RegisterStringChooser(_atomJSON);
            var atomPopup = CreateScrollablePopup(_atomJSON, true);
            atomPopup.popupPanelHeight = 800f;
            SuperController.singleton.onAtomUIDsChangedHandlers += (uids) => OnAtomsChanged(uids);
            OnAtomsChanged(SuperController.singleton.GetAtomUIDs());

            var storables = new List <string>(new[] { "" });
            _storableJSON = new JSONStorableStringChooser("Target storable", storables, "", "Target storable", storable => OnTargetStorableChanged(storable));
            RegisterStringChooser(_storableJSON);
            var storablePopup = CreateScrollablePopup(_storableJSON, true);
            storablePopup.popupPanelHeight = 800f;

            var storableParams = new List <string>(new[] { "" });
            _storableParamJSON = new JSONStorableStringChooser("Target param", storables, "", "Target param", floatParam => OnTargetParamChanged(floatParam));
            RegisterStringChooser(_storableParamJSON);
            var storableParamUI = CreateScrollablePopup(_storableParamJSON, true);
            storableParamUI.popupPanelHeight = 800f;
        }
        catch (Exception exc)
        {
            SuperController.LogError($"{nameof(UISlider)}.{nameof(Init)}: " + exc);
        }
    }
Exemple #30
0
 // FixedUpdate is called with each physics simulation frame by Unity
 void FixedUpdate()
 {
     try {
         // apply forces here
         float timeFactor = Time.fixedDeltaTime;
         currentForce  = Vector3.Lerp(currentForce, targetForce, timeFactor * forceQuicknessJSON.val);
         currentTorque = Vector3.Lerp(currentTorque, targetTorque, timeFactor * torqueQuicknessJSON.val);
         if (RB && (!SuperController.singleton || !SuperController.singleton.freezeAnimation))
         {
             RB.AddForce(currentForce, ForceMode.Force);
             RB.AddTorque(currentTorque, ForceMode.Force);
         }
     }
     catch (Exception e) {
         SuperController.LogError("Exception caught: " + e);
     }
 }