Ejemplo n.º 1
0
 public Skeleton(int boneCount)
 {
     Bones           = new List <SkeletalBone>(boneCount);
     Identity        = new SkeletalPose(boneCount, Matrix4.Identity);
     BindPose        = new SkeletalPose(boneCount);
     InverseBindPose = new SkeletalPose(boneCount);
 }
        public override void AddPose(Pose pose)
        {
            Poses.Add(pose);

            // precompute the matrix for each joint for each animation frame
            SkeletalPose p = pose as SkeletalPose;
            SkeletalPose calculatedPose = new SkeletalPose(p.MatrixArray.Length);

            // multiply each animation joint matrix by its relevant inverse bind pose joint matrix
            for (int i = 0; i < calculatedPose.MatrixArray.Length; i++)
            {
                calculatedPose[i] = Skeleton.InverseBindPose[i] * p[i];
            }

            posePoses.Add(pose.Name, calculatedPose);
        }
        public override void AddAnimation(Animation animation)
        {
            Animations.Add(animation);

            // precompute the matrix for each joint for each animation frame
            List <SkeletalPose> poses = new List <SkeletalPose>();

            foreach (var a in animation.Frames)
            {
                SkeletalPose f    = a as SkeletalPose;
                SkeletalPose pose = new SkeletalPose(f.MatrixArray.Length);

                // multiply each animation joint matrix by its relevant inverse bind pose joint matrix
                for (int i = 0; i < f.MatrixArray.Length; i++)
                {
                    pose[i] = Skeleton.InverseBindPose[i] * f[i];
                }

                poses.Add(pose);
            }

            animationPoses.Add(animation.Name, poses);
        }