Ejemplo n.º 1
0
        /// <summary>
        /// Try to make a simple controller of animation from inst named "name". If that's
        /// not found, try "backup". Will return null if neither is found.
        /// </summary>
        /// <param name="inst"></param>
        /// <param name="name"></param>
        /// <param name="backup"></param>
        /// <returns></returns>
        public static SimpleController TryMake(AnimationInstance inst, string name, string backup)
        {
            Animation anim = inst.FindAnimation(name);

            if ((anim == null) && (backup != null))
            {
                anim = inst.FindAnimation(backup);
            }

            return(anim != null ? new SimpleController(inst, anim) : null);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Compute the localToParent values we know about, leaving the rest alone.
        /// localToParent has already been populated with default values.
        /// </summary>
        /// <param name="inst"></param>
        /// <param name="localToParent"></param>
        internal override void GetTransforms(AnimationInstance inst, Matrix[] localToParent)
        {
            Animation animation = inst.FindAnimation(animName);

            Debug.Assert(Weight > 0);
            if (animation != null)
            {
                BoneKeys[] keyList = animation.KeysList;

                int keyIdx = keyList[0].IndexAtTime(CurrentTicks);
                for (int i = 0; i < keyList.Length; ++i)
                {
                    int boneIdx = animation.KeyIndexToBoneIndex(i);
                    localToParent[boneIdx] = keyList[i].AtIndex(keyIdx);
                }
            }
        }