#include <animControl.h>
Inheritance diagram for AnimControl:
Public Member Functions | |
AnimControl (PartBundle *part, AnimBundle *anim, int channel_index) | |
~AnimControl () | |
void | play (const CPT_Event &stop_event=NULL) |
Runs the entire animation from beginning to end and stops, throwing the stop event (if it is non-NULL). | |
void | play (int from, int to, const CPT_Event &stop_event=NULL) |
Runs the animation from the frame "from" to and including the frame "to", at which point the animation is stopped and the indicated stop event is thrown (if it is non-NULL). | |
void | loop (bool restart) |
Starts the entire animation looping. | |
void | loop (bool restart, int from, int to) |
Loops the animation from the frame "from" to and including the frame "to", indefinitely. | |
void | pingpong (bool restart, int from, int to) |
Loops the animation from the frame "from" to and including the frame "to", and then back in the opposite direction, indefinitely. | |
void | stop () |
Stops a currently playing or looping animation right where it is. | |
void | pose (int frame) |
Sets the animation to the indicated frame and holds it there. | |
void | add_event (int frame, const CPT_Event &event) |
Adds the indicated event to the list of events that will be called whenever the animation reaches the indicated frame number. | |
int | remove_event (const string &event_name) |
Removes all events found that match the indicated event name, and returns the number of events removed. | |
void | remove_all_events () |
Removes all user-defined event messages. | |
void | set_play_rate (double play_rate) |
Sets the speed of the animation, relative to its "normal" speed. | |
double | get_play_rate () const |
Returns the current speed of the animation. | |
double | get_frame_rate () const |
Returns the actual frame rate of the animation, based on the play_rate (see set_play_rate()) and the animation's base frame rate (see AnimBundle::get_base_frame_rate()). | |
int | get_frame () const |
Returns the current frame number of the animation. | |
int | get_num_frames () const |
Returns the number of frames of animation. | |
bool | is_playing () const |
Returns true if the AnimControl is currently playing, false otherwise. | |
PartBundle * | get_part () const |
Returns the PartBundle bound in with this AnimControl. | |
AnimBundle * | get_anim () const |
Returns the AnimBundle bound in with this AnimControl. | |
void | advance_time (double time) |
Tells the AnimControl what time it is. | |
bool | channel_has_changed (AnimChannelBase *channel) const |
Returns true if the indicated channel value has changed since the last call to mark_channels(). | |
void | mark_channels () |
Marks this point as the point of reference for the next call to channel_has_changed(). | |
int | get_channel_index () const |
void | output (ostream &out) const |
int | get_ref_count () const |
Returns the current reference count. | |
int | ref () const |
Explicitly increments the reference count. | |
int | unref () const |
Explicitly decrements the reference count. | |
void | test_ref_count_integrity () const |
Does some easy checks to make sure that the reference count isn't completely bogus. | |
Static Public Member Functions | |
TypeHandle | get_class_type () |
void | init_type () |
Private Types | |
typedef pmultimap< int, Action > | Actions |
enum | ActionType { AT_event, AT_stop, AT_jump, AT_forward, AT_backward } |
Private Member Functions | |
void | set_frame (double frame) |
Sets the current frame number to the indicated frame, and performs any actions on that frame. | |
bool | do_actions_forward (int from, int to) |
Calls each of the actions, in turn, on the timeline between the indicated "from" frame and the indicated "to" frame, inclusive. | |
bool | do_actions_backward (int from, int to) |
Calls each of the actions, in turn, on the timeline between the indicated "from" frame and the indicated "to" frame, in reverse order. | |
void | do_action (int frame, const Action &action, int &sequence_frame, const Action *&sequence_action) |
Performs a single action. | |
void | do_sequence_action (int frame, const Action &action) |
Performs an action that was saved from do_action(), above. | |
Static Private Member Functions | |
void | insert_event_action (Actions &actions, int frame, const CPT_Event &event) |
Inserts an "event" action at the indicated frame number. | |
void | insert_stop_action (Actions &actions, int frame) |
Inserts a "stop" action at the indicated frame number. | |
void | insert_jump_action (Actions &actions, int frame, int jump_to) |
Inserts a "jump" action at the indicated frame number. | |
void | insert_forward_action (Actions &actions, int frame) |
Inserts a "forward" action at the indicated frame number. | |
void | insert_backward_action (Actions &actions, int frame) |
Inserts a "backward" action at the indicated frame number. | |
Private Attributes | |
Actions | _actions |
Actions | _user_actions |
PointerTo< PartGroup > | _part |
PointerTo< AnimBundle > | _anim |
int | _channel_index |
double | _play_rate |
double | _frame |
double | _as_of_time |
bool | _playing |
int | _marked_frame |
Static Private Attributes | |
TypeHandle | _type_handle |
Friends | |
class | AnimControl::Action |
ostream & | operator<< (ostream &, const AnimControl::Action &) |
An AnimControl object is created for each character/bundle binding and manages the state of the animation: whether started, stopped, or looping, and the current frame number and play rate.
Definition at line 57 of file animControl.h.
|
Definition at line 125 of file animControl.h. |
|
Definition at line 103 of file animControl.h. |
|
Definition at line 42 of file animControl.cxx. References _anim, _as_of_time, _channel_index, _frame, _marked_frame, _part, _play_rate, and _playing. |
|
Definition at line 67 of file animControl.cxx. References get_num_frames(), get_play_rate(), nassertv, and play(). |
|
Adds the indicated event to the list of events that will be called whenever the animation reaches the indicated frame number. Once added, the event will persist until it is removed via remove_event() or remove_all_events(). Definition at line 336 of file animControl.cxx. |
|
Tells the AnimControl what time it is. This recomputes the frame number according to the amount of time elapsed since last time. Until this function is called, the frame number will not increment. The time passed to this function must be nondecreasing; it is an error to call it with a value less than a previously-passed value. Definition at line 455 of file animControl.cxx. References _marked_frame, and get_frame(). |
|
Returns true if the indicated channel value has changed since the last call to mark_channels().
Definition at line 520 of file animControl.cxx. References AT_jump. Referenced by MovingPartBase::write_with_value(). |
|
Performs a single action. If the action involves some resequencing behavior--stopping, or jumping around to a new frame or something--does nothing immediately, but instead sets sequence_frame and sequence_action to the current frame number and action, so they may be executed later (after all the other actions this frame have been executed). Definition at line 827 of file animControl.cxx. |
|
Calls each of the actions, in turn, on the timeline between the indicated "from" frame and the indicated "to" frame, in reverse order. If any of the actions specifies to stop the animation, the animation is stopped, the current frame number is set to the point of stopping, no further actions are called, and false is returned. Otherwise, true is returned. Definition at line 767 of file animControl.cxx. References AT_backward, and AT_forward. |
|
Calls each of the actions, in turn, on the timeline between the indicated "from" frame and the indicated "to" frame, inclusive. If any of the actions specifies to stop the animation, the animation is stopped, the current frame number is set to the point of stopping, no further actions are called, and false is returned. Otherwise, true is returned. Definition at line 712 of file animControl.cxx. Referenced by output(). |
|
Performs an action that was saved from do_action(), above. This action presumably does some mucking around with the frame number or something, so we needed to do all the other actions associated with that frame first. Definition at line 881 of file animControl.cxx. Referenced by insert_forward_action(). |
|
Returns the AnimBundle bound in with this AnimControl.
Definition at line 159 of file animControl.I. Referenced by set_play_rate(). |
|
Definition at line 171 of file animControl.I. Referenced by MovingPartBase::write_with_value(). |
|
Reimplemented from ReferenceCount. Definition at line 167 of file animControl.h. |
|
Returns the current frame number of the animation.
Definition at line 105 of file animControl.I. Referenced by advance_time(), AnimControlCollection::loop(), output(), and AnimControlCollection::stop(). |
|
Returns the actual frame rate of the animation, based on the play_rate (see set_play_rate()) and the animation's base frame rate (see AnimBundle::get_base_frame_rate()). This is in frames per second. Definition at line 92 of file animControl.I. |
|
Returns the number of frames of animation. This is actually just extracted directly from the AnimBundle; the function is duplicated here for convenience. The frame number will never be outside the range 0 <= frame < get_num_frames(). Definition at line 129 of file animControl.I. Referenced by AnimControlCollection::get_frame(), loop(), pingpong(), play(), and ~AnimControl(). |
|
Returns the PartBundle bound in with this AnimControl.
Definition at line 429 of file animControl.cxx. Referenced by pingpong(), and play(). |
|
Returns the current speed of the animation. See set_play_rate(). Definition at line 71 of file animControl.I. References _frame, cfloor(), and INLINE. Referenced by loop(), play(), set_play_rate(), and ~AnimControl(). |
|
Returns the current reference count.
Definition at line 183 of file referenceCount.I. Referenced by RenderState::determine_bin_index(), RenderEffects::determine_show_bounds(), FontPool::ns_garbage_collect(), TexturePool::ns_garbage_collect(), MaterialPool::ns_get_material(), and TexturePool::ns_release_texture(). |
|
Reimplemented from ReferenceCount. Definition at line 170 of file animControl.h. |
|
Inserts a "backward" action at the indicated frame number. When the animation hits this action while playing in a forward direction, it will stop and play in a backward direction instead. Definition at line 667 of file animControl.cxx. References AnimControl::Action::_type, AT_jump, and AT_stop. |
|
Inserts an "event" action at the indicated frame number. The event will be thrown as the animation reaches the indicated frame number. Definition at line 578 of file animControl.cxx. References _actions. Referenced by play(). |
|
Inserts a "forward" action at the indicated frame number. When the animation hits this action while playing in a backward direction, it will stop and play in a forward direction instead. Definition at line 646 of file animControl.cxx. References do_sequence_action(). |
|
Inserts a "jump" action at the indicated frame number. When the animation reaches the indicated frame number, it will jump to the indicated jump_to frame. It will not seem to spend any time at the reached frame number. Definition at line 624 of file animControl.cxx. References _actions. Referenced by loop(). |
|
Inserts a "stop" action at the indicated frame number. The animation will stop as soon as it reaches the indicated frame number, traveling from either direction. Definition at line 600 of file animControl.cxx. Referenced by play(). |
|
Returns true if the AnimControl is currently playing, false otherwise.
Definition at line 144 of file animControl.I. |
|
Loops the animation from the frame "from" to and including the frame "to", indefinitely. If restart is true, the animation is restarted from the beginning; otherwise, it continues from the current frame. Definition at line 180 of file animControl.cxx. |
|
Starts the entire animation looping. If restart is true, the animation is restarted from the beginning; otherwise, it continues from the current frame. Definition at line 145 of file animControl.cxx. References _actions, _as_of_time, _playing, _user_actions, ClockObject::get_frame_time(), ClockObject::get_global_clock(), get_num_frames(), get_play_rate(), insert_jump_action(), and nassertv. Referenced by AnimControlCollection::play(). |
|
Marks this point as the point of reference for the next call to channel_has_changed().
Definition at line 546 of file animControl.cxx. References AnimControl::Action::_type, and AT_backward. Referenced by PartBundle::bind_anim(). |
|
Definition at line 558 of file animControl.cxx. References _frame, do_actions_forward(), and get_frame(). |
|
Loops the animation from the frame "from" to and including the frame "to", and then back in the opposite direction, indefinitely.
Definition at line 250 of file animControl.cxx. References _actions, _as_of_time, _playing, cfloor(), PartBundle::control_activated(), ClockObject::get_frame_time(), ClockObject::get_global_clock(), get_num_frames(), get_part(), nassertv, num_frames, and set_frame(). |
|
Runs the animation from the frame "from" to and including the frame "to", at which point the animation is stopped and the indicated stop event is thrown (if it is non-NULL). If the to frame is less than the from frame (unless play_rate is negative), the animation will wrap around the end and begins again at the beginning before the animation stops. Definition at line 114 of file animControl.cxx. References _actions, _as_of_time, _playing, _user_actions, PartBundle::control_activated(), ClockObject::get_frame_time(), ClockObject::get_global_clock(), get_num_frames(), get_part(), get_play_rate(), nassertv, and set_frame(). |
|
Runs the entire animation from beginning to end and stops, throwing the stop event (if it is non-NULL).
Definition at line 83 of file animControl.cxx. References _actions, _as_of_time, _playing, _user_actions, PartBundle::control_activated(), ClockObject::get_frame_time(), ClockObject::get_global_clock(), get_num_frames(), get_part(), insert_event_action(), insert_stop_action(), nassertv, and set_frame(). Referenced by AnimControlCollection::has_stop_event(), and ~AnimControl(). |
|
Sets the animation to the indicated frame and holds it there.
Definition at line 302 of file animControl.cxx. References AT_event. |
|
Explicitly increments the reference count. User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically. This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it. The return value is the new reference count. Definition at line 225 of file referenceCount.I. Referenced by ClientDevice::ClientDevice(), EggGroupNode::find_textures(), EggGroupNode::r_apply_texmats(), EggGroupNode::r_flatten_transforms(), and EggGroupNode::reverse_vertex_ordering(). |
|
Removes all user-defined event messages. However, if called while an animation is running, this will not take effect until the animation is stopped and restarted. Definition at line 414 of file animControl.cxx. |
|
Removes all events found that match the indicated event name, and returns the number of events removed.
Definition at line 356 of file animControl.cxx. |
|
Sets the current frame number to the indicated frame, and performs any actions on that frame.
Definition at line 685 of file animControl.cxx. References _play_rate, and AT_forward. Referenced by pingpong(), and play(). |
|
Sets the speed of the animation, relative to its "normal" speed. Setting this number to 2.0 plays it twice as fast, 0.5 half as fast. -1.0 plays it backwards, and 0.0 stops it. The change is actually retroactive to the last frame. If you are going to change the play_rate from a positive number to a negative number, or vice-versa, you should do this before starting the animation. The various flavors of play() and loop() do slightly different behavior based on whether play_rate is positive or negative. Definition at line 56 of file animControl.I. References get_anim(), AnimBundle::get_base_frame_rate(), get_play_rate(), and INLINE. |
|
Stops a currently playing or looping animation right where it is. The animation remains posed at the current frame, and no event is thrown. Definition at line 287 of file animControl.cxx. |
|
Does some easy checks to make sure that the reference count isn't completely bogus.
Definition at line 328 of file referenceCount.I. References INLINE. Referenced by EggNode::determine_bin(), and ReferenceCount::~ReferenceCount(). |
|
Explicitly decrements the reference count. Note that the object will not be implicitly deleted by unref() simply because the reference count drops to zero. (Having a member function delete itself is problematic; plus, we don't have a virtual destructor anyway.) However, see the helper function unref_delete(). User code should avoid using ref() and unref() directly, which can result in missed reference counts. Instead, let a PointerTo object manage the reference counting automatically. This function is const, even though it changes the object, because generally fiddling with an object's reference count isn't considered part of fiddling with the object. An object might be const in other ways, but we still need to accurately count the number of references to it. The return value is the new reference count. Definition at line 293 of file referenceCount.I. References INLINE. Referenced by RenderState::determine_bin_index(), and RenderEffects::determine_show_bounds(). |
|
Definition at line 180 of file animControl.h. |
|
Definition at line 188 of file animControl.h. |
|
Definition at line 142 of file animControl.h. Referenced by insert_event_action(), insert_jump_action(), loop(), pingpong(), and play(). |
|
Definition at line 149 of file animControl.h. Referenced by AnimControl(), and get_frame(). |
|
Definition at line 159 of file animControl.h. Referenced by AnimControl(), loop(), pingpong(), and play(). |
|
Definition at line 150 of file animControl.h. Referenced by AnimControl(). |
|
Definition at line 158 of file animControl.h. Referenced by AnimControl(), get_play_rate(), and output(). |
|
Definition at line 164 of file animControl.h. Referenced by advance_time(), and AnimControl(). |
|
Definition at line 148 of file animControl.h. Referenced by AnimControl(), and remove_event(). |
|
Definition at line 152 of file animControl.h. Referenced by AnimControl(), and set_frame(). |
|
Definition at line 161 of file animControl.h. Referenced by AnimControl(), loop(), pingpong(), and play(). |
|
Reimplemented from ReferenceCount. Definition at line 32 of file animControl.cxx. |
|
Definition at line 143 of file animControl.h. |