Panda3D
|
Controls the timing of a character animation. More...
#include "animControl.h"
Public Member Functions | |
AnimControl (const string &name, PartBundle *part, double frame_rate, int num_frames) | |
This constructor is used to create a temporarily uninitialized AnimControl that will serve as a placeholder for an animation while the animation is being loaded during an asynchronous load-and-bind operation. | |
bool | channel_has_changed (AnimChannelBase *channel, bool frame_blend_flag) const |
Returns true if the indicated channel value has changed since the last call to mark_channels(). | |
void | fail_anim (PartBundle *part) |
This can only be called once for a given AnimControl. | |
virtual TypeHandle | force_init_type () |
AnimBundle * | get_anim () const |
Returns the AnimBundle bound in with this AnimControl. | |
PandaNode * | get_anim_model () const |
Retrieves the pointer set via set_anim_model(). | |
const BitArray & | get_bound_joints () const |
Returns the subset of joints controlled by this AnimControl. | |
int | get_channel_index () const |
Returns the particular channel index associated with this AnimControl. | |
PartBundle * | get_part () const |
Returns the PartBundle bound in with this AnimControl. | |
string | get_pending_done_event () const |
Returns the event name that will be thrown when the AnimControl is finished binding asynchronously. | |
virtual TypeHandle | get_type () const |
bool | has_anim () const |
Returns true if the AnimControl was successfully loaded, or false if there was a problem. | |
bool | is_pending () const |
Returns true if the AnimControl is being bound asynchronously, and has not yet finished. | |
void | mark_channels (bool frame_blend_flag) |
Marks this point as the point of reference for the next call to channel_has_changed(). | |
virtual void | output (ostream &out) const |
Outputs the Namable. | |
void | set_anim_model (PandaNode *model) |
Associates the indicated PandaNode with the AnimControl. | |
void | set_bound_joints (const BitArray &bound_joints) |
Called to initialize the AnimControl with its array of bound_joints, before setup_anim() has completed. | |
void | set_pending_done_event (const string &done_event) |
Specifies an event name that will be thrown when the AnimControl is finished binding asynchronously. | |
void | setup_anim (PartBundle *part, AnimBundle *anim, int channel_index, const BitArray &bound_joints) |
This can only be called once for a given AnimControl. | |
void | wait_pending () |
Blocks the current thread until the AnimControl has finished loading and is fully bound. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Protected Member Functions | |
virtual void | animation_activated () |
This is provided as a callback method for when the user calls one of the play/loop/pose type methods to start the animation playing. |
Controls the timing of a character animation.
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 41 of file animControl.h.
AnimControl::AnimControl | ( | const string & | name, |
PartBundle * | part, | ||
double | frame_rate, | ||
int | num_frames | ||
) |
This constructor is used to create a temporarily uninitialized AnimControl that will serve as a placeholder for an animation while the animation is being loaded during an asynchronous load-and-bind operation.
Definition at line 35 of file animControl.cxx.
References AnimInterface::set_frame_rate(), and AnimInterface::set_num_frames().
void AnimControl::animation_activated | ( | ) | [protected, virtual] |
This is provided as a callback method for when the user calls one of the play/loop/pose type methods to start the animation playing.
Reimplemented from AnimInterface.
Definition at line 249 of file animControl.cxx.
References PartBundle::control_activated(), and get_part().
bool AnimControl::channel_has_changed | ( | AnimChannelBase * | channel, |
bool | frame_blend_flag | ||
) | const |
Returns true if the indicated channel value has changed since the last call to mark_channels().
Definition at line 212 of file animControl.cxx.
References AnimInterface::get_frac(), AnimInterface::get_frame(), and AnimChannelBase::has_changed().
Referenced by MovingPartBase::do_update().
void AnimControl::fail_anim | ( | PartBundle * | part | ) |
This can only be called once for a given AnimControl.
It indicates the attempt to bind it asynchronously has failed.
Definition at line 104 of file animControl.cxx.
References ConditionVarFullDirect::notify_all().
AnimBundle * AnimControl::get_anim | ( | ) | const [inline] |
Returns the AnimBundle bound in with this AnimControl.
Definition at line 50 of file animControl.I.
PandaNode * AnimControl::get_anim_model | ( | ) | const [inline] |
Retrieves the pointer set via set_anim_model().
See set_anim_model().
Definition at line 115 of file animControl.I.
const BitArray & AnimControl::get_bound_joints | ( | ) | const [inline] |
Returns the subset of joints controlled by this AnimControl.
Most of the time, this will be BitArray::all_on(), for a normal full-body animation. For a subset animation, however, this will be just a subset of those bits, corresponding to the set of joints and sliders actually bound (as enumerated by bind_hierarchy() in depth-first LIFO order).
Definition at line 83 of file animControl.I.
int AnimControl::get_channel_index | ( | ) | const [inline] |
Returns the particular channel index associated with this AnimControl.
This channel index is the slot on which each AnimGroup is bound to its associated PartGroup, for each joint in the animation.
It will be true that get_part()->find_child("n")->get_bound(get_channel_index()) == get_anim()->find_child("n"), for each joint "n".
Definition at line 67 of file animControl.I.
Referenced by MovingPartBase::determine_effective_channels(), MovingPartBase::do_update(), MovingPartScalar::get_blend_value(), and MovingPartMatrix::get_blend_value().
PartBundle * AnimControl::get_part | ( | ) | const |
Returns the PartBundle bound in with this AnimControl.
Definition at line 182 of file animControl.cxx.
Referenced by animation_activated(), PartBundle::control_activated(), and output().
string AnimControl::get_pending_done_event | ( | ) | const |
Returns the event name that will be thrown when the AnimControl is finished binding asynchronously.
Definition at line 170 of file animControl.cxx.
bool AnimControl::has_anim | ( | ) | const [inline] |
Returns true if the AnimControl was successfully loaded, or false if there was a problem.
This may return false while is_pending() is true.
Definition at line 39 of file animControl.I.
Referenced by output().
bool AnimControl::is_pending | ( | ) | const [inline] |
Returns true if the AnimControl is being bound asynchronously, and has not yet finished.
If this is true, the AnimControl's interface is still available and will be perfectly useful (though get_anim() might return NULL), but nothing visible will happen immediately.
Definition at line 27 of file animControl.I.
Referenced by output().
void AnimControl::mark_channels | ( | bool | frame_blend_flag | ) |
Marks this point as the point of reference for the next call to channel_has_changed().
Definition at line 233 of file animControl.cxx.
References AnimInterface::get_frac(), and AnimInterface::get_frame().
Referenced by PartBundle::force_update(), and PartBundle::update().
void AnimControl::output | ( | ostream & | out | ) | const [virtual] |
Outputs the Namable.
This function simply writes the name to the output stream; most Namable derivatives will probably redefine this.
Reimplemented from Namable.
Definition at line 192 of file animControl.cxx.
References get_part(), has_anim(), and is_pending().
void AnimControl::set_anim_model | ( | PandaNode * | model | ) | [inline] |
Associates the indicated PandaNode with the AnimControl.
By convention, this node represents the root node of the model file that corresponds to this AnimControl's animation file, though nothing in this code makes this assumption or indeed does anything with this node.
The purpose of this is simply to allow the AnimControl to keep a reference count on the ModelRoot node that generated it, so that the model will not disappear from the model pool until it is no longer referenced.
Definition at line 104 of file animControl.I.
void AnimControl::set_bound_joints | ( | const BitArray & | bound_joints | ) |
Called to initialize the AnimControl with its array of bound_joints, before setup_anim() has completed.
Definition at line 91 of file animControl.cxx.
void AnimControl::set_pending_done_event | ( | const string & | done_event | ) |
Specifies an event name that will be thrown when the AnimControl is finished binding asynchronously.
If the AnimControl has already finished binding, the event will be thrown immediately.
Definition at line 155 of file animControl.cxx.
void AnimControl::setup_anim | ( | PartBundle * | part, |
AnimBundle * | anim, | ||
int | channel_index, | ||
const BitArray & | bound_joints | ||
) |
This can only be called once for a given AnimControl.
It is used to supply the AnimBundle and related information.
Definition at line 64 of file animControl.cxx.
References ConditionVarFullDirect::notify_all(), AnimInterface::set_frame_rate(), and AnimInterface::set_num_frames().
Referenced by PartBundle::do_bind_anim().
void AnimControl::wait_pending | ( | ) |
Blocks the current thread until the AnimControl has finished loading and is fully bound.
Definition at line 131 of file animControl.cxx.
References Thread::get_current_thread(), and ConditionVarFullDirect::wait().
Referenced by PartBundle::wait_pending().