예제 #1
0
        public void KeyTest()
        {
            var key = CreateBlendShapeKey("Blink", BlendShapePreset.Blink);

            Assert.AreEqual(key, CreateBlendShapeKey("Blink", BlendShapePreset.Blink));
            Assert.AreEqual(key, BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink));
            Assert.AreEqual(key, CreateBlendShapeKey("xxx", BlendShapePreset.Blink));

            var dict = new Dictionary <BlendShapeKey, float>();

            dict[key] = 1.0f;

            Assert.IsTrue(dict.ContainsKey(CreateBlendShapeKey("Blink", BlendShapePreset.Blink)));
            Assert.IsTrue(dict.ContainsKey(BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink)));
            Assert.IsTrue(dict.ContainsKey(CreateBlendShapeKey("xxx", BlendShapePreset.Blink)));

            dict.Clear();

            var key2 = BlendShapeKey.CreateUnknown("Blink"); // name: Blink, Preset: Unknown

            dict[key2] = 1.0f;

            Assert.AreEqual(key2, CreateBlendShapeKey("Blink", BlendShapePreset.Unknown));
            Assert.AreNotEqual(key2, BlendShapeKey.CreateUnknown("blink"));
            Assert.AreNotEqual(key2, CreateBlendShapeKey("Blink", BlendShapePreset.Blink));
            Assert.AreNotEqual(key2, BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink));

            Assert.IsFalse(dict.ContainsKey(BlendShapeKey.CreateUnknown("blink")));
            Assert.IsFalse(dict.ContainsKey(CreateBlendShapeKey("Blink", BlendShapePreset.Blink)));
            Assert.IsFalse(dict.ContainsKey(BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink)));
        }
예제 #2
0
 public static void SetValue(this VRMBlendShapeProxy proxy, BlendShapePreset key, float value, bool apply)
 {
     if (apply)
     {
         proxy.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(key), value);
     }
     else
     {
         proxy.AccumulateValue(BlendShapeKey.CreateFromPreset(key), value);
     }
 }
예제 #3
0
파일: Blinker.cs 프로젝트: vrm-c/UniVRM
        IEnumerator BlinkRoutine()
        {
            while (true)
            {
                var waitTime = Time.time + Random.value * Interval;
                while (waitTime > Time.time)
                {
                    if (Request)
                    {
                        m_request = false;
                        break;
                    }
                    yield return(null);
                }

                // close
                var value      = 0.0f;
                var closeSpeed = 1.0f / CloseSeconds;
                while (true)
                {
                    value += Time.deltaTime * closeSpeed;
                    if (value >= 1.0f)
                    {
                        break;
                    }

                    m_blendShapes.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink), value);
                    yield return(null);
                }
                m_blendShapes.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink), 1.0f);

                // wait...
                yield return(new WaitForSeconds(ClosingTime));

                // open
                value = 1.0f;
                var openSpeed = 1.0f / OpeningSeconds;
                while (true)
                {
                    value -= Time.deltaTime * openSpeed;
                    if (value < 0)
                    {
                        break;
                    }

                    m_blendShapes.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink), value);
                    yield return(null);
                }
                m_blendShapes.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(BlendShapePreset.Blink), 0);
            }
        }
예제 #4
0
 public BlendShapeClip GetClip(BlendShapePreset preset)
 {
     return(GetClip(BlendShapeKey.CreateFromPreset(preset)));
 }
예제 #5
0
 public static void AccumulateValue(this VRMBlendShapeProxy proxy, BlendShapePreset key, float value)
 {
     proxy.AccumulateValue(BlendShapeKey.CreateFromPreset(key), value);
 }
예제 #6
0
 public static void ImmediatelySetValue(this VRMBlendShapeProxy proxy, BlendShapePreset key, float value)
 {
     proxy.ImmediatelySetValue(BlendShapeKey.CreateFromPreset(key), value);
 }
예제 #7
0
 public static float GetValue(this VRMBlendShapeProxy proxy, BlendShapePreset key)
 {
     return(proxy.GetValue(BlendShapeKey.CreateFromPreset(key)));
 }