/// <summary> /// Creates a time index relative to the beginning of the interval. /// </summary> /// <param name="frameIndex">An index that is relative to the beginning of the interval.</param> /// <returns>Time index relative to the beginning of the interval.</returns> public TimeIndex GetTimeIndex(int frameIndex) { Assert.IsTrue(Contains(frameIndex)); return(TimeIndex.Create( segmentIndex, frameIndex)); }
/// <summary> /// Reads a time index from the buffer. /// </summary> /// <returns>The time index that has been read from the buffer.</returns> public static TimeIndex ReadTimeIndex(this Buffer buffer) { var segmentIndex = buffer.Read16(); var frameIndex = buffer.Read16(); return(TimeIndex.Create(segmentIndex, frameIndex)); }
public void LoopSegmentIfEndReached(SamplingTime samplingTime) { int numSegmentFrames = Binary.GetSegment(samplingTime.segmentIndex).destination.NumFrames; if (samplingTime.frameIndex == numSegmentFrames - 1) { PlayAtTime(SamplingTime.Create(TimeIndex.Create(samplingTime.segmentIndex))); } }
/// <summary> /// Determines whether or not the given time index is contained in the interval. /// </summary> /// <returns>True if the given time index is contained in this interval; false otherwise.</returns> public bool Contains(TimeIndex timeIndex) { if (timeIndex.segmentIndex == segmentIndex) { return(Contains(timeIndex.frameIndex)); } return(false); }
internal DeviationScore GetDeviation(ref Binary binary, TimeIndex timeIndex) { for (int i = 0; i < sequences.Length; ++i) { PoseSequenceInfo sequenceInfo = sequences[i]; ref Binary.Interval interval = ref binary.GetInterval(sequenceInfo.sequence.intervalIndex); if (interval.Contains(timeIndex)) { if (timeIndex.frameIndex >= sequenceInfo.sequence.firstFrame && timeIndex.frameIndex < sequenceInfo.sequence.onePastLastFrame) { int deviationIndex = sequenceInfo.firstDeviationIndex + timeIndex.frameIndex - sequenceInfo.sequence.firstFrame; return(deviations[deviationIndex]); } } }
/// <summary> /// Retrieve fragment index inside codebook that is associated to a time index /// </summary> /// <returns>Returns -1 if the time index isn't covered by the codebook</returns> public int GetCodeBookFragmentIndex(ref CodeBook codeBook, TimeIndex timeIndex) { int numIntervals = codeBook.intervals.Length; int fragmentIndex = 0; for (int i = 0; i < numIntervals; ++i) { ref Interval interval = ref GetInterval(codeBook.intervals[i]); if (interval.Contains(timeIndex)) { fragmentIndex += timeIndex.frameIndex - interval.firstFrame; return(fragmentIndex); } fragmentIndex += interval.numFrames; }
void TriggerMarkers(TimeIndex from, TimeIndex to) { Assert.IsTrue(from.segmentIndex == to.segmentIndex); int firstFrame = from.frameIndex; int onePastLastFrame = to.frameIndex; if (lastSamplingTime.segmentIndex == samplingTime.segmentIndex) { firstFrame = math.max(firstFrame, lastSamplingTime.frameIndex + 1); } if (onePastLastFrame >= firstFrame) { TriggerMarkers( samplingTime.segmentIndex, Interval.Create( firstFrame, onePastLastFrame)); lastSamplingTime = to; } }
float RelativeDeviation(TimeIndex candidate, Trajectory trajectory) { ref var binary = ref Binary;
/// <summary> /// Writes a time index to the buffer. /// </summary> /// <param name="timeIndex">The time index that should be written to the buffer.</param> public static void Write(this Buffer buffer, TimeIndex timeIndex) { buffer.Write(timeIndex.segmentIndex); buffer.Write(timeIndex.frameIndex); }
internal int GetFrameIndex(TimeIndex timeIndex) { ref var segment = ref GetSegment(timeIndex.segmentIndex);
/// <summary> /// Switches the pose generation stream to read /// from the time index passed as argument. /// </summary> /// <remarks> /// Animation poses are always generated continuously /// based on a sampling time. This method allows to switch /// to a new starting time. The motion synthesizer automatically /// handles any discrepancies between the old and the new pose. /// </remarks> /// <param name="timeIndex">New starting time index for the pose generation.</param> public void PlayAtTime(TimeIndex timeIndex) { PlayAtTime( SamplingTime.Create( timeIndex, Time.theta)); }