コード例 #1
0
ファイル: AiueoViewer.cs プロジェクト: vrm-c/UniVRMTest
        IEnumerator RoutineNest(BlendShapePreset preset, float velocity, float wait)
        {
            for (var value = 0.0f; value <= 1.0f; value += velocity)
            {
                BlendShapes.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(preset), value);
                yield return(null);
            }
            BlendShapes.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(preset), 1.0f);
            yield return(new WaitForSeconds(wait));

            for (var value = 1.0f; value >= 0; value -= velocity)
            {
                BlendShapes.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(preset), value);
                yield return(null);
            }
            BlendShapes.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(preset), 0);
            yield return(new WaitForSeconds(wait * 2));
        }
コード例 #2
0
 // Use this for initialization
 void Start()
 {
     GamePad.OnButtonPushed.Subscribe(key =>
     {
         if (key == XinputKey.A)
         {
             target.ImmediatelySetValue(BlendShapePreset.Fun, 1f);
         }
         else
         {
             target.ImmediatelySetValue(BlendShapePreset.Fun, 0f);
         }
         if (key == XinputKey.B)
         {
             target.ImmediatelySetValue(BlendShapePreset.Angry, 1f);
         }
         else
         {
             target.ImmediatelySetValue(BlendShapePreset.Angry, 0f);
         }
         if (key == XinputKey.X)
         {
             target.ImmediatelySetValue(BlendShapePreset.Joy, 1f);
         }
         else
         {
             target.ImmediatelySetValue(BlendShapePreset.Joy, 0f);
         }
         if (key == XinputKey.Y)
         {
             target.ImmediatelySetValue(BlendShapePreset.Sorrow, 1f);
         }
         else
         {
             target.ImmediatelySetValue(BlendShapePreset.Sorrow, 0f);
         }
     });
 }
コード例 #3
0
        /// <summary>
        /// 表情変更 transition facial expression
        /// </summary>
        /// <param name="proxy">対象のblendshape      target blendshape</param>
        /// <param name="bs">表情の名前               name of facial expression</param>
        /// <param name="max">最大値                  maximum of parametor of facial expression</param>
        /// <param name="time1">最大まで行く時間      the time from start to maximum of facial expression</param>
        /// <param name="time2">最大でいる時間(累積)  the time from start to end of maximum of facial expression</param>
        /// <param name="time3">もとに戻る時間(累積)  the time of this transition</param>
        IEnumerator EmotionCoroutine(VRMBlendShapeProxy proxy, string bs, float max, float time1, float time2, float time3)
        {
            if (isRunning)
            {
                Debug.Log("break");
                yield break;
            }

            isRunning = true;
            float Parameter = 0;

            while (Parameter <= time1)
            {
                proxy.ImmediatelySetValue(bs, Mathf.Lerp(0, max, Parameter / time1));
                yield return(null);

                Parameter += Time.deltaTime;
            }
            Debug.Log("1");

            yield return(new WaitForSeconds(time2 - time1));

            Parameter = time2;
            Debug.Log("2");

            while (Parameter <= time3)
            {
                proxy.ImmediatelySetValue(bs, Mathf.Lerp(max, 0, (Parameter - time2) / (time3 - time2)));
                yield return(null);

                Parameter += Time.deltaTime;
            }
            Debug.Log("3");

            proxy.ImmediatelySetValue(bs, 0f);

            isRunning = false;
        }
コード例 #4
0
    void LateUpdate()
    {
        var total = 10.0f;

        w = total * GetWeight(nodeA);
        target.ImmediatelySetValue(BlendShapePreset.A, w);
        total -= w;

        w = total * GetWeight(nodeI);
        target.ImmediatelySetValue(BlendShapePreset.I, w);
        total -= w;

        w = total * GetWeight(nodeU);
        target.ImmediatelySetValue(BlendShapePreset.U, w);
        total -= w;

        w = total * GetWeight(nodeE);
        target.ImmediatelySetValue(BlendShapePreset.E, w);
        total -= w;

        w = total * GetWeight(nodeO);
        target.ImmediatelySetValue(BlendShapePreset.O, w);
    }
コード例 #5
0
    void UpdateFace(ARFaceAnchor anchorData)
    {
        var blendShapes = anchorData.blendShapes;

        if (blendShapes == null || blendShapes.Count == 0)
        {
            return;
        }
        //mouth shape
        proxy.ImmediatelySetValue(BlendShapePreset.O, NormalizationNumbers(blendShapes[ARBlendShapeLocation.JawOpen], 0.7f));
        proxy.ImmediatelySetValue(BlendShapePreset.I, NormalizationNumbers(blendShapes[ARBlendShapeLocation.JawForward], 0.7f));
        proxy.ImmediatelySetValue(BlendShapePreset.U, NormalizationNumbers(blendShapes[ARBlendShapeLocation.MouthPucker], 0.7f));
        //blink shape
        proxy.ImmediatelySetValue(BlendShapePreset.Blink_L, blendShapes[ARBlendShapeLocation.EyeBlinkLeft]);
        proxy.ImmediatelySetValue(BlendShapePreset.Blink_R, blendShapes[ARBlendShapeLocation.EyeBlinkRight]);
        //eyes shape
        Vector3 eyes_points = anchorData.lookAtPoint;

        if (eyes_points.y > 0.0f)
        {
            proxy.ImmediatelySetValue(BlendShapePreset.LookUp, eyes_points.y);
        }
        else
        {
            proxy.ImmediatelySetValue(BlendShapePreset.LookDown, Mathf.Abs(eyes_points.y));
        }

        if (eyes_points.x > 0.0f)
        {
            proxy.ImmediatelySetValue(BlendShapePreset.LookRight, eyes_points.x * 1.5f);
        }
        else
        {
            proxy.ImmediatelySetValue(BlendShapePreset.LookLeft, Mathf.Abs(eyes_points.x * 1.5f));
        }
    }
コード例 #6
0
ファイル: VRMSetup.cs プロジェクト: ryu8179/VMotion
        IEnumerator Setup(GameObject go)
        {
            go.transform.position = Vector3.zero;
            go.transform.rotation = Quaternion.identity;
            yield return(null);

            var lookAtHead = go.GetComponent <VRMLookAtHead>();

            lookAtHead.Target     = camera;
            lookAtHead.UpdateType = UpdateType.LateUpdate;
            var skins = go.GetComponentsInChildren <SkinnedMeshRenderer>();

            foreach (var skin in skins)
            {
                skin.updateWhenOffscreen = true;
            }
            var animator = go.GetComponent <Animator>();

            animator.runtimeAnimatorController = animatorController;
            blendshape = go.GetComponent <VRMBlendShapeProxy>();
            blendshape.ImmediatelySetValue(BlendShapePreset.Joy, 0.5f);
            var blink = go.AddComponent <AutoBlinkForVrm>();

            blink.VRM = blendshape;
            blink.blinkParameters.ratioClose = 0.5f;
            blink.blinkParameters.interval   = 0.9f;
            var source = DummyHead.GetComponent <AudioSource>();

            source.clip = clip;
            source.loop = true;
            source.Play();
            dummyBlendShape = DummyHead.GetComponent <SkinnedMeshRenderer>();
            //salsa.skinnedMeshRenderer = blendshape.BlendShapeAvatar.GetClip(BlendShapePreset.A).Values[0].RelativePath
            yield return(null);

            var boneName = go.GetComponent <VRMHumanoidDescription>().Description.human.Where(h => h.humanBone == HumanBodyBones.Head).First().boneName;
            var head     = go.transform.Traverse().Skip(1).Where(n => n.name == boneName).First();

            Debug.Log(head.name);
            Debug.Log("あたま: " + head.position);
            Debug.Log("カメラ: " + camera.position);
            camera.position = new Vector3(camera.position.x, camera.position.y, head.position.z + 1.7f);
        }
コード例 #7
0
        private async void Animate()
        {
            var elapsedTime = 0.0f;

            while (elapsedTime <= 0.5f)
            {
                elapsedTime += Time.deltaTime;
                var nextVal = (0.8f * Mathf.Sin(2 * Mathf.PI * 4 * elapsedTime) + 0.8f) / 2;
                blendShapeProxy.ImmediatelySetValue(BlendShapePreset.A, nextVal);
                await Task.Yield();
            }
            blendShapeProxy.ImmediatelySetValue(BlendShapePreset.A, 0);
            _animating = false;
        }
コード例 #8
0
        public void OnCallChangeFace(string str)
        {
            if (str == "default@unitychan")
            {
                proxy.ImmediatelySetValue(BlendShapePreset.Neutral, 1.0f);
                proxy.ImmediatelySetValue(BlendShapePreset.Angry, 0);
                proxy.ImmediatelySetValue(BlendShapePreset.Fun, 0);
                proxy.ImmediatelySetValue(BlendShapePreset.Blink, 0);
            }

            if (str == "conf@unitychan")
            {
                proxy.ImmediatelySetValue(BlendShapePreset.Angry, 1.0f);
            }
            if (str == "smile3@unitychan")
            {
                proxy.ImmediatelySetValue(BlendShapePreset.Fun, 1.0f);
            }
            if (str == "eye_close@unitychan")
            {
                proxy.ImmediatelySetValue(BlendShapePreset.Blink, 1.0f);
            }
        }
コード例 #9
0
ファイル: MotionController.cs プロジェクト: Mabushi1227/HackU
    /* リアクションを再生する関数 */
    IEnumerator Reaction()
    {
        //リアクション再生をしていない時のみ再生
        if (actionset)
        {
            //リアクションを再生中に変更
            actionset = false;
            process   = "playng";

            //ランダムで再生するリアクションを選択
            int _seed = Random.Range(1, actionLength + 1);

            //リアクションの再生
            anim.SetInteger("action", _seed);

            //パラメータ評価のための変数
            float tmpData;

            //リアクションの表情と競合しないために表情を設定
            MorphClean();

            //リアクションごとの設定
            switch (_seed)
            {
            case 1:
                tmpData = info.GetSlim();
                Proxy.ImmediatelySetValue(BlendShapePreset.Angry, 1.0f);
                comment = (tmpData > 0.5 ? "食事をしっかり取って!!\n身体は資本だよ!!": "私も連れてって!!");
                break;

            case 2:
                tmpData = info.GetBad();
                Proxy.ImmediatelySetValue("BAD", 1.0f);
                comment = (tmpData > 0.5 ? "栄養が偏ってる...\nバランスの良い食事を心がけて!!" : "うぅ どうして名古屋はこんなに暑いの...");
                break;

            case 3:
                tmpData = info.GetGood();
                Proxy.ImmediatelySetValue(BlendShapePreset.Fun, 1.0f);
                comment = (tmpData > 0.5 ? "いい感じだよ!!\n絶好調だね!!": "明日、晴れるかな??");
                break;

            case 4:
                tmpData = info.GetSleepy();
                Proxy.ImmediatelySetValue(BlendShapePreset.A, 1.0f);
                Proxy.ImmediatelySetValue(BlendShapePreset.Blink, 1.0f);
                comment = (tmpData > 0.5 ? "ふぁ〜、最近あんまり寝られてないね...\n今日は早く寝ない??": "ふぁ〜、眠くなってくる時間帯だね");
                break;

            case 5:
                tmpData = info.GetFat() - info.GetSlim();
                Proxy.ImmediatelySetValue(BlendShapePreset.A, 1.0f);
                Proxy.ImmediatelySetValue("SLEEPY", 0.5f);
                Proxy.ImmediatelySetValue("ZITO", 0.5f);
                comment = (tmpData > 0.5 ? "食べ過ぎ!!\nこのままだと危ないよ!!": "(...ここは、どこ??)");
                break;

            case 6:
                tmpData = info.GetFat();
                Proxy.ImmediatelySetValue(BlendShapePreset.Joy, 1.0f);
                comment = (tmpData > 0.5 ? "食べ過ぎじゃない?\n体重計乗ってみよ!!": "こんな日には外に出て見よう!!\nいいことあるよ!!");
                break;

            case 7:
                tmpData = info.GetGood() - info.GetBad() - info.GetSleepy();
                if (tmpData > 0.5)
                {
                    Proxy.ImmediatelySetValue("DOYA", 1.0f);
                    comment = "言うことなし!!君は完璧だよ";
                }
                else
                {
                    Proxy.ImmediatelySetValue(BlendShapePreset.O, 0.7f);
                    comment = "おーい、見えてますかー?";
                }
                break;

            default:                                    //エラー
                tmpData = info.GetFat();
                Proxy.ImmediatelySetValue(BlendShapePreset.Angry, 1.0f);
                comment = (tmpData > 0.5 ? "エラーかな??": "エラーっぽいね");
                break;
            }
        }
        else
        {
            //すでにリアクション再生中の時の処理
            process = "Please Wait";
        }
        // _interval秒まつ
        yield return(new WaitForSeconds(_interval));

        StartCoroutine("forIdle");
        MorphClean();
    }
コード例 #10
0
 void Update()
 {
     if (openSeeExpression == null || vrmBlendShapeProxy == null) {
         return;
     }
     vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Neutral), 0f);
     vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Fun), 0f);
     vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Sorrow), 0f);
     vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Angry), 0f);
     vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Joy), 0f);
     vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Blink_R), 0f);
     vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Blink_L), 0f);
     if (openSeeExpression.expression == expressionFun) {
         vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Fun), 1f);
         return;
     } else if (openSeeExpression.expression == expressionSorrow) {
         vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Sorrow), 1f);
         return;
     } else if (openSeeExpression.expression == expressionAngry) {
         vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Angry), 1f);
         return;
     } else if (openSeeExpression.expression == expressionJoy) {
         vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Joy), 1f);
         return;
     }
     vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Neutral), 1f);
 }
コード例 #11
0
    /// <summary>
    /// まばたき
    /// </summary>
    private void Blink()
    {
        if (!blendShapeProxy)
        {
            return;
        }

        float now = Time.timeSinceLevelLoad;
        float span;

        BlendShapeKey blinkShapeKey = BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink);

        // 表情が笑顔の時は目が閉じられるため、まばたきは無効とする
        if (EmotionPresets[emotionIndex] == BlendShapePreset.Joy)
        {
            blinkState = BlinkState.None;
            blendShapeProxy.ImmediatelySetValue(blinkShapeKey, 0f);
        }

        // まばたきの状態遷移
        switch (blinkState)
        {
        case BlinkState.Closing:
            span = now - lastBlinkTime;
            if (span > BlinkTime)
            {
                blinkState = BlinkState.Opening;
                blendShapeProxy.ImmediatelySetValue(blinkShapeKey, 1f);
            }
            else
            {
                blendShapeProxy.ImmediatelySetValue(blinkShapeKey, (span / BlinkTime));
            }
            break;

        case BlinkState.Opening:
            span = now - lastBlinkTime - BlinkTime;
            if (span > BlinkTime)
            {
                blinkState = BlinkState.None;
                blendShapeProxy.ImmediatelySetValue(blinkShapeKey, 0f);
            }
            else
            {
                blendShapeProxy.ImmediatelySetValue(blinkShapeKey, (1f - span) / BlinkTime);
            }
            break;

        default:
            if (now >= nextBlinkTime)
            {
                lastBlinkTime = now;
                if (Random.value < 0.2f)
                {
                    nextBlinkTime = now;        // 20%の確率で連続まばたき
                }
                else
                {
                    nextBlinkTime = now + Random.Range(1f, 10f);
                }
                blinkState = BlinkState.Closing;
            }
            break;
        }
    }
コード例 #12
0
        private void Clear(KeyCode exclude)
        {
            _proxy.ImmediatelySetValue(BlendShapePreset.Neutral, 0.0f);
            _proxy.ImmediatelySetValue(BlendShapePreset.A, 0.0f);
            _proxy.ImmediatelySetValue(BlendShapePreset.A, 0.0f);
            _proxy.ImmediatelySetValue(BlendShapePreset.I, 0.0f);
            _proxy.ImmediatelySetValue(BlendShapePreset.U, 0.0f);
            _proxy.ImmediatelySetValue(BlendShapePreset.E, 0.0f);
            _proxy.ImmediatelySetValue(BlendShapePreset.O, 0.0f);
            _proxy.ImmediatelySetValue(BlendShapePreset.Blink, 0.0f);
            _proxy.ImmediatelySetValue(BlendShapePreset.Blink_L, 0.0f);
            _proxy.ImmediatelySetValue(BlendShapePreset.Blink_R, 0.0f);
            _proxy.ImmediatelySetValue(BlendShapePreset.Angry, 0.0f);
            _proxy.ImmediatelySetValue(BlendShapePreset.Joy, 0.0f);
            _proxy.ImmediatelySetValue(BlendShapePreset.Fun, 0.0f);
            _proxy.ImmediatelySetValue("Surprised", 0.0f);
            _proxy.ImmediatelySetValue("Extra", 0.0f);

            var keyList = new List <KeyCode>(_keyActive.Keys);

            foreach (var key in keyList)
            {
                if (key == exclude)
                {
                    continue;
                }
                _keyActive[key] = false;
            }
        }
コード例 #13
0
        void OnGUI()
        {
            if (!Application.isEditor || !enablePreview)
            {
                return;
            }
            if (!hadEnabled)
            {
                hadEnabled = true;
                EnablePreview();
                return;
            }

            bool clicked = false;

            scrollViewVector = GUI.BeginScrollView(new Rect(0, 0, 116, Screen.height), scrollViewVector, new Rect(0, 0, 100, proxy.BlendShapeAvatar.Clips.Count * 23 + 23));
            if (GUI.Button(new Rect(0, 0, 100, 22), "[Hide]"))
            {
                enablePreview = false;
                hadEnabled    = false;
                return;
            }
            int k = 1;

            foreach (var values in proxy.GetValues())
            {
                if (GUI.Button(new Rect(0, 23 * k, 100, 22), values.Key.Name))
                {
                    currentExpression = values.Key.Name;
                    blendShapeKey     = values.Key;
                    clicked           = true;
                }
                k++;
            }
            GUI.EndScrollView();

            if (clicked)
            {
                foreach (var values in proxy.GetValues())
                {
                    if (blendShapeKey.Name.ToUpper() == values.Key.Name.ToUpper())
                    {
                        proxy.ImmediatelySetValue(values.Key, 1f);
                    }
                    else
                    {
                        proxy.ImmediatelySetValue(values.Key, 0f);
                    }
                }
                mixer.SetInputWeight(0, 1);
                for (int i = 0; i < animations.Length; i++)
                {
                    if (animations[i].blendshapeName.ToUpper() == currentExpression.ToUpper())
                    {
                        if (toGraph[i] > -1)
                        {
                            mixer.SetInputWeight(toGraph[i], 1);
                            mixer.GetInput(toGraph[i]).SetTime(0);
                        }
                        if (animations[i].animation != null && animations[i].animation.humanMotion)
                        {
                            mixer.SetInputWeight(0, 0);
                        }
                    }
                    else
                    {
                        if (toGraph[i] > -1)
                        {
                            mixer.SetInputWeight(toGraph[i], 0);
                        }
                    }
                }
            }
        }
コード例 #14
0
        void Update()
        {
            if (openSeeExpression == null || vrmBlendShapeProxy == null)
            {
                return;
            }
            float rightEyeOpen = 1f;
            float leftEyeOpen  = 1f;

            if (openSee != null)
            {
                var openSeeData = openSee.trackingData;
                if (openSeeData == null || openSeeData.Length < 1)
                {
                    return;
                }
                int idx = -1;
                int i   = 0;
                foreach (var item in openSeeData)
                {
                    if (item.id == openSeeExpression.faceId)
                    {
                        idx = i;
                    }
                    i++;
                }
                if (idx > -1)
                {
                    rightEyeOpen = openSeeData[idx].rightEyeOpen;
                    leftEyeOpen  = openSeeData[idx].leftEyeOpen;
                }
            }
            vrmBlendShapeProxy.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Neutral), 0f);
            vrmBlendShapeProxy.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Fun), 0f);
            vrmBlendShapeProxy.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Sorrow), 0f);
            vrmBlendShapeProxy.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Angry), 0f);
            vrmBlendShapeProxy.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Joy), 0f);
            vrmBlendShapeProxy.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink_R), 0f);
            vrmBlendShapeProxy.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink_L), 0f);
            if (openSeeExpression.expression == expressionFun)
            {
                vrmBlendShapeProxy.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Fun), 1f);
                return;
            }
            else if (openSeeExpression.expression == expressionSorrow)
            {
                vrmBlendShapeProxy.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Sorrow), 1f);
                return;
            }
            else if (openSeeExpression.expression == expressionAngry)
            {
                vrmBlendShapeProxy.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Angry), 1f);
                return;
            }
            else if (openSeeExpression.expression == expressionJoy)
            {
                vrmBlendShapeProxy.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Joy), 1f);
                return;
            }
            else
            {
                /*if (rightEyeOpen < 0.05) {
                 *  vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Blink_R), 1f);
                 * }
                 * if (leftEyeOpen < 0.05) {
                 *  vrmBlendShapeProxy.ImmediatelySetValue(new BlendShapeKey(BlendShapePreset.Blink_L), 1f);
                 * }*/
            }
            vrmBlendShapeProxy.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Neutral), 1f);
        }
コード例 #15
0
    void ApplyVisemes()
    {
        if (vrmBlendShapeProxy == null || catsData == null)
        {
            return;
        }
        float expressionFactor = 1f;

        if (currentExpression != null)
        {
            expressionFactor = currentExpression.visemeFactor;
        }
        if (currentExpression != null && !currentExpression.enableVisemes)
        {
            for (int i = 0; i < 5; i++)
            {
                vrmBlendShapeProxy.ImmediatelySetValue(visemePresetMap[i], 0f);
            }
            return;
        }
        float weight;

        OVRLipSync.Viseme current = GetActiveViseme(out weight);
        weight = Mathf.Clamp(weight * 1.5f, 0f, 1f);
        float[] values = catsData[current];
        for (int i = 0; i < 5; i++)
        {
            vrmBlendShapeProxy.ImmediatelySetValue(visemePresetMap[i], values[i] * visemeFactor * expressionFactor * weight);
        }
    }
コード例 #16
0
        void Update()
        {
            if (body == null)
            {
                return;
            }

            if (!proxy)
            {
                proxy = tracking.model.gameObject.GetComponent <VRMBlendShapeProxy>();
            }
            else
            {
                proxy.ImmediatelySetValue(BlendShapePreset.Blink_L, tracking.LeftEyeCloseness);
                proxy.ImmediatelySetValue(BlendShapePreset.Blink_R, tracking.RightEyeCloseness);
            }

            transform.position         = tracking.Position;
            transform.rotation         = tracking.Rotation;
            left_eye.localEulerAngles  = tracking.LeftEyeRotation;
            right_eye.localEulerAngles = tracking.RightEyeRotation;

            tmp   = body.Position;
            tmp.y = 0;
            Position.localPosition = tmp;
            tmp   = Vector3.zero;
            tmp.y = body.Position.y;
            Bip_C_Hips.localPosition = tmp;
            Bip_C_Hips.rotation      = body.Rotation[0];
            if (tracking.IsSuccess)
            {
                switch (tracking.mode)
                {
                case DetectMode.Dlib5:
                    var     local = (body.Rotation[1] * Quaternion.Inverse(body.Rotation[0])).eulerAngles;
                    Vector3 rot   = default;
                    if (Mathf.Abs(local.x) < 90 && Mathf.Abs(local.y) < 90 && Mathf.Abs(local.z) < 90)
                    {
                        rot = body.Rotation[1].eulerAngles;
                    }

                    rot.z = tracking.Rotation.eulerAngles.z;
                    Bip_C_Head.rotation = Quaternion.Euler(rot);
                    break;

                case DetectMode.Dlib68:
                case DetectMode.Mixed:
                    Bip_C_Head.rotation = tracking.Rotation;
                    break;
                }
                Bip_C_Head.rotation = tracking.Rotation;
            }
            else
            {
                var local = (body.Rotation[1] * Quaternion.Inverse(body.Rotation[0])).eulerAngles;
                if (Mathf.Abs(local.x) < 90 && Mathf.Abs(local.y) < 90 && Mathf.Abs(local.z) < 90)
                {
                    Bip_C_Head.rotation = body.Rotation[1];
                }
            }

            Bip_R_UpperArm.rotation = body.Rotation[2];
            Bip_L_UpperArm.rotation = body.Rotation[3];
            Bip_R_LowerArm.rotation = body.Rotation[4];
            Bip_L_LowerArm.rotation = body.Rotation[5];
            Bip_R_UpperLeg.rotation = body.Rotation[6];
            Bip_L_UpperLeg.rotation = body.Rotation[7];
            Bip_R_LowerLeg.rotation = body.Rotation[8];
            Bip_L_LowerLeg.rotation = body.Rotation[9];
        }
コード例 #17
0
 // click button
 public void sad_button()
 {
     RestBlendShape();
     proxy.ImmediatelySetValue(BlendShapePreset.Sorrow, 1.0f);
 }
コード例 #18
0
        void Update()
        {
            if (!proxy)
            {
                proxy = GetComponent <VRMBlendShapeProxy>();
            }

            anim.ResetTrigger("bow");            ///アニメーションの予約状態を防止
            anim.ResetTrigger("suprize");        ///prevent reservation of animation
            anim.ResetTrigger("kubi");
            anim.ResetTrigger("by");

            ///アニメーションボタン      button animation sets
            ///<animation>座る・立つ     sit or stand</animation>
            ///<key>return</key>
            if (Input.GetKeyDown("return"))
            {
                if (anim.GetBool("sit") == true)
                {
                    anim.SetBool("sit", false);
                    chair.SetActive(false);
                }
                else
                {
                    anim.SetBool("sit", true);
                    chair.SetActive(true);
                }
            }

            if (!Input.GetKey(KeyCode.LeftShift))
            {
                ///<animation>お辞儀    bow</animation>
                ///<key>1(Alpha1)</key>
                if (Input.GetKeyDown(KeyCode.Alpha1))
                {
                    if (anim.GetCurrentAnimatorStateInfo(0).IsName("wait"))
                    {
                        anim.SetTrigger("bow");
                        Debug.Log("bow");
                        Invoke("Bow", 2f);
                    }
                }
                ///<animation>驚く    suprized</animation>
                ///<key>2(Alpha2)</key>
                if (Input.GetKeyDown(KeyCode.Alpha2))
                {
                    anim.SetTrigger("suprize");
                    StartCoroutine(EmotionCoroutine(proxy, "SUPRISED", 0.8f, 0.05f, 0.2f, 0.25f));
                    Debug.Log("suprize");
                }
                ///<animation>首をかしげる    put one's head on one side</animation>
                ///<key>3(Alpha3)</key>
                if (Input.GetKeyDown(KeyCode.Alpha3))
                {
                    anim.SetTrigger("kubi");
                    StartCoroutine(EmotionCoroutine(proxy, "SMILE2", 0.5f, 0.5f, 1f, 1.5f));
                    Debug.Log("kubi");
                }
                ///<animation>手を振る    swing hand</animation>
                ///<key>0(Alpha0)</key>
                if (Input.GetKeyDown(KeyCode.Alpha0))
                {
                    if (anim.GetCurrentAnimatorStateInfo(0).IsName("wait2"))
                    {
                        anim.SetTrigger("by");
                        StartCoroutine(EmotionCoroutine(proxy, "SMILE1", 0.7f, 0.8f, 2.2f, 2.8f));
                        Debug.Log("goodby");
                    }
                }
            }

            ///マウスでのほほえみ操作  controle of smille by mouse
            proxy.ImmediatelySetValue("FUN2", Input.GetAxis("Fire1") * 2 / 3);
        }
コード例 #19
0
    void Update()
    {
        float vol = GetVolume();

        BlendShapeProxy.ImmediatelySetValue(A, SmoothMouth.SmoothValue(vol < 1 ? 0 : vol / 20));
    }