Timeline#

Fully qualified name: omni::timeline::Timeline

class Timeline#

Defines a timeline controller.

Public Functions

virtual void play(
double startTimeCode = 0,
double endTimeCode = 0,
bool looping = true,
) = 0#

Plays animation with current timeCodePerSecond.

if not set session start and end timecode, will play from global start time to end time in stage.

Parameters:
  • startTimeCode – start timeCode of session play, won’t change the global StartTime.

  • endTimeCode – start timeCode of session play, won’t change the global EndTime.

  • looping – true to enable session play looping, false to disable, won’t change the global Looping.

virtual void pause() = 0#

Pauses animation.

virtual void stop() = 0#

Stops animation.

virtual void rewindOneFrame() = 0#

Rewinds the timeline by one frame.

virtual void forwardOneFrame() = 0#

Forwards the timeline by one frame.

virtual bool isPlaying() const = 0#

Checks if animation is playing.

Returns:

true if animation is playing.

virtual bool isStopped() const = 0#

Checks if animation is stopped, as opposed to paused.

Returns:

true if animation is stopped.

virtual void setAutoUpdate(bool autoUpdate) = 0#

Turns on/off auto update.

Parameters:

autoUpdate – autoUpdate true to enable auto update, false to disable.

virtual bool isAutoUpdating() const = 0#

Checks if timeline auto updates the frame.

Returns:

true if timeline is auto updating

virtual void setPrerolling(bool autoUpdate) = 0#

Turns on/off prerolling status.

Parameters:

autoUpdate – prerolling true to indicate timeline is in preroll state

virtual bool isPrerolling() const = 0#

Checks if timeline is in prerolling mode.

Returns:

true if timeline is in preroll

virtual void setLooping(bool looping) = 0#

Sets animation looping mode.

Parameters:

looping – looping true to enable looping, false to disable.

virtual bool isLooping() const = 0#

Checks if animation is looping.

Returns:

true if animation is looping.

virtual void setCurrentTime(double timeInSeconds) = 0#

Sets current time of animation in seconds.

Parameters:

timeInSeconds – Current time of animation in seconds.

virtual double getCurrentTime() const = 0#

Gets current time of animation in seconds.

Current time is defined as the beginning of the next frame.

Note

When queried inside time update callbacks, we are in the current frame, current time (defined as the beginning of the next frame) is the end of the current frame.

Returns:

Current time of animation in seconds.

virtual double getStartTime() const = 0#

Gets the start time of animation in seconds.

Note

Start time is defined as the beginning of the first frame.

Returns:

Begin time of animation in seconds.

virtual void setStartTime(double startTime) = 0#

Sets the start time of animation in seconds.

This will write into current opened stage.

Note

The call enforces the time interval defined by start and end times to be at least one frame long.

Parameters:

startTime – Begin time of animation in seconds.

virtual double getEndTime() const = 0#

Gets the end time of animation in seconds.

Note

End time means no frames can start strictly after this time point. When start and end time define an integer number of frames, end time is the end of the last animation frame.

Returns:

End time of animation in seconds.

virtual void setEndTime(double endTime) = 0#

Sets the end time of animation in seconds.

This will write into current opened stage.

Note

The call enforces the time interval defined by start and end times to be at least one frame long.

Parameters:

endTime – End time of animation in seconds.

virtual double getTimeCodesPerSecond() const = 0#

Gets timeCodePerSecond metadata from currently opened stage.

This is equivalent to calling GetTimeCodesPerSecond on UsdStage.

Returns:

timeCodePerSecond for current UsdStage.

virtual void setTimeCodesPerSecond(double timeCodesPerSecond) = 0#

Sets timeCodePerSecond metadata to currently opened stage.

This is equivalent to calling SetTimeCodesPerSecond on UsdStage.

Parameters:

timeCodesPerSecond – TimeCodePerSecond to set into current stage.

virtual carb::events::IEventStream *getTimelineEventStream() = 0#

Gets TimelineEventStream, emitting TimelineEventType.

Returns:

IEventStream* of TimelineEventStream.

virtual void setTentativeTime(double timeInSeconds) = 0#

Sets a tentative time of animation in seconds.

Parameters:

timeInSeconds – A tentative current time of animation in seconds.

virtual void clearTentativeTime() = 0#

Clear the tentative time of animation so it becomes invalid.

virtual double getTentativeTime() const = 0#

Gets the tentative time of animation in seconds.

Returns:

The tentative time if it is valid, current time if invalid.

virtual void setTicksPerFrame(unsigned int ticksPerFrame) = 0#

Sets the tick count per frame, i.e.

how many times update event is ticked per frame.

Parameters:

ticksPerFrame – The tick per frame count.

virtual unsigned int getTicksPerFrame() const = 0#

Gets the tick count per frame, i.e.

how many times update event is ticked per frame.

Returns:

The tick per frame count.

virtual double getTicksPerSecond() const = 0#

Gets the tick count per seconds, i.e.

how many times update event is ticked per second.

Returns:

The tick per second count.

virtual unsigned int getCurrentTick() const = 0#

Gets the current tick index, starting from zero.

Always returns zero when ticks per frame is one.

Returns:

The current tick index.

virtual void setFastMode(bool fastMode) = 0#

Turns fast mode on or off.

Deprecated, same as setPlayEveryFrame.

Parameters:

fastMode – true to turn on fast mode, false to turn it off.

virtual bool getFastMode() const = 0#

Checks if fast mode is on or off.

Deprecated, same as getPlayEveryFrame.

Returns:

true is fast mode is on.

virtual void setTargetFramerate(float targetFrameRate) = 0#

Sets the target frame rate, which affects the derived FPS of the runloop in play mode.

Exact runloop FPS is usually not the same as this value, as it is always a multiple of getTimeCodesPerSecond.

Parameters:

targetFrameRate – The target frame rate.

virtual float getTargetFramerate() const = 0#

Gets the target frame rate, which affects the derived FPS of the runloop in play mode.

Exact runloop FPS is usually not the same as this value, as it is always a multiple of getTimeCodesPerSecond.

Returns:

The target frame rate.

virtual double timeToTimeCode(double timeInSecs) const = 0#

Converts time in seconds to time codes, w.r.t.

the current timeCodesPerSecond setting of the timeline.

Returns:

The converted time code.

virtual double timeCodeToTime(double timeCodes) const = 0#

Converts time codes to seconds, w.r.t.

the current timeCodesPerSecond setting of the timeline.

Returns:

The converted time in seconds.

virtual void commit() = 0#

Applies all pending state changes and invokes all callbacks.

This method is not thread-safe, it should be called only from the main thread.

virtual void commitSilently() = 0#

Applies all pending state changes but does not invoke any callbacks.

This method is thread-safe.

virtual void setPlayEveryFrame(bool playEveryFrame) = 0#

Turns frame skipping off (true) or on (false).

Same as setFastMode.

Parameters:

playEveryFrame – true to turn frame skipping off.

virtual bool getPlayEveryFrame() const = 0#

Checks if the timeline sends updates every frame.

Same as getFastMode.

Returns:

true if the timeline does not skip frames.

virtual void setDirector(TimelinePtr timeline) = 0#

Sets a director Timeline.

When a director is set, the timeline mimics its behavior and any state changing call from all other sources are ignored.

Parameters:

timeline – The timeline object to be set as the director. Pass nullptr to clear the current director.

virtual TimelinePtr getDirector() const = 0#

Returns the current director Timeline.

Returns:

The director timeline or nullptr if none is set.

virtual void setZoomRange(double startTime, double endTime) = 0#

Sets the zoom range, i.e.

the playback interval.

Values are truncated to the [getStartTime(), getEndTime()] interval, which is also the default range. A minimum of one frame long range is enforced.

Parameters:
  • startTime – start time of zoom in seconds. Must be less or equal than endTime.

  • endTime – End time of zoom in seconds. Must be greater or equal than endTime.

virtual void clearZoom() = 0#

Clears the zoom state, i.e.

sets the zoom range to [getStartTime(), getEndTime()].

virtual bool isZoomed() const = 0#

Returns whether a zoom is set, i.e.

the zoom range is not the entire [getStartTime(), getEndTime()] interval.

Returns:

true if getStartTime() < getZoomStartTime() or getZoomEndTime() < getEndTime() (note that “<=” always holds). false otherwise.

virtual double getZoomStartTime() const = 0#

Gets the start time of zoomed animation in seconds.

Returns:

: The start time of zoomed animation in seconds. When no zoom is set, this function returns getStartTime().

virtual double getZoomEndTime() const = 0#

Gets the end time of zoomed animation in seconds.

Returns:

: The end time of zoomed animation in seconds. When no zoom is set, this function returns getEndTime().