ReloadSkeleton() public method

When the skeleton changes (for example due to an animation) this method will recompute the meshes to adhere to the new skeleton positions.
public ReloadSkeleton ( ) : void
return void
Ejemplo n.º 1
0
        public void Update(GameTime time)
        {
            var now = time.ElapsedGameTime.Milliseconds;

            if (this.Status == AnimationStatus.WAITING_TO_START)
            {
                StartTime   = now;
                this.Status = AnimationStatus.IN_PROGRESS;
            }

            var fps  = 30.0f * Speed;
            var fpms = fps / 1000;

            var  runTime  = now - StartTime;
            uint frame    = (uint)(runTime * fpms);
            var  fraction = (runTime * fpms) - frame;

            int numDone = 0;

            /** Speed is 30fps by default **/
            foreach (var motion in Animation.Motions)
            {
                var bone        = Avatar.Skeleton.GetBone(motion.BoneName);
                var motionFrame = frame;
                if (frame >= motion.FrameCount)
                {
                    numDone++;
                    motionFrame = motion.FrameCount - 1;
                }

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

            if (numDone == Animation.Motions.Length)
            {
                /** Completed! **/
                this.Status = AnimationStatus.COMPLETED;
            }
            else
            {
                Avatar.ReloadSkeleton();
            }
        }