ExpressionAnimationUI CreateUIFromExpressionPath(string path, JSONStorableString store)
        {
            string fileName = PathExt.GetFileNameWithoutExtension(path);

            store.SetVal(sc.NormalizePath(path));

            string jsonString = sc.ReadFileIntoString(path);

            ExpressionAnimation animation = new ExpressionAnimation(morphControl, jsonString);

            JSONStorableAction action = new JSONStorableAction("Play " + fileName, () =>
            {
                PlayExpression(animation);
            });

            RegisterAction(action);

            ExpressionAnimationUI ui = null;

            ui = new ExpressionAnimationUI(this, fileName, animation, () =>
            {
                store.SetVal("");
                uiList.Remove(ui);
                animationLookup.Remove(fileName);
                DeregisterAction(action);
            });



            animationLookup[fileName] = animation;
            expressionChooser.choices = animationLookup.Keys.ToList();
            uiList.Add(ui);
            return(ui);
        }
Beispiel #2
0
        private void UpdateMassEstimate(float atomScale, bool updateUIStatus = false)
        {
            float mass = breastMassCalculator.Calculate(atomScale);

            if (mass > Const.MASS_MAX)
            {
                massEstimate = Const.MASS_MAX;
                if (updateUIStatus)
                {
                    float excess = Calc.RoundToDecimals(mass - Const.MASS_MAX, 1000f);
                    statusUIText.SetVal(MassExcessStatus(excess));
                }
            }
            else if (mass < Const.MASS_MIN)
            {
                massEstimate = Const.MASS_MIN;
                if (updateUIStatus)
                {
                    float shortage = Calc.RoundToDecimals(Const.MASS_MIN - mass, 1000f);
                    statusUIText.SetVal(MassShortageStatus(shortage));
                }
            }
            else
            {
                massEstimate = mass;
                if (updateUIStatus)
                {
                    statusUIText.SetVal("");
                }
            }
        }
Beispiel #3
0
        private void FixedUpdate()
        {
            try
            {
                if (!physicsUpdateInProgress && (breastMorphListener.Changed() || atomScaleListener.Changed()))
                {
                    StartCoroutine(RefreshStaticPhysics());
                }

                float roll     = AngleCalc.Roll(chest.rotation);
                float pitch    = AngleCalc.Pitch(chest.rotation);
                float scaleVal = breastMassCalculator.LegacyScale(massEstimate);

                gravityMorphH.Update(roll, pitch, scaleVal, gravityLogAmount);
                gravityPhysicsH.Update(roll, pitch, scaleVal, Const.ConvertToLegacyVal(gravity.val));
#if DEBUG_PHYSICS || DEBUG_MORPHS
                SetBaseDebugInfo(roll, pitch);
#endif
#if DEBUG_PHYSICS
                physicsDebugInfo.SetVal(staticPhysicsH.GetStatus() + gravityPhysicsH.GetStatus());
#elif DEBUG_MORPHS
                morphDebugInfo.SetVal(gravityMorphH.GetStatus());
#endif
            }
            catch (Exception e)
            {
                Log.Error($"{e}");
                Log.Error($"Try reloading plugin!");
                enabled = false;
            }
        }
Beispiel #4
0
        private void InitPluginUIRight()
        {
            bool rightSide = true;

            statusUIText = NewTextField("statusText", 28, 100, rightSide);

#if DEBUG_PHYSICS || DEBUG_MORPHS
            UIDynamicTextField angleInfoField = CreateTextField(baseDebugInfo, rightSide);
            angleInfoField.height          = 125;
            angleInfoField.UItext.fontSize = 26;
#else
            CreateNewSpacer(10f, true);
            JSONStorableString usage2Area = NewTextField("Usage Info Area 2", 28, 135, rightSide);
            string             usage2     = UI.Size("\n", 12);
            usage2 += "Physics settings mode selection.";
            usage2Area.SetVal(usage2);

            CreateNewSpacer(10f, true);
            JSONStorableString usage1Area = NewTextField("Usage Info Area 1", 28, 255, rightSide);
            string             usage1     = UI.Size("\n", 12);
            usage1 += "Breast softness adjusts soft physics settings from very firm to very soft.\n\n";
            usage1 += "Breast gravity adjusts how much pose morphs shape the breasts in all orientations.";
            usage1Area.SetVal(usage1);
#endif
#if DEBUG_PHYSICS
            UIDynamicTextField physicsInfoField = CreateTextField(physicsDebugInfo, rightSide);
            physicsInfoField.height          = 945;
            physicsInfoField.UItext.fontSize = 26;
#elif DEBUG_MORPHS
            UIDynamicTextField morphInfo = CreateTextField(morphDebugInfo, rightSide);
            morphInfo.height          = 945;
            morphInfo.UItext.fontSize = 26;
#endif
        }
Beispiel #5
0
 void UpdateStatus()
 {
     if (bvh == null)
     {
         uiStatus.SetVal("Select BVH File");
     }
     else if (baking)
     {
         uiStatus.SetVal("Recording now...");
     }
     else
     {
         uiStatus.SetVal(string.Format("Loaded {0}. {1} bones. {2} frames. {3} FPS. Duration {4:0.#}s. {5}.", bvh.path, bvh.bones.Length, bvh.nFrames,
                                       (int)Mathf.Round(1f / bvh.frameTime), bvh.nFrames * bvh.frameTime, bvh.isTranslationLocal ? "Local translation" : "Absolute Translation"));
     }
 }
Beispiel #6
0
 private void SetBaseDebugInfo(float roll, float pitch)
 {
     baseDebugInfo.SetVal(
         $"{Formatting.NameValueString("Roll", roll, 100f, 15)}\n" +
         $"{Formatting.NameValueString("Pitch", pitch, 100f, 15)}\n" +
         $"{breastMassCalculator.GetStatus(atomScaleListener.Value)}"
         );
 }
Beispiel #7
0
        private void InitPluginUILeft()
        {
            JSONStorableString titleUIText      = new JSONStorableString("titleText", "");
            UIDynamicTextField titleUITextField = CreateTextField(titleUIText);

            titleUITextField.UItext.fontSize = 36;
            titleUITextField.height          = 100;
            titleUIText.SetVal($"{nameof(MocapSwitcher)}\n<size=28>v{pluginVersion}</size>");

            CreateLoadMocapButton();
            CreateSaveMocapButton();
        }
Beispiel #8
0
        void UpdateSaveStore()
        {
            JSONArray freshArray = new JSONArray();

            saveJSON["keyframes"] = freshArray;

            keyframes.ForEach((key) =>
            {
                freshArray.Add(key.pose);
            });

            saveStore.SetVal(saveJSON.ToString());
        }
Beispiel #9
0
        public override void Init()
        {
            try
            {
                ui = new UI(this, 0.001f);
                ui.canvas.transform.SetParent(containingAtom.mainController.transform, false);
                ui.canvas.transform.localPosition = new Vector3(0, -0.15f, 0);

                thrustValue = new JSONStorableFloat("thrust", 0, 0, SLIDER_MAX, true, true);
                RegisterFloat(thrustValue);

                UIDynamicSlider thrustSlider = ui.CreateSlider("Thrust Control", 300, 120);
                thrustSlider.valueFormat = "n0";
                thrustValue.slider       = thrustSlider.slider;

                thrustSlider.slider.onValueChanged.AddListener((float value) =>
                {
                    if (ap != null)
                    {
                        float speed = Remap(thrustValue.val, 0, SLIDER_MAX, 0, maxSpeed.val);
                        ap.SetFloatParamValue("speed", speed);
                    }
                });

                apName = new JSONStorableString("apName", "");
                RegisterString(apName);

                CreateButton("Select Animation Pattern").button.onClick.AddListener(() =>
                {
                    SuperController.singleton.SelectModeAtom((atom) =>
                    {
                        if (atom.GetStorableByID("AnimationPattern") == null)
                        {
                            SuperController.LogError("You must select an animation pattern.");
                            return;
                        }

                        apName.SetVal(atom.name);
                        ap = atom.GetStorableByID("AnimationPattern") as AnimationPattern;
                    });
                });

                maxSpeed = new JSONStorableFloat("maxSpeed", 4, 0, 10, false, true);
                RegisterFloat(maxSpeed);
                CreateSlider(maxSpeed, true);
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }
Beispiel #10
0
        string LoadClips(string requestedPath)
        {
            loadLog.SetVal("");
            try
            {
                //  try as-is, when user selects a folder instead of being in the folder
                SuperController.singleton.GetFilesAtPath(requestedPath).ToList().ForEach((string fileName) =>
                {
                    if (fileName.Contains(".json"))
                    {
                        return;
                    }

                    if (!fileName.Contains(".mp3") && !fileName.Contains(".wav") && !fileName.Contains(".ogg"))
                    {
                        return;
                    }
                    clips.Add(LoadAudio(fileName));
                    loadLog.val += SuperController.singleton.NormalizePath(fileName) + "\n";
                });
                return(requestedPath);
            }
            catch
            {
                //  if user is in the folder, figure out what path they meant
                string folderName = "\\" + requestedPath.Substring(requestedPath.LastIndexOf('\\') + 1) + "\\";
                requestedPath = requestedPath.Replace(folderName, "\\");
                Debug.Log("reqPath is now " + requestedPath);
                SuperController.singleton.GetFilesAtPath(requestedPath).ToList().ForEach((string fileName) =>
                {
                    if (fileName.Contains(".json"))
                    {
                        return;
                    }

                    if (!fileName.Contains(".mp3") && !fileName.Contains(".wav") && !fileName.Contains(".ogg"))
                    {
                        return;
                    }
                    clips.Add(LoadAudio(fileName));
                    loadLog.val += SuperController.singleton.NormalizePath(fileName) + "\n";
                });
                return(requestedPath);
            }
        }
Beispiel #11
0
        private void InitPluginUILeft()
        {
            titleUIText = NewTextField("titleText", 36, 100);
            titleUIText.SetVal($"{nameof(TittyMagic)}\n<size=28>v{version}</size>");

            CreateNewSpacer(10f);
            modeChooser                = new JSONStorableStringChooser("Mode", Const.MODES.Keys.ToList(), Const.MODES.Values.ToList(), "", "Mode");
            modeButtonGroup            = CreateRadioButtonGroup(modeChooser);
            staticPhysicsH.modeChooser = modeChooser;

            CreateNewSpacer(10f);
            softness = NewFloatSlider("Breast softness", 50f, Const.SOFTNESS_MIN, Const.SOFTNESS_MAX, "F0");
            gravity  = NewFloatSlider("Breast gravity", 50f, Const.GRAVITY_MIN, Const.GRAVITY_MAX, "F0");
            linkSoftnessAndGravity     = NewToggle("Link softness and gravity", false);
            linkSoftnessAndGravity.val = true;

            CreateNewSpacer(10f);
            nippleErection = NewFloatSlider("Erect nipples", 0f, 0f, 1.0f, "F2");
        }
 void PerformSave()
 {
     saveString.SetVal(ToJSON().ToString());
 }
Beispiel #13
0
        public override void Init()
        {
            try {
                #region UI
                CreateButton("Select BVH File").button.onClick.AddListener(() => {
                    if (prevFolder == "")
                    {
                        prevFolder = SuperController.singleton.savesDir + "\\Animation";
                    }
                    SuperController.singleton.GetMediaPathDialog((string path) => {
                        Load(path);
                    }, "bvh", prevFolder, false);
                });

                uiStatus = new JSONStorableString("Status:", "");
                CreateTextField(uiStatus, true);
                uiStatus.SetVal("Select a BVH file");

                var showSkeleton = new JSONStorableBool("Show Skeleton", false, (bool val) => {
                    if (val)
                    {
                        ShowSkeleton();
                    }
                    else
                    {
                        HideSkeleton();
                    }
                });
                RegisterBool(showSkeleton);
                CreateToggle(showSkeleton);
                // var uiOnlyHipTrans = new JSONStorableBool("Only hip translation", true, (bool val) => {
                //     onlyHipTranslation = val;
                // });
                // onlyHipTranslation = uiOnlyHipTrans.val;
                // RegisterBool(uiOnlyHipTrans);
                // CreateToggle(uiOnlyHipTrans);

                var modes = new List <string>();
                modes.Add("Offset + Frame (DAZ)");
                modes.Add("Frame only");
                modes.Add("Initial + Frame - Offset (MB)");
                modes.Add("Initial + Frame - Frame[0] (CMU)");

                var uiTranslationMode = new JSONStorableStringChooser("transmode", modes, modes[translationMode], "Translation Mode", (string val) => {
                    translationMode = modes.FindIndex((string mode) => { return(mode == val); });
                    if ((translationMode == translationModeInitialPlusFrameMinusOffset || translationMode == translationModeInitialPlusFrameMinusZero) && tposeBoneOffsets == null)
                    {
                        // We need t-pose measurements, and don't have them yet
                        RecordOffsets();
                        CreateControllerMap();
                    }
                });
                CreatePopup(uiTranslationMode);

                // var uiTransDelta = new JSONStorableBool("Translation is local", true, (bool val) => {
                //     translationIsDelta = val;
                //     if(! translationIsDelta && tposeBoneOffsets == null) {
                //         RecordOffsets();
                //         CreateControllerMap();
                //     }
                // });
                // translationIsDelta = uiTransDelta.val;
                // RegisterBool(uiTransDelta);
                // CreateToggle(uiTransDelta);

                var space = CreateSpacer(true);
                space.height = 20f;
                space        = CreateSpacer();
                space.height = 10f;

                CreateButton("<<").button.onClick.AddListener(() => {
                    uiAnimationPos.SetVal(0);
                });
                CreateButton(">>", true).button.onClick.AddListener(() => {
                    uiAnimationPos.SetVal(100);
                });

                var playModes = new List <string>();
                playModes.Add("Once");
                playModes.Add("Loop");
                playModes.Add("PingPong Once");
                playModes.Add("PingPong Loop");

                var uiPlayMode = new JSONStorableStringChooser("playmode", playModes, playModes[0], "Play Mode", (string val) => {
                    var i        = playModes.IndexOf(val);
                    loopPlay     = (i & 1) == 1;
                    pingpongPlay = i >= 2;
                });
                var uiBakeMode = new JSONStorableStringChooser("bakemode", playModes, playModes[0], "Bake Mode", (string val) => {
                    var i        = playModes.IndexOf(val);
                    loopBake     = (i & 1) == 1;
                    pingpongBake = i >= 2;
                });

                uiAnimationPos = new JSONStorableFloat("Animation (%)", 0, (float value) => {
                    if (bvh != null && !isUpdating)
                    {
                        frame = (int)(bvh.nFrames * value * 0.01);
                        if (frame >= bvh.nFrames)
                        {
                            frame = bvh.nFrames - 1;
                        }
                        discontinuity = true;
                    }
                }, 0, 100);
                CreateSlider(uiAnimationPos);
                uiAnimationSpeed = new JSONStorableFloat("Speed (%)", 100, UpdateSpeed, 1, 300);
                CreateSlider(uiAnimationSpeed, true);

                CreatePopup(uiPlayMode);
                CreateButton("Play").button.onClick.AddListener(() => {
                    playing = true;
                    reverse = false;
                });
                CreatePopup(uiBakeMode, true);
                CreateButton("Bake", true).button.onClick.AddListener(() => {
                    Bake();
                });
                CreateButton("Stop", true).button.onClick.AddListener(() => {
                    playing = false;
                    if (baking)
                    {
                        BakeStop();
                    }
                });
                #endregion

                // saveCollisionEnabled = containingAtom.collisionEnabledJSON.val;
                // containingAtom.collisionEnabledJSON.val = false;

                CreateShadowSkeleton();
                if (showSkeleton.val)
                {
                    ShowSkeleton();
                }
                RecordOffsets();
                CreateControllerMap();
            }
            catch (Exception e) {
                SuperController.LogError("Init: " + e);
            }
        }
Beispiel #14
0
        public override void Init()
        {
            try
            {
                LOAD_PATH = SuperController.singleton.currentLoadDir;

                Sequence.onBranchSelected += OnBranchSelected;

                JSONStorableString sequenceStorable = new JSONStorableString("sequencePath", "", (string sequencePath) =>
                {
                    #region path normalization testing
                    //Debug.Log(sequencePath);
                    //string scenePath = SuperController.singleton.NormalizeScenePath(sequencePath);
                    //string directoryPath = SuperController.singleton.NormalizeDirectoryPath(sequencePath);
                    //string loadPath = SuperController.singleton.NormalizeLoadPath(sequencePath);
                    //string savePath = SuperController.singleton.NormalizeSavePath(sequencePath);
                    //string mediaPath = SuperController.singleton.NormalizeMediaPath(sequencePath);
                    //string path = SuperController.singleton.NormalizePath(sequencePath);

                    //Debug.Log("path " + path);
                    //Debug.Log("scene path " + scenePath);
                    //Debug.Log("directory path " + directoryPath);
                    //Debug.Log("load path " + loadPath);
                    //Debug.Log("save path " + savePath);
                    //Debug.Log("media path " + mediaPath);
                    #endregion


                    Cleanup();

                    string loadPath     = SuperController.singleton.NormalizeLoadPath(sequencePath);
                    string loadedString = SuperController.singleton.ReadFileIntoString(loadPath);
                    JSONClass setup     = (JSONClass)JSON.Parse(loadedString);

                    string startingSequenceName = setup["start"];
                    sceneLoader = new SceneLoader(setup["reference"], GetContainingAtom());

                    JSONClass sequenceData = setup["sequences"].AsObject;
                    sequenceData.Keys.ToList().ForEach((string key) =>
                    {
                        JSONClass branchesObject = sequenceData[key].AsObject["branch"].AsObject as JSONClass;
                        Sequence sequence        = sequences[key] = new Sequence(this, branchesObject);
                    });

                    currentSequence = sequences[startingSequenceName];

                    if (currentSequence != null)
                    {
                        currentSequence.GenerateButtons();
                    }
                });

                RegisterString(sequenceStorable);

                CreateButton("Load Sequence").button.onClick.AddListener(() =>
                {
                    SuperController.singleton.currentLoadDir = LOAD_PATH;
                    SuperController.singleton.GetScenePathDialog((filePath) =>
                    {
                        if (string.IsNullOrEmpty(filePath))
                        {
                            return;
                        }

                        string normalizedPath = SuperController.singleton.NormalizeSavePath(filePath);
                        sequenceStorable.SetVal(filePath);
                    });
                });
            }
            catch (Exception e)
            {
                SuperController.LogError("Exception caught: " + e);
            }
        }