Пример #1
0
        public AnimationHandle RunAnimation(Avatar avatar, Animation animation)
        {
            var instance = new AnimationHandle(this);
            instance.Animation = animation;
            instance.Avatar = avatar;

            Animations.Add(instance);
            return instance;
        }
Пример #2
0
        public static AnimationStatus RenderFrame(Avatar avatar, Animation animation, uint frame)
        {
            var numDone = 0;

            foreach (var motion in animation.Motions)
            {
                var bone = avatar.Skeleton.GetBone(motion.BoneName);
                var motionFrame = frame;
                if (frame >= motion.FrameCount)
                {
                    numDone++;
                    motionFrame = (uint)motion.FrameCount - 1;
                }

                if (motion.HasTranslation)
                {
                    bone.Translation = animation.Translations[motion.FirstTranslationIndex + motionFrame];
                }
                if (motion.HasRotation)
                {
                    bone.Rotation = animation.Rotations[motion.FirstRotationIndex + motionFrame];
                }
            }

            avatar.ReloadSkeleton();
            if (numDone == animation.Motions.Length)
            {
                return AnimationStatus.COMPLETED;
            }
            else
            {
                return AnimationStatus.IN_PROGRESS;
            }
        }