Пример #1
0
    public void ChangeIdle(Global.Emotion emotion)
    {
        switch (character.name)
        {
        case Global.david:
            if (emotion == Global.Emotion.ANGRY)
            {
                idleList = Global.davidAngryGestures;
            }
            else if (emotion == Global.Emotion.BORED)
            {
                idleList = Global.davidBoredGestures;
            }
            else if (emotion == Global.Emotion.CONTENT)
            {
                idleList = Global.davidContentGestures;
            }
            else if (emotion == Global.Emotion.HAPPY)
            {
                idleList = Global.davidHappyGestures;
            }
            break;

        case Global.luna:
            if (emotion == Global.Emotion.ANGRY)
            {
                idleList = Global.lunaAngryGestures;
            }
            else if (emotion == Global.Emotion.BORED)
            {
                idleList = Global.lunaBoredGestures;
            }
            else if (emotion == Global.Emotion.CONTENT)
            {
                idleList = Global.lunaContentGestures;
            }
            else if (emotion == Global.Emotion.HAPPY)
            {
                idleList = Global.lunaHappyGestures;
            }
            break;

        default:
            idleList = null;
            break;
        }
    }
Пример #2
0
 public void SetExpression(Global.Emotion type, int strength = 100)
 {
     Debug.Assert(strength >= 0 && strength <= 100, "strength should be in range 0 to 100");
     if (type == Global.Emotion.ANGRY)
     {
         facialControl.SetAngry(strength);
     }
     else if (type == Global.Emotion.BORED)
     {
         facialControl.SetBored(strength);
     }
     else if (type == Global.Emotion.CONTENT)
     {
         facialControl.SetContent(strength);
     }
     else if (type == Global.Emotion.HAPPY)
     {
         facialControl.SetHappy(strength);
     }
 }
Пример #3
0
    // Trigger event based on event name and event attribute+value
    private void TriggerEvent(string eventName)
    {
        if (eventName == "gesture")
        {
            float  speed = 1.0f, blend = 0.15f;
            int    strength = 100;
            string type     = "neutral";

            // Required
            int poseIndex = int.Parse(root.ChildNodes.Item(action).Attributes["pose"].Value);
            // Optional
            if (root.ChildNodes.Item(action).Attributes["speed"] != null)
            {
                speed = float.Parse(root.ChildNodes.Item(action).Attributes["speed"].Value);
            }
            if (root.ChildNodes.Item(action).Attributes["blend"] != null)
            {
                blend = float.Parse(root.ChildNodes.Item(action).Attributes["blend"].Value);
            }
            if (root.ChildNodes.Item(action).Attributes["offset"] != null)
            {
                type = root.ChildNodes.Item(action).Attributes["offset"].Value;
            }
            if (root.ChildNodes.Item(action).Attributes["strength"] != null)
            {
                strength = int.Parse(root.ChildNodes.Item(action).Attributes["strength"].Value);
            }

            //
            Global.BodyOffset offsetType = Global.BodyOffset.NEUTRAL;
            if (type == "forward")
            {
                offsetType = Global.BodyOffset.FORWARD;
            }
            else if (type == "backward")
            {
                offsetType = Global.BodyOffset.BACKWARD;
            }
            else if (type == "inward")
            {
                offsetType = Global.BodyOffset.INWARD;
            }
            else if (type == "outward")
            {
                offsetType = Global.BodyOffset.OUTWARD;
            }

            currentEvent.ChangePose(poseIndex, speed, blend);
            currentEvent.CharacterOffset(offsetType, strength);
        }

        if (eventName == "facial")
        {
            int strength = 100;

            // Required
            string emotion = root.ChildNodes.Item(action).Attributes["emotion"].Value;
            // Optional
            if (root.ChildNodes.Item(action).Attributes["strength"] != null)
            {
                strength = int.Parse(root.ChildNodes.Item(action).Attributes["strength"].Value);
            }

            //
            Global.Emotion emotionType = Global.Emotion.CONTENT;
            if (emotion == "angry")
            {
                emotionType = Global.Emotion.ANGRY;
            }
            else if (emotion == "bored")
            {
                emotionType = Global.Emotion.BORED;
            }
            else if (emotion == "content")
            {
                emotionType = Global.Emotion.CONTENT;
            }
            else if (emotion == "happy")
            {
                emotionType = Global.Emotion.HAPPY;
            }

            currentEvent.SetExpression(emotionType, strength);
        }

        if (eventName == "hand")
        {
            // Required
            string side  = root.ChildNodes.Item(action).Attributes["side"].Value;
            string shape = root.ChildNodes.Item(action).Attributes["shape"].Value;

            //
            Global.Side sideType = Global.Side.BOTH;
            if (side == "L")
            {
                sideType = Global.Side.LEFT;
            }
            else if (side == "R")
            {
                sideType = Global.Side.RIGHT;
            }

            Global.HandPose handType = Global.HandPose.RELAX;
            if (shape == "relax")
            {
                handType = Global.HandPose.RELAX;
            }
            else if (shape == "palm")
            {
                handType = Global.HandPose.PALM;
            }
            else if (shape == "fist")
            {
                handType = Global.HandPose.FIST;
            }

            currentEvent.SetHandShape(sideType, handType);
        }

        if (eventName == "foot")
        {
            // Required
            string status = root.ChildNodes.Item(action).Attributes["status"].Value;
            //
            if (status == "lock")
            {
                currentEvent.LockFoot(true);
            }
            else
            {
                currentEvent.LockFoot(false);
            }
        }

        if (eventName == "request")
        {
            string message = "";
            // Optional
            if (root.ChildNodes.Item(action).Attributes["message"] != null)
            {
                message = root.ChildNodes.Item(action).Attributes["message"].Value;
            }

            currentEvent.CheckSignal();
        }

        if (eventName == "slide")
        {
            int step = 1;
            // Required
            string direction = root.ChildNodes.Item(action).Attributes["direction"].Value;
            // Optional
            if (root.ChildNodes.Item(action).Attributes["step"] != null)
            {
                step = int.Parse(root.ChildNodes.Item(action).Attributes["step"].Value);
            }

            //
            Global.Direction directionType = Global.Direction.NEXT;
            if (direction == "back")
            {
                directionType = Global.Direction.BACK;
            }

            currentEvent.ChangeSlide(directionType, step);
            currentEvent.ChangeAudio(directionType, step);
        }
    }