# panda3d.direct.CInterval¶

from panda3d.direct import CInterval

class CInterval

Bases: TypedReferenceCount

The base class for timeline components. A CInterval represents a single action, event, or collection of nested intervals that will be performed at some specific time or over a period of time.

This is essentially similar to the Python “Interval” class, but it is implemented in C++ (hence the name). Intervals that may be implemented in C++ will inherit from this class; Intervals that must be implemented in Python will inherit from the similar Python class.

Inheritance diagram

__init__(param0: CInterval) → None
getName() → str

Returns the interval’s name.

getDuration() → float

Returns the duration of the interval in seconds.

getOpenEnded() → bool

Returns the state of the “open_ended” flag. This is primarily intended for instantaneous intervals like FunctionIntervals; it indicates true if the interval has some lasting effect that should be applied even if the interval doesn’t get started until after its finish time, or false if the interval is a transitive thing that doesn’t need to be called late.

getState() → State

Indicates the state the interval believes it is in: whether it has been started, is currently in the middle, or has been finalized.

Return type

State

isStopped() → bool

Returns true if the interval is in either its initial or final states (but not in a running or paused state).

setDoneEvent(event: str) → None

Sets the event that is generated whenever the interval reaches its final state, whether it is explicitly finished or whether it gets there on its own.

getDoneEvent() → str

Returns the event that is generated whenever the interval reaches its final state, whether it is explicitly finished or whether it gets there on its own.

setT(t: float) → None

Explicitly sets the time within the interval. Normally, you would use start() .. finish() to let the time play normally, but this may be used to set the time to some particular value.

getT() → float

Returns the current time of the interval: the last value of t passed to privInitialize(), privStep(), or privFinalize().

setAutoPause(auto_pause: bool) → None

Changes the state of the ‘auto_pause’ flag. If this is true, the interval may be arbitrarily interrupted when the system needs to reset due to some external event by calling CIntervalManager.interrupt(). If this is false (the default), the interval must always be explicitly finished or paused.

getAutoPause() → bool

Returns the state of the ‘auto_pause’ flag. See setAutoPause().

setAutoFinish(auto_finish: bool) → None

Changes the state of the ‘auto_finish’ flag. If this is true, the interval may be arbitrarily finished when the system needs to reset due to some external event by calling CIntervalManager.interrupt(). If this is false (the default), the interval must always be explicitly finished or paused.

getAutoFinish() → bool

Returns the state of the ‘auto_finish’ flag. See setAutoFinish().

setWantsTCallback(wants_t_callback: bool) → None

Changes the state of the ‘wants_t_callback’ flag. If this is true, the interval will be returned by CIntervalManager::get_event() each time the interval’s time value has been changed, regardless of whether it has any external events.

getWantsTCallback() → bool

Returns the state of the ‘wants_t_callback’ flag. See setWantsTCallback().

setManager(manager: CIntervalManager) → None

Indicates the CIntervalManager object which will be responsible for playing this interval. This defaults to the global CIntervalManager; you should need to change this only if you have special requirements for playing this interval.

getManager() → CIntervalManager

Returns the CIntervalManager object which will be responsible for playing this interval. Note that this can only return a C++ object; if the particular CIntervalManager object has been extended in the scripting language, this will return the encapsulated C++ object, not the full extended object.

Return type

CIntervalManager

start(start_t: float, end_t: float, play_rate: float) → None

Starts the interval playing by registering it with the current CIntervalManager. The interval will play to the end and stop.

If end_t is less than zero, it indicates the end of the interval.

loop(start_t: float, end_t: float, play_rate: float) → None

Starts the interval playing by registering it with the current CIntervalManager. The interval will play until it is interrupted with finish() or pause(), looping back to start_t when it reaches end_t.

If end_t is less than zero, it indicates the end of the interval.

pause() → float

Stops the interval from playing but leaves it in its current state. It may later be resumed from this point by calling resume().

resume() → None

Restarts the interval from its current point after a previous call to pause().

resume(start_t: float) → None

Restarts the interval from the indicated point after a previous call to pause().

resumeUntil(end_t: float) → None

Restarts the interval from the current point after a previous call to pause() (or a previous play-to-point-and-stop), to play until the indicated point and then stop.

finish() → None

Stops the interval from playing and sets it to its final state.

clearToInitial() → None

Pauses the interval, if it is playing, and resets its state to its initial state, abandoning any state changes already in progress in the middle of the interval. Calling this is like pausing the interval and discarding it, creating a new one in its place.

isPlaying() → bool

Returns true if the interval is currently playing, false otherwise.

getPlayRate() → float

Returns the play rate as set by the last call to start(), loop(), or setPlayRate().

setPlayRate(play_rate: float) → None

Changes the play rate of the interval. If the interval is already started, this changes its speed on-the-fly. Note that since play_rate is a parameter to start() and loop(), the next call to start() or loop() will reset this parameter.

privDoEvent(t: float, event: EventType) → None

These cannot be declared private because they must be accessible to Python, but the method names are prefixed with priv_ to remind you that you probably don’t want to be using them directly.

privInitialize(t: float) → None

This replaces the first call to privStep(), and indicates that the interval has just begun. This may be overridden by derived classes that need to do some explicit initialization on the first call.

privInstant() → None

This is called in lieu of privInitialize() .. privStep() .. privFinalize(), when everything is to happen within one frame. The interval should initialize itself, then leave itself in the final state.

privStep(t: float) → None

Advances the time on the interval. The time may either increase (the normal case) or decrease (e.g. if the interval is being played by a slider).

privFinalize() → None

This is called to stop an interval, forcing it to whatever state it would be after it played all the way through. It’s generally invoked by set_final_t().

privReverseInitialize(t: float) → None

Similar to privInitialize(), but this is called when the interval is being played backwards; it indicates that the interval should start at the finishing state and undo any intervening intervals.

privReverseInstant() → None

This is called in lieu of privReverseInitialize() .. privStep() .. privReverseFinalize(), when everything is to happen within one frame. The interval should initialize itself, then leave itself in the initial state.

privReverseFinalize() → None

Called generally following a privReverseInitialize(), this indicates the interval should set itself to the initial state.

privInterrupt() → None

This is called while the interval is playing to indicate that it is about to be interrupted; that is, privStep() will not be called for a length of time. But the interval should remain in its current state in anticipation of being eventually restarted when the calls to privStep() eventually resume.

The purpose of this function is to allow self-running intervals like sound intervals to stop the actual sound playback during the pause.

output(out: ostream) → None
write(out: ostream, indent_level: int) → None
setupPlay(start_time: float, end_time: float, play_rate: float, do_loop: bool) → None

Called to prepare the interval for automatic timed playback, e.g. via a Python task. The interval will be played from start_t to end_t, at a time factor specified by play_rate. start_t must always be less than end_t (except for the exception for end_t == -1, below), but if play_rate is negative the interval will be played backwards.

Specify end_t of -1 to play the entire interval from start_t.

Call stepPlay() repeatedly to execute the interval.

setupResume() → None

Called to prepare the interval for restarting at the current point within the interval after an interruption.

setupResumeUntil(end_t: float) → None

Called to prepare the interval for restarting from the current point after a previous call to pause() (or a previous play-to-point-and-stop), to play until the indicated point and then stop.

stepPlay() → bool

Should be called once per frame to execute the automatic timed playback begun with setupPlay().

Returns true if the interval should continue, false if it is done and should stop.

static getClassType() → TypeHandle
Return type

TypeHandle

property name

Returns the interval’s name.

Return type

string

property duration

Returns the duration of the interval in seconds.

Return type

float

property open_ended

Returns the state of the “open_ended” flag. This is primarily intended for instantaneous intervals like FunctionIntervals; it indicates true if the interval has some lasting effect that should be applied even if the interval doesn’t get started until after its finish time, or false if the interval is a transitive thing that doesn’t need to be called late.

Return type

bool

property state

Indicates the state the interval believes it is in: whether it has been started, is currently in the middle, or has been finalized.

Return type

State

property stopped

Returns true if the interval is in either its initial or final states (but not in a running or paused state).

Return type

bool

property done_event
Getter

Returns the event that is generated whenever the interval reaches its final state, whether it is explicitly finished or whether it gets there on its own.

Setter

Sets the event that is generated whenever the interval reaches its final state, whether it is explicitly finished or whether it gets there on its own.

Return type

string

property t
Getter

Returns the current time of the interval: the last value of t passed to privInitialize(), privStep(), or privFinalize().

Setter

Explicitly sets the time within the interval. Normally, you would use start() .. finish() to let the time play normally, but this may be used to set the time to some particular value.

Return type

float

property auto_pause
Getter

Returns the state of the ‘auto_pause’ flag. See setAutoPause().

Setter

Changes the state of the ‘auto_pause’ flag. If this is true, the interval may be arbitrarily interrupted when the system needs to reset due to some external event by calling CIntervalManager.interrupt(). If this is false (the default), the interval must always be explicitly finished or paused.

Return type

bool

property auto_finish
Getter

Returns the state of the ‘auto_finish’ flag. See setAutoFinish().

Setter

Changes the state of the ‘auto_finish’ flag. If this is true, the interval may be arbitrarily finished when the system needs to reset due to some external event by calling CIntervalManager.interrupt(). If this is false (the default), the interval must always be explicitly finished or paused.

Return type

bool

property manager
Getter

Returns the CIntervalManager object which will be responsible for playing this interval. Note that this can only return a C++ object; if the particular CIntervalManager object has been extended in the scripting language, this will return the encapsulated C++ object, not the full extended object.

Setter

Indicates the CIntervalManager object which will be responsible for playing this interval. This defaults to the global CIntervalManager; you should need to change this only if you have special requirements for playing this interval.

Return type

CIntervalManager

property play_rate
Getter

Returns the play rate as set by the last call to start(), loop(), or setPlayRate().

Setter

Changes the play rate of the interval. If the interval is already started, this changes its speed on-the-fly. Note that since play_rate is a parameter to start() and loop(), the next call to start() or loop() will reset this parameter.

Return type

float

property playing

Returns true if the interval is currently playing, false otherwise.

Return type

bool

enum EventType
enumerator ET_initialize = 0
enumerator ET_instant = 1
enumerator ET_step = 2
enumerator ET_finalize = 3
enumerator ET_reverse_initialize = 4
enumerator ET_reverse_instant = 5
enumerator ET_reverse_finalize = 6
enumerator ET_interrupt = 7
enum State
enumerator S_initial = 0
enumerator S_started = 1
enumerator S_paused = 2
enumerator S_final = 3