Пример #1
0
 public static void SetToSetupPose(this Timeline timeline, Skeleton skeleton)
 {
     if (timeline != null)
     {
         if (timeline is RotateTimeline)
         {
             Bone bone = skeleton.bones.Items[((RotateTimeline)timeline).boneIndex];
             bone.rotation = bone.data.rotation;
         }
         else if (timeline is TranslateTimeline)
         {
             Bone bone2 = skeleton.bones.Items[((TranslateTimeline)timeline).boneIndex];
             bone2.x = bone2.data.x;
             bone2.y = bone2.data.y;
         }
         else if (timeline is ScaleTimeline)
         {
             Bone bone3 = skeleton.bones.Items[((ScaleTimeline)timeline).boneIndex];
             bone3.scaleX = bone3.data.scaleX;
             bone3.scaleY = bone3.data.scaleY;
         }
         else if (timeline is DeformTimeline)
         {
             Slot slot = skeleton.slots.Items[((DeformTimeline)timeline).slotIndex];
             slot.attachmentVertices.Clear(false);
         }
         else if (timeline is AttachmentTimeline)
         {
             skeleton.SetSlotAttachmentToSetupPose(((AttachmentTimeline)timeline).slotIndex);
         }
         else if (timeline is ColorTimeline)
         {
             skeleton.slots.Items[((ColorTimeline)timeline).slotIndex].SetColorToSetupPose();
         }
         else if (timeline is IkConstraintTimeline)
         {
             IkConstraintTimeline ikConstraintTimeline = (IkConstraintTimeline)timeline;
             IkConstraint         ikConstraint         = skeleton.ikConstraints.Items[ikConstraintTimeline.ikConstraintIndex];
             IkConstraintData     data = ikConstraint.data;
             ikConstraint.bendDirection = data.bendDirection;
             ikConstraint.mix           = data.mix;
         }
         else if (timeline is DrawOrderTimeline)
         {
             skeleton.SetDrawOrderToSetupPose();
         }
     }
 }
Пример #2
0
        internal static void SetPropertyToSetupPose(this Skeleton skeleton, int propertyID)
        {
            int tt           = propertyID >> 24;
            var timelineType = (TimelineType)tt;
            int i            = propertyID - (tt << 24);

            Bone           bone;
            IkConstraint   ikc;
            PathConstraint pc;

            switch (timelineType)
            {
            // Bone
            case TimelineType.Rotate:
                bone          = skeleton.bones.Items[i];
                bone.rotation = bone.data.rotation;
                break;

            case TimelineType.Translate:
                bone   = skeleton.bones.Items[i];
                bone.x = bone.data.x;
                bone.y = bone.data.y;
                break;

            case TimelineType.Scale:
                bone        = skeleton.bones.Items[i];
                bone.scaleX = bone.data.scaleX;
                bone.scaleY = bone.data.scaleY;
                break;

            case TimelineType.Shear:
                bone        = skeleton.bones.Items[i];
                bone.shearX = bone.data.shearX;
                bone.shearY = bone.data.shearY;
                break;

            // Slot
            case TimelineType.Attachment:
                skeleton.SetSlotAttachmentToSetupPose(i);
                break;

            case TimelineType.Color:
                skeleton.slots.Items[i].SetColorToSetupPose();
                break;

            case TimelineType.TwoColor:
                skeleton.slots.Items[i].SetColorToSetupPose();
                break;

            case TimelineType.Deform:
                skeleton.slots.Items[i].attachmentVertices.Clear();
                break;

            // Skeleton
            case TimelineType.DrawOrder:
                skeleton.SetDrawOrderToSetupPose();
                break;

            // IK Constraint
            case TimelineType.IkConstraint:
                ikc               = skeleton.ikConstraints.Items[i];
                ikc.mix           = ikc.data.mix;
                ikc.bendDirection = ikc.data.bendDirection;
                break;

            // TransformConstraint
            case TimelineType.TransformConstraint:
                var tc     = skeleton.transformConstraints.Items[i];
                var tcData = tc.data;
                tc.rotateMix    = tcData.rotateMix;
                tc.translateMix = tcData.translateMix;
                tc.scaleMix     = tcData.scaleMix;
                tc.shearMix     = tcData.shearMix;
                break;

            // Path Constraint
            case TimelineType.PathConstraintPosition:
                pc          = skeleton.pathConstraints.Items[i];
                pc.position = pc.data.position;
                break;

            case TimelineType.PathConstraintSpacing:
                pc         = skeleton.pathConstraints.Items[i];
                pc.spacing = pc.data.spacing;
                break;

            case TimelineType.PathConstraintMix:
                pc              = skeleton.pathConstraints.Items[i];
                pc.rotateMix    = pc.data.rotateMix;
                pc.translateMix = pc.data.translateMix;
                break;
            }
        }
Пример #3
0
		public static void SetToSetupPose (this Timeline timeline, Skeleton skeleton) {
			if (timeline != null) {
				// sorted according to assumed likelihood here

				// Bone
				if (timeline is RotateTimeline) {
					var bone = skeleton.bones.Items[((RotateTimeline)timeline).boneIndex];
					bone.rotation = bone.data.rotation;
				} else if (timeline is TranslateTimeline) {
					var bone = skeleton.bones.Items[((TranslateTimeline)timeline).boneIndex];
					bone.x = bone.data.x;
					bone.y = bone.data.y;
				} else if (timeline is ScaleTimeline) {
					var bone = skeleton.bones.Items[((ScaleTimeline)timeline).boneIndex];
					bone.scaleX = bone.data.scaleX;
					bone.scaleY = bone.data.scaleY;


				// Attachment
				} else if (timeline is DeformTimeline) {
					var slot = skeleton.slots.Items[((DeformTimeline)timeline).slotIndex];
					slot.attachmentVertices.Clear(false);

				// Slot
				} else if (timeline is AttachmentTimeline) {
					skeleton.SetSlotAttachmentToSetupPose(((AttachmentTimeline)timeline).slotIndex);

				} else if (timeline is ColorTimeline) {
					skeleton.slots.Items[((ColorTimeline)timeline).slotIndex].SetColorToSetupPose();


				// Constraint
				} else if (timeline is IkConstraintTimeline) {
					var ikTimeline = (IkConstraintTimeline)timeline;
					var ik = skeleton.ikConstraints.Items[ikTimeline.ikConstraintIndex];
					var data = ik.data;
					ik.bendDirection = data.bendDirection;
					ik.mix = data.mix;

				// Skeleton
				} else if (timeline is DrawOrderTimeline) {
					skeleton.SetDrawOrderToSetupPose();

				}

			}

		}
Пример #4
0
        public static void SetToSetupPose(this Timeline timeline, Skeleton skeleton)
        {
            if (timeline != null)
            {
                // sorted according to assumed likelihood here

                // Bone
                if (timeline is RotateTimeline)
                {
                    var bone = skeleton.bones.Items[((RotateTimeline)timeline).boneIndex];
                    bone.rotation = bone.data.rotation;
                }
                else if (timeline is TranslateTimeline)
                {
                    var bone = skeleton.bones.Items[((TranslateTimeline)timeline).boneIndex];
                    bone.x = bone.data.x;
                    bone.y = bone.data.y;
                }
                else if (timeline is ScaleTimeline)
                {
                    var bone = skeleton.bones.Items[((ScaleTimeline)timeline).boneIndex];
                    bone.scaleX = bone.data.scaleX;
                    bone.scaleY = bone.data.scaleY;


                    // Attachment
                }
                else if (timeline is DeformTimeline)
                {
                    var slot = skeleton.slots.Items[((DeformTimeline)timeline).slotIndex];
                    slot.attachmentVertices.Clear(false);

                    // Slot
                }
                else if (timeline is AttachmentTimeline)
                {
                    skeleton.SetSlotAttachmentToSetupPose(((AttachmentTimeline)timeline).slotIndex);
                }
                else if (timeline is ColorTimeline)
                {
                    skeleton.slots.Items[((ColorTimeline)timeline).slotIndex].SetColorToSetupPose();


                    // Constraint
                }
                else if (timeline is IkConstraintTimeline)
                {
                    var ikTimeline = (IkConstraintTimeline)timeline;
                    var ik         = skeleton.ikConstraints.Items[ikTimeline.ikConstraintIndex];
                    var data       = ik.data;
                    ik.bendDirection = data.bendDirection;
                    ik.mix           = data.mix;

                    // Skeleton
                }
                else if (timeline is DrawOrderTimeline)
                {
                    skeleton.SetDrawOrderToSetupPose();
                }
            }
        }
Пример #5
0
		// For each timeline type.
		// Timelines know how to apply themselves based on skeleton data; They should know how to reset the skeleton back to skeleton data?
		public static void SetToSetupPose (this Timeline timeline, Skeleton skeleton) {
			if (timeline != null) {
				// sorted according to assumed likelihood here

				// Bone stuff
				if (timeline is RotateTimeline) {
					var bone = skeleton.bones.Items[((RotateTimeline)timeline).boneIndex];
					bone.rotation = bone.data.rotation;
				} else if (timeline is TranslateTimeline) {
					var bone = skeleton.bones.Items[((TranslateTimeline)timeline).boneIndex];
					bone.x = bone.data.x;
					bone.y = bone.data.y;
				} else if (timeline is ScaleTimeline) {
					var bone = skeleton.bones.Items[((ScaleTimeline)timeline).boneIndex];
					bone.scaleX = bone.data.scaleX;
					bone.scaleY = bone.data.scaleY;


				// Attachment stuff. How do you reset FFD?
				} else if (timeline is FFDTimeline) {
					var slot = skeleton.slots.Items[((FFDTimeline)timeline).slotIndex];
					slot.attachmentVerticesCount = 0;	// This causes (Weighted)MeshAttachment.ComputeWorldVertices to use its internal(stateless) vertex array.
					//slot.attachmentTime = bone.skeleton.time; // Currently inconsequential. (Spine 3.1)
				
				// Slot stuff. This is heavy to do every frame. Maybe not do it?
				} else if (timeline is AttachmentTimeline) {
					skeleton.SetSlotAttachmentToSetupPose(((AttachmentTimeline)timeline).slotIndex);

				} else if (timeline is ColorTimeline) {
					skeleton.slots.Items[((ColorTimeline)timeline).slotIndex].SetColorToSetupPose();


				// Constraint Stuff
				} else if (timeline is IkConstraintTimeline) {
					var ikTimeline = (IkConstraintTimeline)timeline;
					var ik = skeleton.ikConstraints.Items[ikTimeline.ikConstraintIndex];
					var data = ik.data;
					ik.bendDirection = data.bendDirection;
					ik.mix = data.mix;

				// Skeleton stuff. Skeleton.SetDrawOrderToSetupPose. This is heavy to do every frame. Maybe not do it?
				} else if (timeline is DrawOrderTimeline) {
					skeleton.SetDrawOrderToSetupPose();


				}

			}


		}
Пример #6
0
        internal static void SetPropertyToSetupPose(this Skeleton skeleton, int propertyID)
        {
            Bone           bone;
            PathConstraint constraint2;
            int            num   = propertyID >> 0x18;
            TimelineType   type  = (TimelineType)num;
            int            index = propertyID - (num << 0x18);

            switch (type)
            {
            case TimelineType.Rotate:
                bone          = skeleton.bones.Items[index];
                bone.rotation = bone.data.rotation;
                break;

            case TimelineType.Translate:
                bone   = skeleton.bones.Items[index];
                bone.x = bone.data.x;
                bone.y = bone.data.y;
                break;

            case TimelineType.Scale:
                bone        = skeleton.bones.Items[index];
                bone.scaleX = bone.data.scaleX;
                bone.scaleY = bone.data.scaleY;
                break;

            case TimelineType.Shear:
                bone        = skeleton.bones.Items[index];
                bone.shearX = bone.data.shearX;
                bone.shearY = bone.data.shearY;
                break;

            case TimelineType.Attachment:
                skeleton.SetSlotAttachmentToSetupPose(index);
                break;

            case TimelineType.Color:
                skeleton.slots.Items[index].SetColorToSetupPose();
                break;

            case TimelineType.Deform:
                skeleton.slots.Items[index].attachmentVertices.Clear(true);
                break;

            case TimelineType.DrawOrder:
                skeleton.SetDrawOrderToSetupPose();
                break;

            case TimelineType.IkConstraint:
            {
                IkConstraint constraint = skeleton.ikConstraints.Items[index];
                constraint.mix           = constraint.data.mix;
                constraint.bendDirection = constraint.data.bendDirection;
                break;
            }

            case TimelineType.TransformConstraint:
            {
                TransformConstraint     constraint3 = skeleton.transformConstraints.Items[index];
                TransformConstraintData data        = constraint3.data;
                constraint3.rotateMix    = data.rotateMix;
                constraint3.translateMix = data.translateMix;
                constraint3.scaleMix     = data.scaleMix;
                constraint3.shearMix     = data.shearMix;
                break;
            }

            case TimelineType.PathConstraintPosition:
                constraint2          = skeleton.pathConstraints.Items[index];
                constraint2.position = constraint2.data.position;
                break;

            case TimelineType.PathConstraintSpacing:
                constraint2         = skeleton.pathConstraints.Items[index];
                constraint2.spacing = constraint2.data.spacing;
                break;

            case TimelineType.PathConstraintMix:
                constraint2              = skeleton.pathConstraints.Items[index];
                constraint2.rotateMix    = constraint2.data.rotateMix;
                constraint2.translateMix = constraint2.data.translateMix;
                break;

            case TimelineType.TwoColor:
                skeleton.slots.Items[index].SetColorToSetupPose();
                break;
            }
        }
Пример #7
0
        internal static void SetPropertyToSetupPose(this Skeleton skeleton, int propertyID)
        {
            int          num          = propertyID >> 24;
            TimelineType timelineType = (TimelineType)num;
            int          num2         = propertyID - (num << 24);

            switch (timelineType)
            {
            case TimelineType.Event:
                break;

            case TimelineType.Rotate:
            {
                Bone bone = skeleton.bones.Items[num2];
                bone.rotation = bone.data.rotation;
                break;
            }

            case TimelineType.Translate:
            {
                Bone bone = skeleton.bones.Items[num2];
                bone.x = bone.data.x;
                bone.y = bone.data.y;
                break;
            }

            case TimelineType.Scale:
            {
                Bone bone = skeleton.bones.Items[num2];
                bone.scaleX = bone.data.scaleX;
                bone.scaleY = bone.data.scaleY;
                break;
            }

            case TimelineType.Shear:
            {
                Bone bone = skeleton.bones.Items[num2];
                bone.shearX = bone.data.shearX;
                bone.shearY = bone.data.shearY;
                break;
            }

            case TimelineType.Attachment:
                skeleton.SetSlotAttachmentToSetupPose(num2);
                break;

            case TimelineType.Color:
                skeleton.slots.Items[num2].SetColorToSetupPose();
                break;

            case TimelineType.TwoColor:
                skeleton.slots.Items[num2].SetColorToSetupPose();
                break;

            case TimelineType.Deform:
                skeleton.slots.Items[num2].attachmentVertices.Clear();
                break;

            case TimelineType.DrawOrder:
                skeleton.SetDrawOrderToSetupPose();
                break;

            case TimelineType.IkConstraint:
            {
                IkConstraint ikConstraint = skeleton.ikConstraints.Items[num2];
                ikConstraint.mix           = ikConstraint.data.mix;
                ikConstraint.bendDirection = ikConstraint.data.bendDirection;
                break;
            }

            case TimelineType.TransformConstraint:
            {
                TransformConstraint     transformConstraint = skeleton.transformConstraints.Items[num2];
                TransformConstraintData data = transformConstraint.data;
                transformConstraint.rotateMix    = data.rotateMix;
                transformConstraint.translateMix = data.translateMix;
                transformConstraint.scaleMix     = data.scaleMix;
                transformConstraint.shearMix     = data.shearMix;
                break;
            }

            case TimelineType.PathConstraintPosition:
            {
                PathConstraint pathConstraint = skeleton.pathConstraints.Items[num2];
                pathConstraint.position = pathConstraint.data.position;
                break;
            }

            case TimelineType.PathConstraintSpacing:
            {
                PathConstraint pathConstraint = skeleton.pathConstraints.Items[num2];
                pathConstraint.spacing = pathConstraint.data.spacing;
                break;
            }

            case TimelineType.PathConstraintMix:
            {
                PathConstraint pathConstraint = skeleton.pathConstraints.Items[num2];
                pathConstraint.rotateMix    = pathConstraint.data.rotateMix;
                pathConstraint.translateMix = pathConstraint.data.translateMix;
                break;
            }
            }
        }