Exemplo n.º 1
0
 private void UpdateSkeleton()
 {
     this.trunk           = new TreeMesh(device, skeleton);
     this.leaves          = new TreeLeafCloud(device, skeleton);
     this.animationState  = new TreeAnimationState(skeleton);
     this.bindingMatrices = new Matrix[skeleton.Bones.Count];
 }
        /// <summary>
        /// Interpolates between two animation states and stores the result in a third state.
        /// </summary>
        /// <param name="state1">The first animation state.</param>
        /// <param name="state2">The second animation state.</param>
        /// <param name="destinationState">Where to store the interpolated result. This may be the same as either of the two input states.</param>
        /// <param name="f">Interpolation factor, between 0 and 1. 0 weights towards the first state, and 1 weights towards the second state.</param>
        /// <remarks>The three animation states must have the same number of bones.</remarks>
        public static void Interpolate(TreeAnimationState state1, TreeAnimationState state2, TreeAnimationState destinationState, float f)
        {
            if (state1.BoneRotations.Length != state2.BoneRotations.Length || state1.BoneRotations.Length != destinationState.BoneRotations.Length)
                throw new ArgumentException("All three animation states must have the same number of bones");

            if (f < 0.0f || f > 1.0f)
                throw new ArgumentException("Interpolation factor must be between 0 and 1.", "f");

            for (int i = 0; i < destinationState.BoneRotations.Length; i++)
            {
                destinationState.BoneRotations[i] = Quaternion.Slerp(state1.BoneRotations[i], state2.BoneRotations[i], f);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Interpolates between two animation states and stores the result in a third state.
        /// </summary>
        /// <param name="state1">The first animation state.</param>
        /// <param name="state2">The second animation state.</param>
        /// <param name="destinationState">Where to store the interpolated result. This may be the same as either of the two input states.</param>
        /// <param name="f">Interpolation factor, between 0 and 1. 0 weights towards the first state, and 1 weights towards the second state.</param>
        /// <remarks>The three animation states must have the same number of bones.</remarks>
        public static void Interpolate(TreeAnimationState state1, TreeAnimationState state2, TreeAnimationState destinationState, float f)
        {
            if (state1.BoneRotations.Length != state2.BoneRotations.Length || state1.BoneRotations.Length != destinationState.BoneRotations.Length)
            {
                throw new ArgumentException("All three animation states must have the same number of bones");
            }

            if (f < 0.0f || f > 1.0f)
            {
                throw new ArgumentException("Interpolation factor must be between 0 and 1.", "f");
            }

            for (int i = 0; i < destinationState.BoneRotations.Length; i++)
            {
                destinationState.BoneRotations[i] = Quaternion.Slerp(state1.BoneRotations[i], state2.BoneRotations[i], f);
            }
        }
 private void UpdateSkeleton()
 {
     Trunk = new TreeMesh(device, skeleton);
     Leaves = new TreeLeafCloud(device, skeleton);
     animationState = new TreeAnimationState(skeleton);
     BindingMatrices = new Matrix[skeleton.Bones.Count];
 }