protected override void DrawCreateButtonGUI() { GatoGUILayout.Button( LocalizeText.instance.langPair.createAnimFileButtonText, () => { var animController = originalAvatar.StandingAnimController; var createdAnimClip = FaceEmotion.CreateBlendShapeAnimationClip(animName, originalAvatar.AnimSavedFolderPath, editAvatar); if (selectedHandAnim != HandPose.HandPoseType.NoSelection) { HandPose.AddHandPoseAnimationKeysFromOriginClip(createdAnimClip, handPoseAnim); animController[AnimationsGUI.HANDANIMS[(int)selectedHandAnim - 1]] = createdAnimClip; EditorUtility.SetDirty(animController); FaceEmotion.ResetToDefaultFaceEmotion(editAvatar); } originalAvatar.StandingAnimController = animController; editAvatar.StandingAnimController = animController; animationsGUI.ResetPathMissing(AnimationsGUI.HANDANIMS[(int)selectedHandAnim - 1]); }, selectedHandAnim != HandPose.HandPoseType.NoSelection && handPoseAnim != null); }
protected void DrawFunctionButtons() { using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); GatoGUILayout.Button( LocalizeText.instance.langPair.loadAnimationButtonText, () => { FaceEmotion.LoadAnimationProperties(this, parentWindow); }, editAvatar.Descriptor != null); GatoGUILayout.Button( LocalizeText.instance.langPair.setToDefaultButtonText, () => { if (EditorUtility.DisplayDialog( LocalizeText.instance.langPair.setToDefaultDialogTitleText, LocalizeText.instance.langPair.setToDefaultDialogMessageText, LocalizeText.instance.langPair.ok, LocalizeText.instance.langPair.cancel)) { FaceEmotion.SetToDefaultFaceEmotion(editAvatar, originalAvatar); } }, editAvatar.Descriptor != null); GatoGUILayout.Button( LocalizeText.instance.langPair.resetToDefaultButtonText, () => { FaceEmotion.ResetToDefaultFaceEmotion(editAvatar); ChangeSaveAnimationState(); }, editAvatar.Descriptor != null); } }
public void SetRequestedEmotion(FaceEmotion emotion) { RequestedEmotion = emotion; EmotionValidation = EmotionValidationState.None; EmotionScores = null; UpdatedAt = DateTimeOffset.Now; }
internal static FaceEmotion ToFaceEmotion(this Droid.Contract.Emotion emotion) { var faceEmotion = new FaceEmotion { Anger = (float)emotion.Anger, Contempt = (float)emotion.Contempt, Disgust = (float)emotion.Disgust, Fear = (float)emotion.Fear, Happiness = (float)emotion.Happiness, Neutral = (float)emotion.Neutral, Sadness = (float)emotion.Sadness, Surprise = (float)emotion.Surprise, MostEmotion = nameof(emotion.Anger), MostEmotionValue = (float)emotion.Anger }; if (faceEmotion.Contempt > faceEmotion.MostEmotionValue) { faceEmotion.MostEmotion = nameof(faceEmotion.Contempt); faceEmotion.MostEmotionValue = faceEmotion.Contempt; } if (faceEmotion.Disgust > faceEmotion.MostEmotionValue) { faceEmotion.MostEmotion = nameof(faceEmotion.Disgust); faceEmotion.MostEmotionValue = faceEmotion.Disgust; } if (faceEmotion.Fear > faceEmotion.MostEmotionValue) { faceEmotion.MostEmotion = nameof(faceEmotion.Fear); faceEmotion.MostEmotionValue = faceEmotion.Fear; } if (faceEmotion.Happiness > faceEmotion.MostEmotionValue) { faceEmotion.MostEmotion = nameof(faceEmotion.Happiness); faceEmotion.MostEmotionValue = faceEmotion.Happiness; } if (faceEmotion.Neutral > faceEmotion.MostEmotionValue) { faceEmotion.MostEmotion = nameof(faceEmotion.Neutral); faceEmotion.MostEmotionValue = faceEmotion.Neutral; } if (faceEmotion.Sadness > faceEmotion.MostEmotionValue) { faceEmotion.MostEmotion = nameof(faceEmotion.Sadness); faceEmotion.MostEmotionValue = faceEmotion.Sadness; } if (faceEmotion.Surprise > faceEmotion.MostEmotionValue) { faceEmotion.MostEmotion = nameof(faceEmotion.Surprise); faceEmotion.MostEmotionValue = faceEmotion.Surprise; } return(faceEmotion); }
/// <summary> /// アバターの情報を取得する /// </summary> public void LoadAvatarInfo(GameObject avatarObj) { if (avatarObj == null) { return; } Animator = avatarObj.GetComponent <Animator>(); AvatarId = avatarObj.GetComponent <PipelineManager>()?.blueprintId ?? string.Empty; Materials = GatoUtility.GetMaterials(avatarObj); int triangleCountInactive = 0; TriangleCount = GatoUtility.GetAllTrianglesCount(avatarObj, ref triangleCountInactive); TriangleCountInactive = triangleCountInactive; GameObject faceMeshObj = null; if (FaceMesh != null) { faceMeshObj = FaceMesh.gameObject; } SkinnedMeshList = GetSkinnedMeshList(avatarObj, faceMeshObj); DefaultFaceEmotion = FaceEmotion.GetAvatarFaceParamaters(SkinnedMeshList); MeshRendererList = GatoUtility.GetMeshList(avatarObj); Height = CalculateAvatarHeight( Animator.transform.position, SkinnedMeshList.Select(s => s.Renderer), MeshRendererList); }
string GetEmotion(FaceEmotion emotion) { string emotionType = ""; double emotionValue = 0.0; if (emotion.Anger > emotionValue) { emotionValue = emotion.Anger; emotionType = "Anger"; } if (emotion.Contempt > emotionValue) { emotionValue = emotion.Contempt; emotionType = "Contempt"; } if (emotion.Disgust > emotionValue) { emotionValue = emotion.Disgust; emotionType = "Disgust"; } if (emotion.Fear > emotionValue) { emotionValue = emotion.Fear; emotionType = "Fear"; } if (emotion.Happiness > emotionValue) { emotionValue = emotion.Happiness; emotionType = "Happiness"; } if (emotion.Neutral > emotionValue) { emotionValue = emotion.Neutral; emotionType = "Neutral"; } if (emotion.Sadness > emotionValue) { emotionValue = emotion.Sadness; emotionType = "Sadness"; } if (emotion.Surprise > emotionValue) { emotionValue = emotion.Surprise; emotionType = "Surprise"; } return(string.Format("{0}: {1}", emotionType, emotionValue)); }
public virtual void OnLoadedAnimationProperties() { FaceEmotion.ApplyAnimationProperties(ScriptableSingleton <SendData> .instance.loadingProperties, editAvatar); }
protected void BlendShapeListGUI() { // BlendShapeのリスト using (var scrollView = new EditorGUILayout.ScrollViewScope(scrollPos)) { scrollPos = scrollView.scrollPosition; foreach (IFaceEmotionSkinnedMesh skinnedMesh in editAvatar.SkinnedMeshList) { if (skinnedMesh.BlendShapeCount <= 0) { continue; } skinnedMesh.IsOpenBlendShapes = EditorGUILayout.Foldout(skinnedMesh.IsOpenBlendShapes, skinnedMesh.Obj.name); if (skinnedMesh.IsOpenBlendShapes) { using (new EditorGUI.IndentLevelScope()) { using (new GUILayout.HorizontalScope()) { using (var check = new EditorGUI.ChangeCheckScope()) { skinnedMesh.IsContainsAll = EditorGUILayout.ToggleLeft(string.Empty, skinnedMesh.IsContainsAll, GUILayout.Width(45)); if (check.changed) { FaceEmotion.SetContainsAll(skinnedMesh.IsContainsAll, skinnedMesh.Blendshapes); } } EditorGUILayout.LabelField(LocalizeText.instance.langPair.toggleAllLabel, GUILayout.Height(20)); } foreach (var blendshape in skinnedMesh.Blendshapes) { if (!blendshape.IsExclusion) { using (new EditorGUILayout.HorizontalScope()) { blendshape.IsContains = EditorGUILayout.ToggleLeft(string.Empty, blendshape.IsContains, GUILayout.Width(45)); EditorGUILayout.SelectableLabel(blendshape.Name, GUILayout.Height(20)); using (var check = new EditorGUI.ChangeCheckScope()) { var value = skinnedMesh.Renderer.GetBlendShapeWeight(blendshape.Id); value = EditorGUILayout.Slider(value, 0, 100); if (check.changed) { skinnedMesh.Renderer.SetBlendShapeWeight(blendshape.Id, value); } } GatoGUILayout.Button( LocalizeText.instance.langPair.minButtonText, () => { FaceEmotion.SetBlendShapeMinValue(skinnedMesh.Renderer, blendshape.Id); }, true, GUILayout.MaxWidth(50)); GatoGUILayout.Button( LocalizeText.instance.langPair.maxButtonText, () => { FaceEmotion.SetBlendShapeMaxValue(skinnedMesh.Renderer, blendshape.Id); }, true, GUILayout.MaxWidth(50)); } } } } } } } }
public void Dispose() { FaceEmotion.ResetToDefaultFaceEmotion(editAvatar); }
public FaceEmotionDTO GetEmotionDTOFromEmotion(FaceEmotion emotion) { return(_mapper.Map <FaceEmotion, FaceEmotionDTO>(emotion)); }
public override bool DrawGUI(GUILayoutOption[] layoutOptions) { // 設定済みアニメーション一覧 using (new EditorGUILayout.VerticalScope(GUI.skin.box, layoutOptions)) { using (new EditorGUILayout.HorizontalScope()) { GUILayout.FlexibleSpace(); // タブを描画する _tab = (Tab)GUILayout.Toolbar((int)_tab, LocalizeText.instance.animationTabTexts, "LargeButton", GUI.ToolbarButtonSize.Fixed); GUILayout.FlexibleSpace(); } if (_tab == Tab.Standing) { titleText = LocalizeText.instance.langPair.standingTabText; if (originalAvatar != null) { controller = originalAvatar.StandingAnimController; } } else { titleText = LocalizeText.instance.langPair.sittingTabText; if (originalAvatar != null) { controller = originalAvatar.SittingAnimController; } } using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField(titleText, EditorStyles.boldLabel); string btnText; if (!showEmoteAnimations) { btnText = LocalizeText.instance.langPair.emoteButtonText; } else { btnText = LocalizeText.instance.langPair.faceAndHandButtonText; } GatoGUILayout.Button( btnText, () => { showEmoteAnimations = !showEmoteAnimations; }); } EditorGUILayout.Space(); if (controller != null) { if (!showEmoteAnimations) { AnimationClip anim; for (int i = 0; i < HANDANIMS.Length; i++) { var handPoseName = HANDANIMS[i]; anim = handPoseName == controller[handPoseName].name ? null : controller[handPoseName]; controller[handPoseName] = EdittableAnimationField( (i + 1) + ":" + handPoseName, anim, pathMissing[i], anim != null, () => { if (vrcAvatarEditorGUI.CurrentTool != VRCAvatarEditorGUI.ToolFunc.FaceEmotion) { vrcAvatarEditorGUI.CurrentTool = VRCAvatarEditorGUI.ToolFunc.FaceEmotion; } FaceEmotion.ApplyAnimationProperties(controller[handPoseName], editAvatar); ((FaceEmotionGUI2)faceEmotionGUI).ChangeSaveAnimationState(controller[handPoseName].name, (HandPose.HandPoseType)Enum.ToObject(typeof(HandPose.HandPoseType), i + 1), controller[handPoseName]); }); } } else { AnimationClip anim; foreach (var emoteAnim in EMOTEANIMS) { anim = emoteAnim == controller[emoteAnim].name ? null : controller[emoteAnim]; controller[emoteAnim] = ValidatableAnimationField($" {emoteAnim}", anim, false); } } } else { if (editAvatar.Descriptor == null) { EditorGUILayout.HelpBox(LocalizeText.instance.langPair.noAvatarMessageText, MessageType.Warning); } else { string notSettingMessage, createMessage; if (_tab == Tab.Standing) { notSettingMessage = LocalizeText.instance.langPair.noCustomStandingAnimsMessageText; createMessage = LocalizeText.instance.langPair.createCustomStandingAnimsButtonText; } else { notSettingMessage = LocalizeText.instance.langPair.noCustomSittingAnimsMessageText; createMessage = LocalizeText.instance.langPair.createCustomSittingAnimsButtonText; } EditorGUILayout.HelpBox(notSettingMessage, MessageType.Warning); GatoGUILayout.Button( createMessage, () => { var fileName = "CO_" + originalAvatar.Animator.gameObject.name + ".overrideController"; saveFolderPath = "Assets/" + originalAvatar.Animator.gameObject.name + "/"; var fullFolderPath = Path.GetFullPath(saveFolderPath); if (!Directory.Exists(fullFolderPath)) { Directory.CreateDirectory(fullFolderPath); AssetDatabase.Refresh(); } var createdCustomOverrideController = InstantiateVrcCustomOverideController(saveFolderPath + fileName); if (_tab == Tab.Standing) { originalAvatar.Descriptor.CustomStandingAnims = createdCustomOverrideController; editAvatar.Descriptor.CustomStandingAnims = createdCustomOverrideController; } else { originalAvatar.Descriptor.CustomSittingAnims = createdCustomOverrideController; editAvatar.Descriptor.CustomSittingAnims = createdCustomOverrideController; } originalAvatar.LoadAvatarInfo(); editAvatar.LoadAvatarInfo(); vrcAvatarEditorGUI.UpdateExclusitionBlendShapes(); }); if (_tab == Tab.Sitting) { GatoGUILayout.Button( LocalizeText.instance.langPair.setToSameAsCustomStandingAnimsButtonText, () => { var customStandingAnimsController = originalAvatar.Descriptor.CustomStandingAnims; originalAvatar.Descriptor.CustomSittingAnims = customStandingAnimsController; editAvatar.Descriptor.CustomSittingAnims = customStandingAnimsController; originalAvatar.LoadAvatarInfo(); editAvatar.LoadAvatarInfo(); vrcAvatarEditorGUI.UpdateExclusitionBlendShapes(); }, editAvatar.StandingAnimController != null); } } } if (pathMissing.Any(x => x)) { var warningMessage = (failedAutoFixMissingPath) ? LocalizeText.instance.langPair.failAutoFixMissingPathMessageText : LocalizeText.instance.langPair.existMissingPathMessageText; EditorGUILayout.HelpBox(warningMessage, MessageType.Warning); GatoGUILayout.Button( LocalizeText.instance.langPair.autoFix, () => { failedAutoFixMissingPath = false; for (int i = 0; i < pathMissing.Length; i++) { if (!pathMissing[i]) { continue; } var result = GatoUtility.TryFixMissingPathInAnimationClip( editAvatar.Animator, editAvatar.StandingAnimController[HANDANIMS[i]]); pathMissing[i] = !result; failedAutoFixMissingPath = !result; } }, !failedAutoFixMissingPath ); } } return(false); }
public override bool DrawGUI(GUILayoutOption[] layoutOptions) { using (new EditorGUILayout.VerticalScope(GUI.skin.box, layoutOptions)) { if (originalAvatar != null) { fxController = originalAvatar.FxController; } using (new EditorGUILayout.HorizontalScope()) { EditorGUILayout.LabelField("FX Layer", EditorStyles.boldLabel); // TODO: Emote一覧に切り替えるボタン } EditorGUILayout.Space(); // TODO: Emote一覧と切り替えられるように? if (fxController != null) { var layerNames = fxController.layers.Select(l => l.name).ToArray(); editAvatar.TargetFxLayerIndex = EditorGUILayout.Popup("Layer", editAvatar.TargetFxLayerIndex, layerNames); var states = fxController.layers[editAvatar.TargetFxLayerIndex] .stateMachine.states .Where(s => !(s.state.motion is BlendTree)) .OrderBy(s => s.state.name) .ToArray(); GatoGUILayout.ErrorBox(LocalizeText.instance.langPair.haveNoAnimationClipMessageText, states.Any(), MessageType.Info); AnimationClip anim; for (int i = 0; i < states.Length; i++) { var stateName = states[i].state.name; anim = states[i].state.motion as AnimationClip; states[i].state.motion = EdittableAnimationField( $"{i + 1}:{stateName}", anim, false, anim != null && !anim.name.StartsWith("proxy_"), () => { if (vrcAvatarEditorGUI.CurrentTool != VRCAvatarEditorGUI.ToolFunc.FaceEmotion) { vrcAvatarEditorGUI.CurrentTool = VRCAvatarEditorGUI.ToolFunc.FaceEmotion; } FaceEmotion.ApplyAnimationProperties(anim, editAvatar); ((FaceEmotionGUI3)faceEmotionGUI).ChangeSaveAnimationState( anim.name, i, anim); }); } } else { EditorGUILayout.HelpBox(LocalizeText.instance.langPair.missingFxControllerMessageText, MessageType.Warning); if (GUILayout.Button(LocalizeText.instance.langPair.createFxControllerText)) { CreatePlayableLayerController(originalAvatar, editAvatar); vrcAvatarEditorGUI.OnToolChanged(); } } } return(false); }
protected override void DrawCreateButtonGUI() { GatoGUILayout.Button( LocalizeText.instance.langPair.createAnimFileButtonText, () => { var controller = originalAvatar.FxController; var createdAnimClip = FaceEmotion.CreateBlendShapeAnimationClip( animName, originalAvatar.AnimSavedFolderPath, editAvatar, true); // Stateがない場合は作成のみ if (states.Any()) { states[selectedStateIndex].state.motion = createdAnimClip; EditorUtility.SetDirty(controller); // 可能であればもう一方の手も同じAnimationClipを設定する if (setLeftAndRight) { var layerName = editAvatar.FxController.layers[editAvatar.TargetFxLayerIndex].name; string targetLayerName = string.Empty; if (layerName == "Left Hand") { targetLayerName = "Right Hand"; } else if (layerName == "Right Hand") { targetLayerName = "Left Hand"; } if (!string.IsNullOrEmpty(targetLayerName)) { var targetLayer = editAvatar.FxController.layers .Where(l => l.name == targetLayerName) .SingleOrDefault(); if (targetLayer != null) { var targetStateName = states[selectedStateIndex].state.name; var targetState = targetLayer.stateMachine.states .Where(s => s.state.name == targetStateName) .SingleOrDefault(); if (targetState.state != null) { targetState.state.motion = createdAnimClip; EditorUtility.SetDirty(controller); } } } } } FaceEmotion.ResetToDefaultFaceEmotion(editAvatar); originalAvatar.FxController = controller; editAvatar.FxController = controller; }, originalAvatar.FxController != null); }