예제 #1
0
        public override Matrix[] GetBoneTransforms()
        {
            Matrix[] child1Transforms = child1.GetBoneTransforms();
            Matrix[] child2Transforms = child2.GetBoneTransforms();
            Matrix[] child3Transforms = child2.GetBoneTransforms();

            Matrix[] blendedTransforms = new Matrix[child1Transforms.Length];

            Vector3    scale1;
            Quaternion rot1;
            Vector3    pos1;
            Vector3    scale2;
            Quaternion rot2;
            Vector3    pos2;
            Vector3    scale3;
            Quaternion rot3;
            Vector3    pos3;

            Vector3 bc = SpaceUtils.GetBarycentricCoords(Child1Position, Child2Position, Child3Position, BlendPosition);

            for (int p = 0; p < child1Transforms.Length; p++)
            {
                child1Transforms[p].Decompose(out scale1, out rot1, out pos1);
                child2Transforms[p].Decompose(out scale2, out rot2, out pos2);
                child3Transforms[p].Decompose(out scale3, out rot3, out pos3);
                blendedTransforms[p] = Matrix.CreateScale(scale1 * bc.X + scale2 * bc.Y + scale3 * bc.Z) *
                                       Matrix.CreateFromQuaternion(Quaternion.Normalize(rot1 * bc.X + rot2 * bc.Y + rot3 * bc.Z)) *
                                       Matrix.CreateTranslation(pos1 * bc.X + pos2 * bc.Y + pos3 * bc.Z);
            }

            return(blendedTransforms);
        }
예제 #2
0
        public override Matrix[] GetBoneTransforms()
        {
            foreach (TernaryLerpBlendNode tri in Triangulation)
            {
                Vector3 bc = SpaceUtils.GetBarycentricCoords(tri.Child1Position, tri.Child2Position, tri.Child3Position, BlendPosition);
                if (bc.X >= 0.0f && bc.Y >= 0.0f && bc.Z >= 0.0f)
                {
                    return(tri.GetBoneTransforms());
                }
            }

            throw new InvalidOperationException("The triangulation does not contain the BlendPosition point");
        }