protected virtual SpriterSpatial[] GetBoneInfos(SpriterMainlineKey key, SpriterAnimation animation, float targetTime, SpriterSpatial parentInfo = null) { if (key.BoneRefs == null) { return(null); } SpriterSpatial[] ret = Pool.GetArray <SpriterSpatial>(key.BoneRefs.Length); for (int i = 0; i < key.BoneRefs.Length; ++i) { SpriterRef boneRef = key.BoneRefs[i]; SpriterSpatial interpolated = GetBoneInfo(boneRef, animation, targetTime); if (boneRef.ParentId >= 0) { interpolated.ApplyParentTransform(ret[boneRef.ParentId]); } else if (parentInfo != null) { interpolated.ApplyParentTransform(parentInfo); } ret[i] = interpolated; } return(ret); }
private static SpriterSpatial[] GetBoneInfos(SpriterMainlineKey key, SpriterAnimation animation, float targetTime, SpriterSpatial parentInfo = null) { if (key.BoneRefs == null) { return(null); } SpriterSpatial[] ret = new SpriterSpatial[key.BoneRefs.Length]; for (int i = 0; i < key.BoneRefs.Length; ++i) { SpriterRef boneRef = key.BoneRefs[i]; SpriterSpatial interpolated = GetBoneInfo(boneRef, animation, targetTime); if (boneRef.ParentId >= 0) { ApplyParentTransform(interpolated, ret[boneRef.ParentId]); } else if (parentInfo != null) { ApplyParentTransform(interpolated, parentInfo); } ret[i] = interpolated; } return(ret); }
protected virtual SpriterObject GetObjectInfo(SpriterRef spriterRef, SpriterAnimation animation, float targetTime) { SpriterTimelineKey[] keys = animation.Timelines[spriterRef.TimelineId].Keys; SpriterTimelineKey keyA = keys[spriterRef.KeyId]; SpriterTimelineKey keyB = keys.GetNextKey(keyA, animation.Looping); if (keyB == null) { return(Copy(keyA.ObjectInfo)); } float factor = SpriterHelper.GetFactor(keyA, keyB, animation.Length, targetTime); return(Interpolate(keyA.ObjectInfo, keyB.ObjectInfo, factor, keyA.Spin)); }
private static SpriterSpatial GetBoneInfo(SpriterRef spriterRef, SpriterAnimation animation, float targetTime) { SpriterTimelineKey[] keys = animation.Timelines[spriterRef.TimelineId].Keys; SpriterTimelineKey keyA = keys[spriterRef.KeyId]; SpriterTimelineKey keyB = GetNextXLineKey(keys, keyA, animation.Looping); if (keyB == null) { return(Copy(keyA.BoneInfo)); } float factor = GetFactor(keyA, keyB, animation.Length, targetTime); return(Interpolate(keyA.BoneInfo, keyB.BoneInfo, factor, keyA.Spin)); }
private static SpriterObjectInfo GetObjectInfo(SpriterRef spriterRef, SpriterAnimation animation, float targetTime) { SpriterTimeLineKey keyA; SpriterTimeLineKey keyB; GetKeys(spriterRef, animation, out keyA, out keyB); if (keyB == null) return Copy(keyA.ObjectInfo); float factor = GetFactor(keyA, keyB, animation.Length, targetTime); return Interpolate(keyA.ObjectInfo, keyB.ObjectInfo, factor, keyA.Spin); }
private static void GetKeys(SpriterRef spriterRef, SpriterAnimation animation, out SpriterTimeLineKey keyA, out SpriterTimeLineKey keyB) { int tId = spriterRef.TimelineId; int kId = spriterRef.KeyId; var timelineKeys = animation.Timelines[tId].Keys; keyA = timelineKeys[kId]; keyB = null; if (timelineKeys.Length == 1) return; int keyBId = kId + 1; if (keyBId >= timelineKeys.Length) { if (animation.Looping) keyBId = 0; else return; } keyB = timelineKeys[keyBId]; }