Panda3D
Public Types | Public Member Functions | Static Public Member Functions

CMetaInterval Class Reference

Inheritance diagram for CMetaInterval:
CInterval

List of all members.

Public Types

enum  DefType { DTCInterval = 0, DTExtIndex = 1, DTPushLevel = 2, DTPopLevel = 3 }
enum  EventType {
  ETInitialize = 0, ETInstant = 1, ETStep = 2, ETFinalize = 3,
  ETReverseInitialize = 4, ETReverseInstant = 5, ETReverseFinalize = 6, ETInterrupt = 7
}
enum  RelativeStart { RSPreviousEnd = 0, RSPreviousBegin = 1, RSLevelBegin = 2 }
enum  State { SInitial = 0, SStarted = 1, SPaused = 2, SFinal = 3 }

Public Member Functions

 CMetaInterval (string name)
int addCInterval (CInterval c_interval)
 Adds a new CInterval to the list.
int addCInterval (CInterval c_interval, double rel_time, RelativeStart rel_to)
 Adds a new CInterval to the list.
int addCInterval (CInterval c_interval, double rel_time)
 Adds a new CInterval to the list.
int addExtIndex (int ext_index, string name, double duration, bool open_ended, double rel_time, RelativeStart rel_to)
 Adds a new external interval to the list.
 clearIntervals ()
 Resets the list of intervals and prepares for receiving a new list.
 clearToInitial ()
 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.
 finish ()
 Stops the interval from playing and sets it to its final state.
bool getAutoFinish ()
 Returns the state of the 'auto_finish' flag.
bool getAutoPause ()
 Returns the state of the 'auto_pause' flag.
CInterval getCInterval (int n)
 Return the CInterval pointer associated with the nth interval definition.
DefType getDefType (int n)
 Returns the type of the nth interval definition that has been added.
string getDoneEvent ()
 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.
double getDuration ()
 Returns the duration of the interval in seconds.
int getEventIndex ()
 If a previous call to is_event_ready() returned true, this returns the index number (added via add_event_index()) of the external interval that needs to be played.
double getEventT ()
 If a previous call to is_event_ready() returned true, this returns the t value that should be fed to the given interval.
EventType getEventType ()
 If a previous call to is_event_ready() returned true, this returns the type of the event (initialize, step, finalize, etc.) for the given interval.
int getExtIndex (int n)
 Return the external interval index number associated with the nth interval definition.
double getIntervalEndTime (string name)
 Returns the actual end time, relative to the beginning of the interval, of the child interval with the given name, if found, or -1 if the interval is not found.
double getIntervalStartTime (string name)
 Returns the actual start time, relative to the beginning of the interval, of the child interval with the given name, if found, or -1 if the interval is not found.
CIntervalManager getManager ()
 Returns the CIntervalManager object which will be responsible for playing this interval.
string getName ()
 Returns the interval's name.
int getNumDefs ()
 Returns the number of interval and push/pop definitions that have been added to the meta interval.
bool getOpenEnded ()
 Returns the state of the "open_ended" flag.
double getPlayRate ()
 Returns the play rate as set by the last call to start(), loop(), or set_play_rate().
double getPrecision ()
 Returns the precision with which time measurements are compared.
State getState ()
 Indicates the state the interval believes it is in: whether it has been started, is currently in the middle, or has been finalized.
double getT ()
 Returns the current time of the interval: the last value of t passed to priv_initialize(), priv_step(), or priv_finalize().
bool getWantsTCallback ()
 Returns the state of the 'wants_t_callback' flag.
bool isEventReady ()
 Returns true if a recent call to priv_initialize(), priv_step(), or priv_finalize() has left some external intervals ready to play.
bool isPlaying ()
 Returns true if the interval is currently playing, false otherwise.
bool isStopped ()
 Returns true if the interval is in either its initial or final states (but not in a running or paused state).
 loop (double start_t, double end_t, double play_rate)
 Starts the interval playing by registering it with the current CIntervalManager.
 loop (double start_t, double end_t)
 Starts the interval playing by registering it with the current CIntervalManager.
 loop (double start_t)
 Starts the interval playing by registering it with the current CIntervalManager.
 loop ()
 Starts the interval playing by registering it with the current CIntervalManager.
 output (ostream out)
double pause ()
 Stops the interval from playing but leaves it in its current state.
 popEvent ()
 Acknowledges that the external interval on the top of the queue has been extracted, and is about to be serviced by the scripting language.
int popLevel (double duration)
 Finishes a level marked by a previous call to push_level(), and returns to the previous level.
int popLevel ()
 Finishes a level marked by a previous call to push_level(), and returns to the previous level.
 privDoEvent (double t, EventType event)
 privFinalize ()
 This is called to stop an interval, forcing it to whatever state it would be after it played all the way through.
 privInitialize (double t)
 This replaces the first call to priv_step(), and indicates that the interval has just begun.
 privInstant ()
 This is called in lieu of priv_initialize() .
 privInterrupt ()
 This is called while the interval is playing to indicate that it is about to be interrupted; that is, priv_step() will not be called for a length of time.
 privReverseFinalize ()
 Called generally following a priv_reverse_initialize(), this indicates the interval should set itself to the initial state.
 privReverseInitialize (double t)
 Similar to priv_initialize(), 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 ()
 This is called in lieu of priv_reverse_initialize()
 privStep (double t)
 Advances the time on the interval.
int pushLevel (string name, double rel_time, RelativeStart rel_to)
 Marks the beginning of a nested level of child intervals.
 resume (double start_t)
 Restarts the interval from the indicated point after a previous call to pause().
 resume ()
 Restarts the interval from its current point after a previous call to pause().
 resumeUntil (double end_t)
 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.
 setAutoFinish (bool auto_finish)
 Changes the state of the 'auto_finish' flag.
 setAutoPause (bool auto_pause)
 Changes the state of the 'auto_pause' flag.
 setDoneEvent (string event)
 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.
bool setIntervalStartTime (string name, double rel_time)
 Adjusts the start time of the child interval with the given name, if found.
bool setIntervalStartTime (string name, double rel_time, RelativeStart rel_to)
 Adjusts the start time of the child interval with the given name, if found.
 setManager (CIntervalManager manager)
 Indicates the CIntervalManager object which will be responsible for playing this interval.
 setPlayRate (double play_rate)
 Changes the play rate of the interval.
 setPrecision (double precision)
 Indicates the precision with which time measurements are compared.
 setT (double t)
 Explicitly sets the time within the interval.
 setupPlay (double start_time, double end_time, double play_rate, bool do_loop)
 Called to prepare the interval for automatic timed playback, e.g.
 setupResume ()
 Called to prepare the interval for restarting at the current point within the interval after an interruption.
 setupResumeUntil (double end_t)
 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.
 setWantsTCallback (bool wants_t_callback)
 Changes the state of the 'wants_t_callback' flag.
 start (double start_t)
 Starts the interval playing by registering it with the current CIntervalManager.
 start ()
 Starts the interval playing by registering it with the current CIntervalManager.
 start (double start_t, double end_t)
 Starts the interval playing by registering it with the current CIntervalManager.
 start (double start_t, double end_t, double play_rate)
 Starts the interval playing by registering it with the current CIntervalManager.
bool stepPlay ()
 Should be called once per frame to execute the automatic timed playback begun with setup_play().
 timeline (ostream out)
 Outputs a list of all events in the order in which they occur.
 write (ostream out, int indent_level)

Static Public Member Functions

static TypeHandle getClassType ()

Member Enumeration Documentation

enum DefType
Enumerator:
DTCInterval 
DTExtIndex 
DTPushLevel 
DTPopLevel 
enum EventType [inherited]
Enumerator:
ETInitialize 
ETInstant 
ETStep 
ETFinalize 
ETReverseInitialize 
ETReverseInstant 
ETReverseFinalize 
ETInterrupt 
Enumerator:
RSPreviousEnd 
RSPreviousBegin 
RSLevelBegin 
enum State [inherited]
Enumerator:
SInitial 
SStarted 
SPaused 
SFinal 

Constructor & Destructor Documentation

CMetaInterval ( string  name)

Member Function Documentation

int addCInterval ( CInterval  c_interval,
double  rel_time,
RelativeStart  rel_to 
)

Adds a new CInterval to the list.

The interval will be played when the indicated time (relative to the given point) has been reached.

The return value is the index of the def entry representing the new interval.

int addCInterval ( CInterval  c_interval,
double  rel_time 
)

Adds a new CInterval to the list.

The interval will be played when the indicated time (relative to the given point) has been reached.

The return value is the index of the def entry representing the new interval.

int addCInterval ( CInterval  c_interval)

Adds a new CInterval to the list.

The interval will be played when the indicated time (relative to the given point) has been reached.

The return value is the index of the def entry representing the new interval.

int addExtIndex ( int  ext_index,
string  name,
double  duration,
bool  open_ended,
double  rel_time,
RelativeStart  rel_to 
)

Adds a new external interval to the list.

This represents some object in the external scripting language that has properties similar to a CInterval (for instance, a Python Interval object).

The CMetaInterval object cannot play this external interval directly, but it records a placeholder for it and will ask the scripting language to play it when it is time, via is_event_ready() and related methods.

The ext_index number itself is simply a handle that the scripting language makes up and associates with its interval object somehow. The CMetaInterval object does not attempt to interpret this value.

The return value is the index of the def entry representing the new interval.

clearIntervals ( )

Resets the list of intervals and prepares for receiving a new list.

clearToInitial ( ) [inherited]

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.

finish ( ) [inherited]

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

bool getAutoFinish ( ) [inherited]

Returns the state of the 'auto_finish' flag.

See set_auto_finish().

bool getAutoPause ( ) [inherited]

Returns the state of the 'auto_pause' flag.

See set_auto_pause().

CInterval getCInterval ( int  n)

Return the CInterval pointer associated with the nth interval definition.

It is only valid to call this if get_def_type(n) returns DT_c_interval.

static TypeHandle getClassType ( ) [static]

Reimplemented from CInterval.

DefType getDefType ( int  n)

Returns the type of the nth interval definition that has been added.

string getDoneEvent ( ) [inherited]

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.

double getDuration ( ) [inherited]

Returns the duration of the interval in seconds.

int getEventIndex ( )

If a previous call to is_event_ready() returned true, this returns the index number (added via add_event_index()) of the external interval that needs to be played.

double getEventT ( )

If a previous call to is_event_ready() returned true, this returns the t value that should be fed to the given interval.

EventType getEventType ( )

If a previous call to is_event_ready() returned true, this returns the type of the event (initialize, step, finalize, etc.) for the given interval.

int getExtIndex ( int  n)

Return the external interval index number associated with the nth interval definition.

It is only valid to call this if get_def_type(n) returns DT_ext_index.

double getIntervalEndTime ( string  name)

Returns the actual end time, relative to the beginning of the interval, of the child interval with the given name, if found, or -1 if the interval is not found.

double getIntervalStartTime ( string  name)

Returns the actual start time, relative to the beginning of the interval, of the child interval with the given name, if found, or -1 if the interval is not found.

CIntervalManager getManager ( ) [inherited]

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.

string getName ( ) [inherited]

Returns the interval's name.

int getNumDefs ( )

Returns the number of interval and push/pop definitions that have been added to the meta interval.

bool getOpenEnded ( ) [inherited]

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.

double getPlayRate ( ) [inherited]

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

double getPrecision ( )

Returns the precision with which time measurements are compared.

See set_precision().

State getState ( ) [inherited]

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

double getT ( ) [inherited]

Returns the current time of the interval: the last value of t passed to priv_initialize(), priv_step(), or priv_finalize().

bool getWantsTCallback ( ) [inherited]

Returns the state of the 'wants_t_callback' flag.

See set_wants_t_callback().

bool isEventReady ( )

Returns true if a recent call to priv_initialize(), priv_step(), or priv_finalize() has left some external intervals ready to play.

If this returns true, call get_event_index(), get_event_t(), and pop_event() to retrieve the relevant information.

bool isPlaying ( ) [inherited]

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

bool isStopped ( ) [inherited]

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

loop ( double  start_t,
double  end_t,
double  play_rate 
) [inherited]

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.

loop ( double  start_t,
double  end_t 
) [inherited]

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.

loop ( double  start_t) [inherited]

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.

loop ( ) [inherited]

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.

output ( ostream  out) [inherited]
double pause ( ) [inherited]

Stops the interval from playing but leaves it in its current state.

It may later be resumed from this point by calling resume().

popEvent ( )

Acknowledges that the external interval on the top of the queue has been extracted, and is about to be serviced by the scripting language.

This prepares the interval so the next call to is_event_ready() will return information about the next external interval on the queue, if any.

int popLevel ( double  duration)

Finishes a level marked by a previous call to push_level(), and returns to the previous level.

If the duration is not negative, it represents a phony duration to assign to the level, for the purposes of sequencing later intervals. Otherwise, the level's duration is computed based on the intervals within the level.

int popLevel ( )

Finishes a level marked by a previous call to push_level(), and returns to the previous level.

If the duration is not negative, it represents a phony duration to assign to the level, for the purposes of sequencing later intervals. Otherwise, the level's duration is computed based on the intervals within the level.

privDoEvent ( double  t,
EventType  event 
) [inherited]
privFinalize ( ) [inherited]

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().

privInitialize ( double  t) [inherited]

This replaces the first call to priv_step(), 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 ( ) [inherited]

This is called in lieu of priv_initialize() .

. priv_step() .. priv_finalize(), when everything is to happen within one frame. The interval should initialize itself, then leave itself in the final state.

privInterrupt ( ) [inherited]

This is called while the interval is playing to indicate that it is about to be interrupted; that is, priv_step() 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 priv_step() 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.

privReverseFinalize ( ) [inherited]

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

privReverseInitialize ( double  t) [inherited]

Similar to priv_initialize(), 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 ( ) [inherited]

This is called in lieu of priv_reverse_initialize()

. priv_step() .. priv_reverse_finalize(), when everything is to happen within one frame. The interval should initialize itself, then leave itself in the initial state.

privStep ( double  t) [inherited]

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).

int pushLevel ( string  name,
double  rel_time,
RelativeStart  rel_to 
)

Marks the beginning of a nested level of child intervals.

Within the nested level, a RelativeStart time of RS_level_begin refers to the start of the level, and the first interval added within the level is always relative to the start of the level.

The return value is the index of the def entry created by this push.

resume ( ) [inherited]

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

resume ( double  start_t) [inherited]

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

resumeUntil ( double  end_t) [inherited]

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.

setAutoFinish ( bool  auto_finish) [inherited]

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.

setAutoPause ( bool  auto_pause) [inherited]

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.

setDoneEvent ( string  event) [inherited]

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.

bool setIntervalStartTime ( string  name,
double  rel_time,
RelativeStart  rel_to 
)

Adjusts the start time of the child interval with the given name, if found.

This may be either a C++ interval added via add_c_interval(), or an external interval added via add_ext_index(); the name must match exactly.

If the interval is found, its start time is adjusted, and all subsequent intervals are adjusting accordingly, and true is returned. If a matching interval is not found, nothing is changed and false is returned.

bool setIntervalStartTime ( string  name,
double  rel_time 
)

Adjusts the start time of the child interval with the given name, if found.

This may be either a C++ interval added via add_c_interval(), or an external interval added via add_ext_index(); the name must match exactly.

If the interval is found, its start time is adjusted, and all subsequent intervals are adjusting accordingly, and true is returned. If a matching interval is not found, nothing is changed and false is returned.

setManager ( CIntervalManager  manager) [inherited]

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.

setPlayRate ( double  play_rate) [inherited]

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.

setPrecision ( double  precision)

Indicates the precision with which time measurements are compared.

For numerical accuracy, all floating-point time values are converted to integer values internally by scaling by the precision factor. The larger the number given here, the smaller the delta of time that can be differentiated; the limit is the maximum integer that can be represented in the system.

setT ( double  t) [inherited]

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.

setupPlay ( double  start_time,
double  end_time,
double  play_rate,
bool  do_loop 
) [inherited]

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 step_play() repeatedly to execute the interval.

setupResume ( ) [inherited]

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

setupResumeUntil ( double  end_t) [inherited]

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.

setWantsTCallback ( bool  wants_t_callback) [inherited]

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.

start ( ) [inherited]

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.

start ( double  start_t,
double  end_t,
double  play_rate 
) [inherited]

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.

start ( double  start_t,
double  end_t 
) [inherited]

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.

start ( double  start_t) [inherited]

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.

bool stepPlay ( ) [inherited]

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

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

timeline ( ostream  out)

Outputs a list of all events in the order in which they occur.

write ( ostream  out,
int  indent_level 
) [inherited]
 All Classes Namespaces Functions Variables Enumerations Enumerator Properties