public void AddMixingTransform(string timelineName, int type = 2, bool recursive = true) { if (_clip != null && _clip.GetTimeline(timelineName) != null) { if (_mixingTransforms == null) { _mixingTransforms = new Dictionary <string, int>(); } if (recursive) { int i = _armature._boneList.Count; Bone bone = null; Bone currentBone = null; while (i-- > 0) { bone = _armature._boneList[i]; if (bone.Name == timelineName) { currentBone = bone; } if (currentBone != null && (currentBone == bone || currentBone.Contains(bone))) { _mixingTransforms[bone.Name] = type; } } } else { _mixingTransforms[timelineName] = type; } updateTimelineStates(); } else { throw new ArgumentException(); } }
public static void AddHideTimeline(AnimationData animationData, ArmatureData armatureData) { List <BoneData> boneDataList = armatureData.BoneDataList; int i = boneDataList.Count; BoneData boneData; string boneName; while (i-- > 0) { boneData = boneDataList[i]; boneName = boneData.Name; if (animationData.GetTimeline(boneName) == null) { animationData.AddTimeline(TransformTimeline.HIDE_TIMELINE, boneName); } } }
public static void TransformAnimationData(AnimationData animationData, ArmatureData armatureData) { SkinData skinData = armatureData.GetSkinData(null); List <BoneData> boneDataList = armatureData.BoneDataList; List <SlotData> slotDataList = skinData.SlotDataList; int i = boneDataList.Count; BoneData boneData; TransformTimeline timeline; SlotData slotData; DisplayData displayData; TransformTimeline parentTimeline; List <Frame> frameList; DBTransform originTransform; Point originPivot; TransformFrame prevFrame; uint frameListLength; TransformFrame frame; while (i-- > 0) { boneData = boneDataList[i]; timeline = animationData.GetTimeline(boneData.Name); if (timeline == null) { continue; } slotData = null; foreach (SlotData slotDataObj in slotDataList) { if (slotDataObj.Parent == boneData.Name) { slotData = slotDataObj; break; } } parentTimeline = boneData.Parent != null?animationData.GetTimeline(boneData.Parent) : null; frameList = timeline.FrameList; originTransform = null; originPivot = null; prevFrame = null; frameListLength = (uint)frameList.Count; for (int j = 0; j < frameListLength; j++) { frame = frameList[j] as TransformFrame; if (parentTimeline != null) { //tweenValues to transform. _helpTransform1.Copy(frame.Global); //get transform from parent timeline. GetTimelineTransform(parentTimeline, frame.Position, _helpTransform2); TransformUtil.TransformPointWithParent(_helpTransform1, _helpTransform2); //transform to tweenValues. frame.Transform.Copy(_helpTransform1); } else { frame.Transform.Copy(frame.Global); } frame.Transform.X -= boneData.Transform.X; frame.Transform.Y -= boneData.Transform.Y; frame.Transform.SkewX -= boneData.Transform.SkewX; frame.Transform.SkewY -= boneData.Transform.SkewY; frame.Transform.ScaleX -= boneData.Transform.ScaleX; frame.Transform.ScaleY -= boneData.Transform.ScaleY; if (!timeline.Transformed) { if (slotData != null) { frame.ZOrder -= slotData.ZOrder; } } if (originTransform == null) { originTransform = timeline.OriginTransform; originTransform.Copy(frame.Transform); originTransform.SkewX = TransformUtil.FormatRadian(originTransform.SkewX); originTransform.SkewY = TransformUtil.FormatRadian(originTransform.SkewY); originPivot = timeline.OriginPivot; originPivot.X = frame.Pivot.X; originPivot.Y = frame.Pivot.Y; } frame.Transform.X -= originTransform.X; frame.Transform.Y -= originTransform.Y; frame.Transform.SkewX = TransformUtil.FormatRadian(frame.Transform.SkewX - originTransform.SkewX); frame.Transform.SkewY = TransformUtil.FormatRadian(frame.Transform.SkewY - originTransform.SkewY); frame.Transform.ScaleX -= originTransform.ScaleX; frame.Transform.ScaleY -= originTransform.ScaleY; if (!timeline.Transformed) { frame.Pivot.Y -= originPivot.X; frame.Pivot.Y -= originPivot.Y; } if (prevFrame != null) { float dLX = frame.Transform.SkewX - prevFrame.Transform.SkewX; if (prevFrame.TweenRotate != 0) { if (prevFrame.TweenRotate > 0) { if (dLX < 0) { frame.Transform.SkewX += (float)Math.PI * 2f; frame.Transform.SkewY += (float)Math.PI * 2f; } if (prevFrame.TweenRotate > 1) { frame.Transform.SkewX += (float)Math.PI * 2f * ((float)prevFrame.TweenRotate - 1f); frame.Transform.SkewY += (float)Math.PI * 2f * ((float)prevFrame.TweenRotate - 1f); } } else { if (dLX > 0) { frame.Transform.SkewX -= (float)Math.PI * 2f; frame.Transform.SkewY -= (float)Math.PI * 2f; } if (prevFrame.TweenRotate < 1) { frame.Transform.SkewX += (float)Math.PI * 2f * ((float)prevFrame.TweenRotate + 1f); frame.Transform.SkewY += (float)Math.PI * 2f * ((float)prevFrame.TweenRotate + 1f); } } } else { frame.Transform.SkewX = prevFrame.Transform.SkewX + TransformUtil.FormatRadian(frame.Transform.SkewX - prevFrame.Transform.SkewX); frame.Transform.SkewY = prevFrame.Transform.SkewY + TransformUtil.FormatRadian(frame.Transform.SkewY - prevFrame.Transform.SkewY); } } prevFrame = frame; } timeline.Transformed = true; } }