public static double GetTimeInSpace(PlayableTimeSpace srcSpace, double srcTime, PlayableTimeSpace dstSpace, double clipStart, double clipEnd) { if (srcSpace == dstSpace) { return(srcTime); } if (dstSpace == PlayableTimeSpace.AfterClipStart) { switch (srcSpace) { case PlayableTimeSpace.BeforeClipEnd: return(clipEnd - srcTime - clipStart); case PlayableTimeSpace.Percentage: return((clipEnd - clipStart) * (srcTime / 100.0)); case PlayableTimeSpace.Absolute: return(srcTime - clipStart); } } else if (dstSpace == PlayableTimeSpace.BeforeClipEnd) { switch (srcSpace) { case PlayableTimeSpace.AfterClipStart: return(clipEnd - srcTime - clipStart); case PlayableTimeSpace.Percentage: return(clipEnd - clipStart - (clipEnd - clipStart) * (srcTime / 100.0)); case PlayableTimeSpace.Absolute: return(clipEnd - srcTime); } } else if (dstSpace == PlayableTimeSpace.Percentage) { switch (srcSpace) { case PlayableTimeSpace.AfterClipStart: return(100.0 * (srcTime) / (clipEnd - clipStart)); case PlayableTimeSpace.BeforeClipEnd: return(100.0 * (clipEnd - srcTime - clipStart) / (clipEnd - clipStart)); case PlayableTimeSpace.Absolute: return(100.0 * (srcTime - clipStart) / (clipEnd - clipStart)); } } else if (dstSpace == PlayableTimeSpace.Absolute) { switch (srcSpace) { case PlayableTimeSpace.AfterClipStart: return(clipStart + srcTime); case PlayableTimeSpace.BeforeClipEnd: return(clipEnd - srcTime); case PlayableTimeSpace.Percentage: return(clipStart + (clipEnd - clipStart) * (srcTime / 100.0)); } } //Other conversion throw new NotImplementedException(srcSpace + " to " + dstSpace); }
public static IEnumerable <VisualEffectPlayableSerializedEvent> GetEventNormalizedSpace(PlayableTimeSpace space, VisualEffectControlClip source, bool clipEvents) { IEnumerable <VisualEffectPlayableSerializedEvent> sourceEvents; if (clipEvents) { sourceEvents = CollectClipEvents(source); } else { sourceEvents = source.singleEvents; } return(GetEventNormalizedSpace(space, sourceEvents, source.clipStart, source.clipEnd)); }
private static IEnumerable <VisualEffectPlayableSerializedEvent> GetEventNormalizedSpace(PlayableTimeSpace space, IEnumerable <VisualEffectPlayableSerializedEvent> events, double clipStart, double clipEnd) { foreach (var itEvent in events) { var copy = itEvent; copy.timeSpace = space; copy.time = GetTimeInSpace(itEvent.timeSpace, itEvent.time, space, clipStart, clipEnd); yield return(copy); } }
public static IEnumerable <VisualEffectPlayableSerializedEvent> GetEventNormalizedSpace(PlayableTimeSpace space, VisualEffectControlPlayableBehaviour source) { return(GetEventNormalizedSpace(space, source.events, source.clipStart, source.clipEnd)); }