public override void Init()
        {
            try
            {
                JSONStorable js = containingAtom.GetStorableByID("geometry");
                if (js != null)
                {
                    DAZCharacterSelector       dcs     = js as DAZCharacterSelector;
                    GenerateDAZMorphsControlUI morphUI = dcs.morphsControlUI;
                    if (morphUI != null)
                    {
                        stomachMorph   = morphUI.GetMorphByDisplayName("Breath1");
                        mouthMorph     = morphUI.GetMorphByDisplayName("Mouth Open");
                        nosePinchMorph = morphUI.GetMorphByDisplayName("Nose Pinch");
                        noseFlareMorph = morphUI.GetMorphByDisplayName("Nostrils Flare");
                    }
                }

                headAudio       = containingAtom.GetStorableByID("HeadAudioSource");
                chestController = containingAtom.GetStorableByID("chestControl") as FreeControllerV3;

                SetupUI();

                if (chestController != null)
                {
                    chestController.jointRotationDriveSpring = chestSpring.val;
                    chestController.jointRotationDriveDamper = 1.0f;
                }

                List <BreathEntry> tmp = new List <BreathEntry>();
                for (int i = 0; i < breathEntries.Length; ++i)
                {
                    if (!breathEntries[i].moan)
                    {
                        tmp.Add(breathEntries[i]);
                    }
                }
                breathEntriesNoMoan = tmp.ToArray();

                breatheNeedInit = true;

                float v     = variance.val * (breathEntries.Length - 1);
                float bi    = breatheIntensity * (breathEntries.Length - 1);
                float min   = Mathf.Max(bi - v - 1.0f, -0.5f);
                float max   = Mathf.Min(bi + v + 1.0f, breathEntries.Length - 0.5f);
                int   index = Mathf.RoundToInt(UnityEngine.Random.Range(min, max));
                breatheIndex = Mathf.Clamp(index, 0, breathEntries.Length - 1);

                breatheCycle     = 0.0f;
                breatheIntensity = intensity.val;
                breathePower     = UnityEngine.Random.Range(0.8f, 1.2f);
                breatheDuration  = UnityEngine.Random.Range(0.0f, 1.5f);
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
Пример #2
0
        private void Update()
        {
            waited += Time.deltaTime;

            var delay          = Mathf.Lerp(0.05f, 0.001f, vibrationFrequencyStorable.val);
            var changeStrength = vibrationStrengthStorable.val;

            if (delay > 0 && changeStrength > 0 && waited > delay)
            {
                waited            = 0;
                previousDirection = previousDirection * -1;
                foreach (var item in vibrationStrengths)
                {
                    var morphName = item.Key;
                    var morph     = morphsControl.GetMorphByDisplayName(morphName);
                    if (morph != null)
                    {
                        var changeRandomizer = Mathf.Lerp(0.6f, 1.0f, UnityEngine.Random.value);
                        var previousChange   = previousMorphChange[morphName];

                        var changeMultiplier = item.Value;
                        var originalValue    = (morph.morphValue - previousChange);
                        var change           = (previousDirection * changeStrength * changeMultiplier * changeRandomizer);
                        morph.morphValueAdjustLimits = originalValue + change;

                        previousMorphChange[morphName] = change;
                    }
                }
            }
        }
Пример #3
0
        public ExpressionController(DollmasterPlugin dm) : base(dm)
        {
            expressionsEnabled = new JSONStorableBool("expressionsEnabled", true);
            dm.RegisterBool(expressionsEnabled);
            UIDynamicToggle moduleEnableToggle = dm.CreateToggle(expressionsEnabled);

            moduleEnableToggle.label           = "Enable Expressions + Voice";
            moduleEnableToggle.backgroundColor = Color.green;

            JSONStorable         geometry  = atom.GetStorableByID("geometry");
            DAZCharacterSelector character = geometry as DAZCharacterSelector;

            morphControl = character.morphsControlUI;

            mouthOpenMorph   = morphControl.GetMorphByDisplayName("Mouth Open Wide");
            tongueRaiseMorph = morphControl.GetMorphByDisplayName("Tongue Raise-Lower");

            interpolationSpeed = new JSONStorableFloat("expression speed", 8f, 0.1f, 20.0f, true);
            dm.RegisterFloat(interpolationSpeed);
            dm.CreateSlider(interpolationSpeed);

            upperJaw = atom.GetStorableByID("upperJaw") as DAZBone;
            lowerJaw = atom.GetStorableByID("lowerJaw") as DAZBone;

            //  Hack to fix bad tongue morph values
            morphControl.GetMorphByDisplayName("Tongue In-Out").startValue = 1.0f;

            dm.CreateSpacer();
        }
Пример #4
0
        public override void Init()
        {
            try
            {
                JSONStorable js = containingAtom.GetStorableByID("geometry");
                if (js != null)
                {
                    DAZCharacterSelector       dcs     = js as DAZCharacterSelector;
                    GenerateDAZMorphsControlUI morphUI = dcs.morphsControlUI;
                    if (morphUI != null)
                    {
                        stomachMorph   = morphUI.GetMorphByDisplayName("Breath1");
                        mouthMorph     = morphUI.GetMorphByDisplayName("Mouth Open");
                        nosePinchMorph = morphUI.GetMorphByDisplayName("Nose Pinch");
                        noseFlareMorph = morphUI.GetMorphByDisplayName("Nostrils Flare");
                    }
                }

                headAudio       = containingAtom.GetStorableByID("HeadAudioSource");
                chestController = containingAtom.GetStorableByID("chestControl") as FreeControllerV3;


                intensity     = CreateFloatSlider("Intensity", 0.0f, 0.0f, 1.0f);
                variance      = CreateFloatSlider("Variance", 0.2f, 0.0f, 0.5f);
                stomachPower  = CreateFloatSlider("StomachPower", 0.3f, 0.0f, 1.0f);
                chestSpring   = CreateFloatSlider("ChestSpring", 90.0f, 0.0f, 250.0f);
                chestDriveMin = CreateFloatSlider("ChestDriveMin", -3.0f, -20.0f, 20.0f);
                chestDriveMax = CreateFloatSlider("ChestDriveMax", 8.0f, -20.0f, 20.0f);
                mouthOpenMin  = CreateFloatSlider("MouthOpenMin", 0.0f, -0.5f, 2.0f);
                mouthOpenMax  = CreateFloatSlider("MouthOpenMax", 0.8f, -0.5f, 2.0f);

                if (chestController != null)
                {
                    chestController.jointRotationDriveSpring = chestSpring.val;
                    chestController.jointRotationDriveDamper = 1.0f;
                }


                breatheNeedInit = true;

                float v     = variance.val * (breathEntries.Length - 1);
                float bi    = breatheIntensity * (breathEntries.Length - 1);
                float min   = Mathf.Max(bi - v - 1.0f, -0.5f);
                float max   = Mathf.Min(bi + v + 1.0f, breathEntries.Length - 0.5f);
                int   index = Mathf.RoundToInt(UnityEngine.Random.Range(min, max));
                breatheIndex = Mathf.Clamp(index, 0, breathEntries.Length - 1);

                breatheCycle     = 0.0f;
                breatheIntensity = intensity.val;
                breathePower     = UnityEngine.Random.Range(0.8f, 1.2f);
                breatheDuration  = UnityEngine.Random.Range(0.0f, 1.5f);
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
Пример #5
0
 void ClearExpressionMorphs()
 {
     morphControl.GetMorphDisplayNames().ForEach((name) =>
     {
         DAZMorph morph = morphControl.GetMorphByDisplayName(name);
         if (morph.isPoseControl || morph.region.Contains("Expressions"))
         {
             morph.SetValue(morph.startValue);
             morph.SyncJSON();
         }
     });
 }
Пример #6
0
        public void Init(SharedBehaviors plugin)
        {
            JSONStorable               geometry     = plugin.containingAtom.GetStorableByID("geometry");
            DAZCharacterSelector       character    = geometry as DAZCharacterSelector;
            GenerateDAZMorphsControlUI morphControl = character.morphsControlUI;

            blinkMorph = morphControl.GetMorphByDisplayName("Eyes Closed");

            blinkCurve = new AnimationCurve(blinkKeyframes);

            leftSquintMorph  = morphControl.GetMorphByDisplayName("Eyes Squint Left");
            rightSquintMorph = morphControl.GetMorphByDisplayName("Eyes Squint Right");
        }
Пример #7
0
        public ExpressionController(DollmasterPlugin dm) : base(dm)
        {
            morphsEnabled = new JSONStorableBool("morphsEnabled", true, (bool enabled) =>
            {
                if (enabled == false)
                {
                    ZeroTargets();
                }
            });
            dm.RegisterBool(morphsEnabled);
            UIDynamicToggle morphsEnabledToggle = dm.CreateToggle(morphsEnabled);

            morphsEnabledToggle.label           = "Enable Facial Morphs";
            morphsEnabledToggle.backgroundColor = Color.green;

            voiceEnabled = new JSONStorableBool("voiceEnabled", true);
            dm.RegisterBool(voiceEnabled);
            UIDynamicToggle voiceEnabledToggle = dm.CreateToggle(voiceEnabled);

            voiceEnabledToggle.label           = "Enable Voice";
            voiceEnabledToggle.backgroundColor = Color.green;

            morphPercent = new JSONStorableFloat("morph percent", 0.7f, 0, 1, true);
            dm.RegisterFloat(morphPercent);
            UIDynamicSlider morphPercentSlider = dm.CreateSlider(morphPercent);

            JSONStorable         geometry  = atom.GetStorableByID("geometry");
            DAZCharacterSelector character = geometry as DAZCharacterSelector;

            morphControl = character.morphsControlUI;

            mouthOpenMorph   = morphControl.GetMorphByDisplayName("Mouth Open Wide");
            tongueRaiseMorph = morphControl.GetMorphByDisplayName("Tongue Raise-Lower");

            interpolationSpeed = new JSONStorableFloat("expression speed", 8f, 0.1f, 20.0f, true);
            dm.RegisterFloat(interpolationSpeed);
            dm.CreateSlider(interpolationSpeed);

            upperJaw = atom.GetStorableByID("upperJaw") as DAZBone;
            lowerJaw = atom.GetStorableByID("lowerJaw") as DAZBone;

            //  Hack to fix bad tongue morph values.
            //morphControl.GetMorphByDisplayName("Tongue In-Out").startValue = 1.0f;

            dm.CreateSpacer();

            // Prevent mouth from getting too big.
            dm.headAudioSource.SetFloatParamValue("volumeTriggerMultiplier", 0);
        }
Пример #8
0
        public override void Init()
        {
            JSONStorable               geometry     = containingAtom.GetStorableByID("geometry");
            DAZCharacterSelector       character    = geometry as DAZCharacterSelector;
            GenerateDAZMorphsControlUI morphControl = character.morphsControlUI;

            breathingMorph = morphControl.GetMorphByDisplayName("Breath1");
            throatMorph    = morphControl.GetMorphByDisplayName("deepthroat");

            chestControl = containingAtom.GetStorableByID("chestControl") as FreeControllerV3;
            headControl  = containingAtom.GetStorableByID("headControl") as FreeControllerV3;

            RegisterFloat(speed);
            CreateSlider(speed);
        }
Пример #9
0
        void SetExpression(JSONNode node, float alpha = 1.0f)
        {
            if (node == null)
            {
                return;
            }

            alpha = Mathf.Clamp01(alpha);

            JSONArray morphs = node["morphs"].AsArray;

            for (int i = 0; i < morphs.Count; i++)
            {
                JSONClass morphNode = morphs[i].AsObject;
                string    name      = morphNode["name"].Value;
                float     value     = morphNode["value"].AsFloat * alpha;
                DAZMorph  morph     = morphControl.GetMorphByDisplayName(name);
                if (morph == null)
                {
                    continue;
                }

                if (morph.isPoseControl || morph.region.Contains("Expressions"))
                {
                    morphTargets[morph] = value * morphPercent.val;
                    animatedMorphs      = morphTargets.Keys.ToList();
                }
            }
        }
        protected void FixedUpdate()
        {
            if (toggles["Play"].toggle.isOn)
            {
                JSONStorable               geometry     = containingAtom.GetStorableByID("geometry");
                DAZCharacterSelector       character    = geometry as DAZCharacterSelector;
                GenerateDAZMorphsControlUI morphControl = character.morphsControlUI;

                Dictionary <string, UIDynamicToggle> togglesOn = toggles.Where(t => t.Value.toggle.isOn).ToDictionary(p => p.Key, p => p.Value);

                // morph progressively every morphs to their new values
                foreach (KeyValuePair <string, UIDynamicToggle> entry in togglesOn)
                {
                    string name = entry.Key;
                    if (name != "Play")
                    {
                        DAZMorph morph = morphControl.GetMorphByDisplayName(name);
                        if (morph.animatable == false)
                        {
                            float valeur = Mathf.Lerp(CurrentMorphsValues[name], newMorphValues[name], Time.deltaTime * animLengthSlider.val * masterSpeedSlider.val);
                            CurrentMorphsValues[name] = morph.morphValue = valeur;
                        }
                    }
                }
            }
        }
Пример #11
0
        private void animateHands(FreeControllerV3 hc, Hand hand, string[] fingerMorphs, float mirror)
        {
            float fx;

            h = hand.PalmPosition;
            r = hand.Rotation;

            Vector3    pos = new Vector3(h[0], h[1], h[2]);
            Quaternion rot = new Quaternion(r.x, r.y, r.z, r.w);

            hc.transform.position = pos;
            hc.transform.rotation = rot;
            hc.transform.Rotate(0, 90 * mirror, 0);
            hc.transform.Translate(xOffsetSlider.val * mirror, 0, 0, Space.Self);

            for (int i = 0; i < hand.Fingers.Count; i++)
            {
                DAZMorph   morph = morphControl.GetMorphByDisplayName(fingerMorphs[i]);
                Quaternion vd    = leapQuaternionToQuaternion(hand.Fingers[i].bones[3].Rotation);
                vd = Quaternion.Inverse(vd * Quaternion.Euler(0, -90 * mirror, 0)) * rot;

                if (i == 0)
                {
                    fx = (0.5f - minMax(0f, 1f, positiveAttitude(vd.x))) * 1.22f;
                }
                else
                {
                    fx = minMax(0f, 1f, correctRotation(vd.x, 0.65f)) * 0.9f;
                }
                if (fx != 0)
                {
                    morph.morphValue = fx / 0.85f;
                }
            }
        }
 protected void FixedUpdate()
 {
     if (toggles["Play"].toggle.isOn)
     {
         GenerateDAZMorphsControlUI           morphControl = returnMorphs();
         Dictionary <string, UIDynamicToggle> togglesOn    = toggles.Where(t => t.Value.toggle.isOn).ToDictionary(p => p.Key, p => p.Value);
         // morph progressively every morphs to their new values
         string textBoxMessage     = "\n Animatable morphs (not animated) :\n";
         string animatableSelected = textBoxMessage;
         foreach (KeyValuePair <string, UIDynamicToggle> entry in togglesOn)
         {
             string name = entry.Key;
             if (name != "Play")
             {
                 DAZMorph morph = morphControl.GetMorphByDisplayName(name);
                 if (morph.animatable == false)
                 {
                     // float valeur = Mathf.Lerp(CurrentMorphsValues[name], newMorphValues[name], Time.deltaTime * animLengthSlider.val * masterSpeedSlider.val);
                     float valeur = Mathf.Lerp(CurrentMorphsValues[name], newMorphValues[name], Time.deltaTime * animLengthSlider.val * masterSpeedSlider.val * Mathf.Sin(timer / (animWaitSlider.val / masterSpeedSlider.val) * Mathf.PI));
                     CurrentMorphsValues[name] = morph.morphValue = valeur;
                 }
                 else
                 {
                     animatableSelected = animatableSelected + " " + name + "\n";
                 }
             }
         }
         if (animatableSelected != textBoxMessage || morphList.val != textBoxMessage)
         {
             morphList.val = animatableSelected;
         }
     }
 }
Пример #13
0
        public ExpressionAnimation(GenerateDAZMorphsControlUI morphControl, ExpressionAnimation stopping, ExpressionAnimation starting)
        {
            this.morphControl = morphControl;

            ExpressionKeyframe stoppingFrame = stopping.keyframes[0];
            ExpressionKeyframe startingFrame = starting.keyframes[0];

            List <string> stoppingMorphs = stoppingFrame.morphValues.Keys.ToList();
            List <string> startingMorphs = startingFrame.morphValues.Keys.ToList();
            List <string> notInStarting  = stoppingMorphs.Where((stoppingName) =>
            {
                return(startingMorphs.Contains(stoppingName) == false);
            }).ToList();

            ExpressionKeyframe startFrame = new ExpressionKeyframe()
            {
                time = 0
            };
            ExpressionKeyframe endFrame = new ExpressionKeyframe()
            {
                time = 1
            };

            notInStarting.ForEach((morphName) =>
            {
                DAZMorph morph = morphControl.GetMorphByDisplayName(morphName);
                startFrame.morphValues[morphName] = morph.appliedValue;
                endFrame.morphValues[morphName]   = morph.startValue;
            });

            keyframes.Add(startFrame);
            keyframes.Add(endFrame);
            duration = TRANSITION_ANIMATION_DURATION;
        }
Пример #14
0
        private void InitializeMorphs()
        {
            var atom = containingAtom;

            JSONStorable geometry = atom.GetStorableByID("geometry");

            if (geometry == null)
            {
                throw new InvalidOperationException($"Cannot get morphs control for this atom: {atom.uid}");
            }

            DAZCharacterSelector dcs = geometry as DAZCharacterSelector;

            if (dcs == null)
            {
                throw new InvalidOperationException($"Cannot get morphs control for this atom: {atom.uid}");
            }

            morphsControl = dcs.morphsControlUI;
            foreach (var item in vibrationStrengths)
            {
                var morph = morphsControl.GetMorphByDisplayName(item.Key);
                if (morph != null)
                {
                    previousMorphChange[item.Key] = 0.0f;
                }
            }
        }
Пример #15
0
        protected void UpdateRandomParams()
        {
            JSONStorable               geometry     = containingAtom.GetStorableByID("geometry");
            DAZCharacterSelector       character    = geometry as DAZCharacterSelector;
            GenerateDAZMorphsControlUI morphControl = character.morphsControlUI;

            // define the random values to switch to
            morphControl.GetMorphDisplayNames().ForEach((name) =>
            {
                DAZMorph morph = morphControl.GetMorphByDisplayName(name);
                if (toggles.ContainsKey(name) == false)
                {
                    return;
                }

                if (toggles[name].toggle.isOn)
                {
                    if (morph.animatable == false)
                    {
                        float valeur         = UnityEngine.Random.Range(minSlider.val, maxSlider.val) * multiSlider.val;
                        newMorphValues[name] = valeur;
                    }
                }
            });
        }
Пример #16
0
        protected void UpdateRandomParams()
        {
            GenerateDAZMorphsControlUI morphControl = returnMorphs();

            // define the random values to switch to
            foreach (KeyValuePair <string, UIDynamicToggle> entry in togglesOn)
            {
                string name = entry.Key;
                if (name != "Play")
                {
                    DAZMorph morph = morphControl.GetMorphByDisplayName(name);
                    if (morph.animatable == false)
                    {
                        if (CurrentMorphsValues[name] > 0.1f && abaToggle.val)
                        {
                            newMorphValues[name] = 0;
                        }
                        else
                        {
                            float valeur = UnityEngine.Random.Range(minSlider.val, maxSlider.val) * multiSlider.val;
                            newMorphValues[name] = valeur;
                        }
                    }
                }
            }
        }
Пример #17
0
            public Playback(JSONClass json, GenerateDAZMorphsControlUI morphControl)
            {
                float scale = 1;

                if (json.HasKey("scale"))
                {
                    scale = json["scale"].AsFloat;
                }

                var keys = json["keys"].AsObject;
                List <Animation> animations = new List <Animation>();

                foreach (var morphName in keys.Keys.ToList())
                {
                    var animString = keys[morphName].Value;
                    var morph      = morphControl.GetMorphByDisplayName(morphName);
                    if (morph == null)
                    {
                        SuperController.LogError("MorphAnimation: morph not found: " + morphName);
                        continue;
                    }

                    animations.Add(new Animation(morph, animString, scale));
                }

                this.animations = animations;
            }
Пример #18
0
        List <MorphAnimationStep> ConstructPlayback(JSONClass animationData)
        {
            DAZCharacterSelector       dcs     = containingAtom.GetStorableByID("geometry") as DAZCharacterSelector;
            GenerateDAZMorphsControlUI morphUI = dcs.morphsControlUI;

            return(animationData.Keys.ToList().Select((morphName) =>
            {
                DAZMorph morph = morphUI.GetMorphByDisplayName(morphName);
                JSONArray changes = animationData[morphName].AsArray;

                List <MorphAnimationStep> steps = changes.Childs.ToList().Select(change =>
                {
                    JSONClass changeObject = change.AsObject;
                    float time = float.Parse(changeObject["time"]);
                    float value = float.Parse(changeObject["value"]);
                    MorphAnimationStep step = new MorphAnimationStep()
                    {
                        morph = morph,
                        time = time,
                        value = value,
                    };
                    return step;
                }).ToList();

                for (int i = 0; i < steps.Count - 1; i++)
                {
                    steps[i].next = steps[i + 1];
                }

                MorphAnimationStep head = steps[0];
                return head;
            }).ToList());
        }
Пример #19
0
        public override void Init()
        {
            try
            {
                if (containingAtom.type != "Person")
                {
                    SuperController.LogError($"Requires atom of type person, instead selected: {containingAtom.type}");
                    return;
                }

                JSONStorable               geometry = containingAtom.GetStorableByID("geometry");
                DAZCharacterSelector       dcs      = geometry as DAZCharacterSelector;
                GenerateDAZMorphsControlUI morphUI  = dcs.morphsControlUI;
                if (morphUI != null)
                {
                    eyesClosed = morphUI.GetMorphByDisplayName("Eyes Closed");
                }

                JSONStorable eyelids = containingAtom.GetStorableByID("EyelidControl");
                autoBlink = eyelids.GetBoolJSONParam("blinkEnabled");
            }
            catch (System.Exception e) {
                SuperController.LogError("Exception caught: " + e);
            }
        }
Пример #20
0
        void UpdateSearch(string searchTerm)
        {
            if (string.IsNullOrEmpty(searchTerm))
            {
                return;
            }

            List <DAZMorph> foundMorphs = new List <DAZMorph>();

            morphNames.ForEach((name) =>
            {
                bool matches = MatchSearchTerm(name, searchTerm);
                if (matches == false)
                {
                    return;
                }

                foundMorphs.Add(morphControl.GetMorphByDisplayName(name));
            });
            if (switchSort)
            {
                foreach (DAZMorph morph in foundMorphs.OrderByDescending(x => Mathf.Abs(x.appliedValue)))
                {
                    foundMorphsSorted.Add(morph);
                }
                foundMorphs = foundMorphsSorted;
            }


            int pages = Mathf.FloorToInt((float)foundMorphs.Count / morphSliders.Count);

            paginationValue.min = 0;
            paginationValue.max = pages;
            paginationValue.val = 0;

            paginationValue.slider.onValueChanged.RemoveAllListeners();
            paginationValue.slider.onValueChanged.AddListener((float newPage) =>
            {
                UpdateSliders(foundMorphs, Mathf.FloorToInt(newPage));
            });

            paginationSlider.gameObject.SetActive(pages > 1);

            UpdateSliders(foundMorphs, 0);

            UpdateCommonTerms(foundMorphs);
        }
Пример #21
0
        private void UpdateCurrentMorphs()
        {
            GenerateDAZMorphsControlUI morphControl = returnMorphs();

            morphControl.GetMorphDisplayNames().ForEach((name) => {
                CurrentMorphsValues[name] = morphControl.GetMorphByDisplayName(name).morphValue;
            });
        }
        void LoadSaveJson(JSONNode aJson)
        {
            string receiver;

            if (_loadReceiver.val)
            {
                receiver = aJson["receiver"].Value;
            }
            else
            {
                receiver = _receiverJSON.val;
            }
            SyncAtom(_atom.name);

            _receiverJSON.val = receiver; // sync receiver

            foreach (JSONNode target in aJson["targets"].AsArray)
            {
                string targetId   = target["id"].Value;
                var    randomizer = GetRandomizerById(targetId);
                if (randomizer != null)
                {
                    randomizer.RestoreFromJson(target);
                }
                else
                {
                    if (_addAnimatable.val && receiver == "geometry")
                    {
                        // Ensure target is animatable
                        JSONStorable               geometry     = containingAtom.GetStorableByID("geometry");
                        DAZCharacterSelector       character    = geometry as DAZCharacterSelector;
                        GenerateDAZMorphsControlUI morphControl = character.morphsControlUI;
                        DAZMorph morph = morphControl.GetMorphByDisplayName(targetId);
                        if (morph != null)
                        {
                            morph.animatable = true;
                            // Add the newly-animatable target to the list and try again
                            SyncTargetChoices();
                            randomizer = GetRandomizerById(targetId);
                            if (null != randomizer)
                            {
                                randomizer.RestoreFromJson(target);
                            }
                        }
                    }

                    // Still no randomizer? Report the missing param
                    if (randomizer == null)
                    {
                        SuperController.LogMessage("Failed to add randomizer for " + targetId);
                    }
                }
            }

            SyncTargetChoices();
            SyncTargets(_targetJson.val);
            UpdateEnabledList();
        }
Пример #23
0
        public override void Init()
        {
            eyesControl = containingAtom.GetStorableByID("Eyes") as EyesControl;

            faceCollider = containingAtom.GetComponentsInChildren <CapsuleCollider>().ToList().Find(collider => collider.name == "AutoColliderAutoCollidersFaceCentral1Hard");

            headBone = containingAtom.GetStorableByID("head") as DAZBone;

            leftEyeReference = new GameObject().transform;
            leftEyeReference.SetParent(headBone.transform, false);
            leftEyeReference.localPosition = new Vector3(-0.05f, 0.05f, 0.05f);

            rightEyeReference = new GameObject().transform;
            rightEyeReference.SetParent(headBone.transform, false);
            rightEyeReference.localPosition = new Vector3(0.05f, 0.05f, 0.05f);

            #region Debug
            //debugObject = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            //GameObject.Destroy(debugObject.GetComponent<Collider>());
            //debugObject.transform.SetParent(headBone.transform, false);
            //debugObject.transform.localScale = new Vector3(0.1f, 0.1f, 0.1f);
            //debugObject.transform.localPosition = new Vector3(-0.05f, 0.05f, 0.05f);

            //float radius = faceCentralCollider.radius;
            //float height = faceCentralCollider.height;
            //debugObject = GameObject.CreatePrimitive(PrimitiveType.Capsule);
            //debugObject.transform.SetParent(faceCentralCollider.transform, false);
            //debugObject.transform.parent = faceCentralCollider.gameObject.transform;
            //debugObject.transform.localScale = new Vector3(radius, height * 0.5f, radius);
            //GameObject.Destroy(debugObject.GetComponent<Collider>());
            #endregion

            JSONStorable               geometry     = containingAtom.GetStorableByID("geometry");
            DAZCharacterSelector       character    = geometry as DAZCharacterSelector;
            GenerateDAZMorphsControlUI morphControl = character.morphsControlUI;
            leftSquintMorph    = morphControl.GetMorphByDisplayName("Eyes Squint Left");
            rightSquintMorph   = morphControl.GetMorphByDisplayName("Eyes Squint Right");
            pupilDilationMorph = morphControl.GetMorphByDisplayName("PupilDilation");

            RegisterFloat(squintSpeed);
            CreateSlider(squintSpeed);
        }
Пример #24
0
        public void Stop()
        {
            if (keyframes.Count <= 0)
            {
                return;
            }

            isPlaying = false;
            ExpressionKeyframe step = keyframes[0];

            step.morphValues.Keys.ToList().ForEach((morphName) =>
            {
                DAZMorph morph = morphControl.GetMorphByDisplayName(morphName);
                if (morph != null)
                {
                    //morph.SetValue(morph.startValue);
                    morph.SetDefaultValue();
                }
            });
        }
Пример #25
0
        private void UpdateNewMorphs()
        {
            GenerateDAZMorphsControlUI morphControl = returnMorphs();

            morphControl.GetMorphDisplayNames().ForEach((name) => {
                if (toggles.ContainsKey(name))
                {
                    newMorphValues[name] = morphControl.GetMorphByDisplayName(name).morphValue;
                }
            });
        }
Пример #26
0
        void Start()
        {
            try
            {
                morphControl = returnMorphs();

                morphControl.GetMorphByDisplayName("Left Thumb Fist").morphValue    = 0;
                morphControl.GetMorphByDisplayName("Right Thumb Fist").morphValue   = 0;
                morphControl.GetMorphByDisplayName("Left Fingers Fist").morphValue  = 0;
                morphControl.GetMorphByDisplayName("Right Fingers Fist").morphValue = 0;

                lh = containingAtom.GetStorableByID("lHandControl") as FreeControllerV3;
                rh = containingAtom.GetStorableByID("rHandControl") as FreeControllerV3;
                hd = containingAtom.GetStorableByID("headControl") as FreeControllerV3;
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
Пример #27
0
        private void UpdateInitialMorphs()
        {
            JSONStorable               geometry     = containingAtom.GetStorableByID("geometry");
            DAZCharacterSelector       character    = geometry as DAZCharacterSelector;
            GenerateDAZMorphsControlUI morphControl = character.morphsControlUI;

            morphControl.GetMorphDisplayNames().ForEach((name) =>
            {
                initialMorphValues[name] = morphControl.GetMorphByDisplayName(name).morphValue;
            });
        }
Пример #28
0
 void ZeroMorphs(GenerateDAZMorphsControlUI morphControl)
 {
     morphControl.GetMorphDisplayNames().ForEach((name) =>
     {
         DAZMorph morph = morphControl.GetMorphByDisplayName(name);
         if (morph.isPoseControl)
         {
             morph.SetValue(morph.startValue);
             morph.SyncJSON();
         }
     });
 }
Пример #29
0
        private void saveLoadMorphs(bool saveM)
        {
            int                        C            = 0;
            JSONStorable               geometry     = containingAtom.GetStorableByID("geometry");
            DAZCharacterSelector       character    = geometry as DAZCharacterSelector;
            GenerateDAZMorphsControlUI morphControl = character.morphsControlUI;

            morphControl.GetMorphDisplayNames().ForEach((name) =>
            {
                if (saveM == true)
                {
                    morphDict[name] = morphControl.GetMorphByDisplayName(name).morphValue;
                }
                else
                {
                    morphControl.GetMorphByDisplayName(name).morphValue = morphDict[name];
                }
                C++;
            });
            SuperController.LogMessage("Morph total : " + C.ToString());
        }
Пример #30
0
        private void ResetMorphs()
        {
            JSONStorable               geometry     = containingAtom.GetStorableByID("geometry");
            DAZCharacterSelector       character    = geometry as DAZCharacterSelector;
            GenerateDAZMorphsControlUI morphControl = character.morphsControlUI;

            morphControl.GetMorphDisplayNames().ForEach((name) =>
            {
                if (toggleRelations.ContainsKey(name))
                {
                    DAZMorph morph   = morphControl.GetMorphByDisplayName(name);
                    morph.morphValue = initialMorphValues[name];
                }
            });
        }