コード例 #1
0
ファイル: Skeleton.cs プロジェクト: qwer327146/SpineViewerWPF
        /// <summary>Sets the bones and constraints to their setup pose values.</summary>
        public void SetBonesToSetupPose()
        {
            var bonesItems = this.bones.Items;

            for (int i = 0, n = bones.Count; i < n; i++)
            {
                bonesItems[i].SetToSetupPose();
            }

            var ikConstraintsItems = this.ikConstraints.Items;

            for (int i = 0, n = ikConstraints.Count; i < n; i++)
            {
                IkConstraint constraint = ikConstraintsItems[i];
                constraint.mix           = constraint.data.mix;
                constraint.softness      = constraint.data.softness;
                constraint.bendDirection = constraint.data.bendDirection;
                constraint.compress      = constraint.data.compress;
                constraint.stretch       = constraint.data.stretch;
            }

            var transformConstraintsItems = this.transformConstraints.Items;

            for (int i = 0, n = transformConstraints.Count; i < n; i++)
            {
                TransformConstraint     constraint     = transformConstraintsItems[i];
                TransformConstraintData constraintData = constraint.data;
                constraint.rotateMix    = constraintData.rotateMix;
                constraint.translateMix = constraintData.translateMix;
                constraint.scaleMix     = constraintData.scaleMix;
                constraint.shearMix     = constraintData.shearMix;
            }

            var pathConstraintItems = this.pathConstraints.Items;

            for (int i = 0, n = pathConstraints.Count; i < n; i++)
            {
                PathConstraint     constraint     = pathConstraintItems[i];
                PathConstraintData constraintData = constraint.data;
                constraint.position     = constraintData.position;
                constraint.spacing      = constraintData.spacing;
                constraint.rotateMix    = constraintData.rotateMix;
                constraint.translateMix = constraintData.translateMix;
            }
        }
コード例 #2
0
        // --- Transform constraints.

        /// <returns>May be null.</returns>
        public TransformConstraintData FindTransformConstraint(string constraintName)
        {
            if (constraintName == null)
            {
                throw new ArgumentNullException("constraintName", "constraintName cannot be null.");
            }
            ExposedList <TransformConstraintData> transformConstraints = this.transformConstraints;

            for (int i = 0, n = transformConstraints.Count; i < n; i++)
            {
                TransformConstraintData transformConstraint = transformConstraints.Items[i];
                if (transformConstraint.name == constraintName)
                {
                    return(transformConstraint);
                }
            }
            return(null);
        }
コード例 #3
0
 /// <summary>Copy constructor.</summary>
 public TransformConstraint(TransformConstraint constraint, Skeleton skeleton)
 {
     if (constraint == null)
     {
         throw new ArgumentNullException("constraint cannot be null.");
     }
     if (skeleton == null)
     {
         throw new ArgumentNullException("skeleton cannot be null.");
     }
     data  = constraint.data;
     bones = new ExposedList <Bone>(constraint.Bones.Count);
     foreach (Bone bone in constraint.Bones)
     {
         bones.Add(skeleton.Bones.Items[bone.data.index]);
     }
     target       = skeleton.Bones.Items[constraint.target.data.index];
     rotateMix    = constraint.rotateMix;
     translateMix = constraint.translateMix;
     scaleMix     = constraint.scaleMix;
     shearMix     = constraint.shearMix;
 }
コード例 #4
0
        public TransformConstraint(TransformConstraintData data, Skeleton skeleton)
        {
            if (data == null)
            {
                throw new ArgumentNullException("data", "data cannot be null.");
            }
            if (skeleton == null)
            {
                throw new ArgumentNullException("skeleton", "skeleton cannot be null.");
            }
            this.data    = data;
            rotateMix    = data.rotateMix;
            translateMix = data.translateMix;
            scaleMix     = data.scaleMix;
            shearMix     = data.shearMix;

            bones = new ExposedList <Bone>();
            foreach (BoneData boneData in data.bones)
            {
                bones.Add(skeleton.FindBone(boneData.name));
            }

            target = skeleton.FindBone(data.target.name);
        }