Class SyncTrack
Namespace: ValveResourceFormat.Animation
Assembly: ValveResourceFormat.dll
Synchronizes animations by dividing their timeline into named sync periods. Positions on the track are expressed as SyncTrackTime (event index plus percentage through it), which lets differently-timed clips advance in lockstep.
public class SyncTrackInheritance
object ← SyncTrack
Constructors
SyncTrack(Event[], int)
Creates a track from events and a start event offset.
public SyncTrack(SyncTrack.Event[] events, int startEventOffset)Parameters
startEventOffset int
SyncTrack(SyncTrack, SyncTrack, float)
Creates a track by blending two tracks: event durations are blended, start times follow from the blended durations. The event count is the LCM of the two tracks' counts.
public SyncTrack(SyncTrack track0, SyncTrack track1, float blendWeight)Parameters
track0 SyncTrack
track1 SyncTrack
blendWeight float
SyncTrack(KVObject)
Reads the SyncTrack from its KeyValues3 data.
public SyncTrack(KVObject data)Parameters
data KVObject
Properties
Default
A default track with one full-length unnamed event.
public static SyncTrack Default { get; }Property Value
EndTime
The time at the end of the last event.
public SyncTrackTime EndTime { get; }Property Value
HasStartOffset
Whether playback starts at an event other than the first.
public bool HasStartOffset { get; }Property Value
bool
NumEvents
The logical event count; the scratch backing array may be larger.
public int NumEvents { get; }Property Value
int
StartEventOffset
The index of the event playback starts at.
public int StartEventOffset { get; }Property Value
int
StartTime
The time at the start of the first event.
public static SyncTrackTime StartTime { get; }Property Value
SyncEvents
The sync events, in order.
public SyncTrack.Event[] SyncEvents { get; }Property Value
Methods
CalculateDurationSynchronized(float, float, int, int, int, float)
Calculates the duration resulting from a blend of two synchronized tracks.
public static float CalculateDurationSynchronized(float duration0, float duration1, int numEvents0, int numEvents1, int eventsLCM, float blendWeight)Parameters
duration0 float
duration1 float
numEvents0 int
numEvents1 int
eventsLCM int
blendWeight float
Returns
float
CalculatePercentageCovered(SyncTrackTime, SyncTrackTime)
Returns the percentage of the sync track covered by the specified range.
public float CalculatePercentageCovered(SyncTrackTime startTime, SyncTrackTime endTime)Parameters
startTime SyncTrackTime
endTime SyncTrackTime
Returns
float
CalculatePercentageCovered(SyncTrackTimeRange)
Calculates the percentage of the track covered by a time range.
public float CalculatePercentageCovered(SyncTrackTimeRange range)Parameters
range SyncTrackTimeRange
Returns
float
CreateBlendScratch()
Creates a reusable scratch track for in-place blending.
public static SyncTrack CreateBlendScratch()Returns
GetClosestEventIndexForID(SyncTrackTime, StringToken)
Gets the event matching the ID closest to the given time; when nothing matches, the first event including offset.
public int GetClosestEventIndexForID(SyncTrackTime time, StringToken id)Parameters
time SyncTrackTime
id StringToken
Returns
int
GetEvent(int)
Gets the event at the specified index, including the start offset.
public SyncTrack.Event GetEvent(int i)Parameters
i int
Returns
GetEventDuration(int, bool)
Gets the duration of an event as a percentage of the whole track.
public float GetEventDuration(int eventIdx, bool withOffset = true)Parameters
eventIdx int
withOffset bool
Returns
float
GetEventID(int)
Gets the ID for the event at the specified index, including the start offset.
public StringToken GetEventID(int i)Parameters
i int
Returns
GetEventIndexForID(StringToken)
Gets the first event matching the ID; when nothing matches, the first event including offset.
public int GetEventIndexForID(StringToken id)Parameters
id StringToken
Returns
int
GetPercentageThrough(SyncTrackTime)
Gets the percentage through the clip for a sync time, starting at the offset event.
public float GetPercentageThrough(SyncTrackTime time)Parameters
time SyncTrackTime
Returns
float
GetPercentageThrough(SyncTrackTime, bool)
Gets the percentage through the clip for a sync time, optionally starting at the offset event.
public float GetPercentageThrough(SyncTrackTime time, bool withOffset)Parameters
time SyncTrackTime
withOffset bool
Returns
float
GetTime(float)
Gets the sync track time for a percentage through the track, starting at the offset event.
public SyncTrackTime GetTime(float percentage)Parameters
percentage float
Returns
GetTime(float, bool)
Gets the sync track time for a percentage through the track, optionally starting at the offset event.
public SyncTrackTime GetTime(float percentage, bool withOffset)Parameters
percentage float
withOffset bool
Returns
HasEventWithID(StringToken)
Whether the track has an event with the given ID.
public bool HasEventWithID(StringToken id)Parameters
id StringToken
Returns
bool
LowestCommonMultiple(int, int)
Gets the lowest common multiple of two integers.
public static int LowestCommonMultiple(int a, int b)Parameters
a int
b int
Returns
int
SetToBlendOf(SyncTrack, SyncTrack, float)
Reuses this track as the blend of two tracks, only reallocating the event array when the event count changes. The inputs must not be this instance.
public void SetToBlendOf(SyncTrack track0, SyncTrack track1, float blendWeight)Parameters
track0 SyncTrack
track1 SyncTrack
blendWeight float
SetToCopyWithoutStartOffset(SyncTrack)
Reuses this track as a copy of another, without its start event offset.
public void SetToCopyWithoutStartOffset(SyncTrack source)Parameters
source SyncTrack
UpdateEventTime(SyncTrackTime, float)
Calculates the track time resulting from a start time advanced by a percentage delta.
public SyncTrackTime UpdateEventTime(SyncTrackTime startTime, float deltaPercentage)Parameters
startTime SyncTrackTime
deltaPercentage float

