Esempio n. 1
0
        public void Merge(ActorBehavior behaviour)
        {
            Vector3        rootRotation    = new Vector3(rotation);
            Vector3        rootTranslation = new Vector3(translation);
            DualQuaternion rootTransform   = DualQuaternion.FromRotationTranslation(
                behaviour.model.MainDefinition.BoneSystem.RootBone.RotationOrder.FromEulerAngles(MathExtensions.DegreesToRadians(rootRotation)),
                rootTranslation);

            behaviour.dragHandle.Transform = rootTransform.ToMatrix();

            var poseDeltas = behaviour.ikAnimator.PoseDeltas;

            poseDeltas.ClearToZero();
            foreach (var bone in behaviour.model.MainDefinition.BoneSystem.Bones)
            {
                Vector3 angles;
                if (boneRotations.TryGetValue(bone.Name, out var values))
                {
                    angles = new Vector3(values);
                }
                else
                {
                    angles = Vector3.Zero;
                }
                var twistSwing = bone.RotationOrder.FromTwistSwingAngles(MathExtensions.DegreesToRadians(angles));
                poseDeltas.Rotations[bone.Index] = twistSwing;
            }
        }