Ejemplo n.º 1
0
        private void SetAnimation(VObject _obj, string _key)
        {
            _obj.SetNextAnimation(string.Empty, true);

            if (!_obj.FrameSetList.ContainsKey(_key))
                return;

            if (_obj.PickNode != null)
            {
                _obj.PickNode.Position = new Vector3D(0, 0, 0);
                _obj.PickNode.Scale = new Vector3D(1, 1, 1);
            }

            bool loopFlag = true;
            JointUpdateOnRenderMode jointMode = JointUpdateOnRenderMode.Control;
            switch (_key)
            {
                case "sitstart":
                    _obj.SetNextAnimation("sitting", true);
                    if (_obj.PickNode != null)
                    {
                        _obj.PickNode.Position = new Vector3D(-0.35f, 0.1f, 0);
                        _obj.PickNode.Scale = new Vector3D(1, 0.75f, 1);
                    }
                    loopFlag = false;
                    jointMode = JointUpdateOnRenderMode.None;
                    break;

                case UtilityAnimation.ANIMATION_KEY_SPEAK_SITTING:
                    _obj.SetNextAnimation(UtilityAnimation.ANIMATION_KEY_SPEAK_SITTING_END, false);
                    break;
                case UtilityAnimation.ANIMATION_KEY_SPEAK_SITTING_END:
                    _obj.SetNextAnimation(UtilityAnimation.ANIMATION_KEY_SITTING, true);
                    loopFlag = false;
                    break;
                case UtilityAnimation.ANIMATION_KEY_SPEAK_STANDING:
                    _obj.SetNextAnimation(UtilityAnimation.ANIMATION_KEY_SPEAK_STANDING_END, false);
                    break;
                case UtilityAnimation.ANIMATION_KEY_SPEAK_STANDING_END:
                    _obj.SetNextAnimation(UtilityAnimation.ANIMATION_KEY_STANDING, true);
                     loopFlag = false;
                     break;

                default:
                    _obj.CurrentAnimationUUID = new UUID();
                    break;
            }

            if (_key.StartsWith("customize"))
            {
                int animNo = int.Parse(_key.Substring(9));
                _obj.CurrentAnimationUUID = UtilityAnimation.CUSTOM_ANIMATIONS[animNo];
                loopFlag = false;
            }

            int startFrame = _obj.FrameSetList[_key].StartFrame;
            int endFrame = _obj.FrameSetList[_key].EndFrame;
            int animFramesPerSecond = _obj.FrameSetList[_key].AnimationSpeed;

            _obj.AnimationCurrentName = _key;
            _obj.AnimationSpeed = animFramesPerSecond;
            _obj.SetAnimationMode(jointMode);
            _obj.SetAnimation(_key, startFrame, endFrame, loopFlag);
        }