Panda3D
Public Member Functions | Static Public Member Functions | List of all members
AnimControl Class Reference

Controls the timing of a character animation. More...

#include "animControl.h"

Inheritance diagram for AnimControl:
TypedReferenceCount AnimInterface Namable TypedObject ReferenceCount MemoryBase MemoryBase MemoryBase

Public Member Functions

 AnimControl (const std::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. More...
 
 AnimControl (const AnimControl &copy)=delete
 
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(). More...
 
void fail_anim (PartBundle *part)
 This can only be called once for a given AnimControl. More...
 
virtual TypeHandle force_init_type ()
 
AnimBundleget_anim () const
 Returns the AnimBundle bound in with this AnimControl. More...
 
PandaNodeget_anim_model () const
 Retrieves the pointer set via set_anim_model(). More...
 
const BitArrayget_bound_joints () const
 Returns the subset of joints controlled by this AnimControl. More...
 
int get_channel_index () const
 Returns the particular channel index associated with this AnimControl. More...
 
PartBundleget_part () const
 Returns the PartBundle bound in with this AnimControl. More...
 
std::string get_pending_done_event () const
 Returns the event name that will be thrown when the AnimControl is finished binding asynchronously. More...
 
virtual TypeHandle get_type () const
 
bool has_anim () const
 Returns true if the AnimControl was successfully loaded, or false if there was a problem. More...
 
bool is_pending () const
 Returns true if the AnimControl is being bound asynchronously, and has not yet finished. More...
 
void mark_channels (bool frame_blend_flag)
 Marks this point as the point of reference for the next call to channel_has_changed(). More...
 
virtual void output (std::ostream &out) const
 
void set_anim_model (PandaNode *model)
 Associates the indicated PandaNode with the AnimControl. More...
 
void set_bound_joints (const BitArray &bound_joints)
 Called to initialize the AnimControl with its array of bound_joints, before setup_anim() has completed. More...
 
void set_pending_done_event (const std::string &done_event)
 Specifies an event name that will be thrown when the AnimControl is finished binding asynchronously. More...
 
void setup_anim (PartBundle *part, AnimBundle *anim, int channel_index, const BitArray &bound_joints)
 This can only be called once for a given AnimControl. More...
 
void wait_pending ()
 Blocks the current thread until the AnimControl has finished loading and is fully bound. More...
 
- Public Member Functions inherited from TypedReferenceCount
 TypedReferenceCount (const TypedReferenceCount &copy)
 
void operator= (const TypedReferenceCount &copy)
 
- Public Member Functions inherited from TypedObject
 TypedObject (const TypedObject &copy)=default
 
TypedObjectas_typed_object ()
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
const TypedObjectas_typed_object () const
 Returns the object, upcast (if necessary) to a TypedObject pointer. More...
 
int get_best_parent_from_Set (const std::set< int > &) const
 
int get_type_index () const
 Returns the internal index number associated with this object's TypeHandle, a unique number for each different type. More...
 
bool is_exact_type (TypeHandle handle) const
 Returns true if the current object is the indicated type exactly. More...
 
bool is_of_type (TypeHandle handle) const
 Returns true if the current object is or derives from the indicated type. More...
 
TypedObjectoperator= (const TypedObject &copy)=default
 
- Public Member Functions inherited from ReferenceCount
int get_ref_count () const
 
WeakReferenceListget_weak_list () const
 Returns the WeakReferenceList associated with this ReferenceCount object. More...
 
bool has_weak_list () const
 Returns true if this particular ReferenceCount object has a WeakReferenceList created, false otherwise. More...
 
void local_object ()
 This function should be called, once, immediately after creating a new instance of some ReferenceCount-derived object on the stack. More...
 
void ref () const
 Explicitly increments the reference count. More...
 
bool ref_if_nonzero () const
 Atomically increases the reference count of this object if it is not zero. More...
 
bool test_ref_count_integrity () const
 Does some easy checks to make sure that the reference count isn't completely bogus. More...
 
bool test_ref_count_nonzero () const
 Does some easy checks to make sure that the reference count isn't zero, or completely bogus. More...
 
virtual bool unref () const
 Explicitly decrements the reference count. More...
 
WeakReferenceListweak_ref ()
 Adds the indicated PointerToVoid as a weak reference to this object. More...
 
void weak_unref ()
 Removes the indicated PointerToVoid as a weak reference to this object. More...
 
- Public Member Functions inherited from AnimInterface
double get_frac () const
 
int get_frame () const
 
double get_frame_rate () const
 
double get_full_fframe () const
 
int get_full_frame () const
 
int get_next_frame () const
 
virtual int get_num_frames () const
 
double get_play_rate () const
 
bool is_playing () const
 
void loop (bool restart)
 Starts the entire animation looping. More...
 
void loop (bool restart, double from, double to)
 Loops the animation from the frame "from" to and including the frame "to", indefinitely. More...
 
void pingpong (bool restart)
 Starts the entire animation bouncing back and forth between its first frame and last frame. More...
 
void pingpong (bool restart, double from, double to)
 Loops the animation from the frame "from" to and including the frame "to", and then back in the opposite direction, indefinitely. More...
 
void play ()
 Runs the entire animation from beginning to end and stops. More...
 
void play (double from, double to)
 Runs the animation from the frame "from" to and including the frame "to", at which point the animation is stopped. More...
 
void pose (double frame)
 Sets the animation to the indicated frame and holds it there. More...
 
void set_play_rate (double play_rate)
 
void stop ()
 Stops a currently playing or looping animation right where it is. More...
 
- Public Member Functions inherited from Namable
 Namable (const std::string &initial_name="")
 
void clear_name ()
 Resets the Namable's name to empty. More...
 
const std::string & get_name () const
 
bool has_name () const
 Returns true if the Namable has a nonempty name set, false if the name is empty. More...
 
void output (std::ostream &out) const
 Outputs the Namable. More...
 
void set_name (const std::string &name)
 

Static Public Member Functions

static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from TypedObject
static TypeHandle get_class_type ()
 
static void init_type ()
 This function is declared non-inline to work around a compiler bug in g++ 2.96. More...
 
- Static Public Member Functions inherited from ReferenceCount
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from AnimInterface
static TypeHandle get_class_type ()
 
static void init_type ()
 
- Static Public Member Functions inherited from Namable
static TypeHandle get_class_type ()
 
static void init_type ()
 

Additional Inherited Members

- Public Attributes inherited from TypedObject
 get_type
 
- Public Attributes inherited from ReferenceCount
 get_ref_count
 Returns the current reference count. More...
 
- Public Attributes inherited from AnimInterface
 get_frac
 Returns the fractional part of the current frame. More...
 
 get_frame
 Returns the current integer frame number. More...
 
 get_frame_rate
 Returns the native frame rate of the animation. More...
 
 get_full_fframe
 Returns the current floating-point frame number. More...
 
 get_full_frame
 Returns the current integer frame number. More...
 
 get_next_frame
 Returns the current integer frame number + 1, constrained to the range 0 <= f < get_num_frames(). More...
 
 get_num_frames
 Returns the number of frames in the animation. More...
 
 get_play_rate
 Returns the rate at which the animation plays. More...
 
 is_playing
 Returns true if the animation is currently playing, false if it is stopped (e.g. More...
 
 set_play_rate
 Changes the rate at which the animation plays. More...
 
- Public Attributes inherited from Namable
 get_name
 
 set_name
 

Detailed Description

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 38 of file animControl.h.

Constructor & Destructor Documentation

◆ AnimControl()

AnimControl::AnimControl ( const std::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 30 of file animControl.cxx.

References MemoryUsage::update_type().

Member Function Documentation

◆ channel_has_changed()

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 182 of file animControl.cxx.

References AnimInterface::get_frac, AnimInterface::get_frame, and AnimChannelBase::has_changed().

Referenced by MovingPartBase::do_update().

◆ fail_anim()

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 91 of file animControl.cxx.

◆ get_anim()

AnimBundle * AnimControl::get_anim ( ) const
inline

Returns the AnimBundle bound in with this AnimControl.

Definition at line 38 of file animControl.I.

◆ get_anim_model()

PandaNode * AnimControl::get_anim_model ( ) const
inline

Retrieves the pointer set via set_anim_model().

See set_anim_model().

Definition at line 87 of file animControl.I.

◆ get_bound_joints()

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 64 of file animControl.I.

◆ get_channel_index()

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 52 of file animControl.I.

Referenced by MovingPartBase::do_update().

◆ get_part()

PartBundle * AnimControl::get_part ( ) const

Returns the PartBundle bound in with this AnimControl.

Definition at line 156 of file animControl.cxx.

◆ get_pending_done_event()

std::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 147 of file animControl.cxx.

◆ has_anim()

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 30 of file animControl.I.

◆ is_pending()

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 21 of file animControl.I.

◆ mark_channels()

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 201 of file animControl.cxx.

References AnimInterface::get_frac, and AnimInterface::get_frame.

Referenced by PartBundle::force_update(), and PartBundle::update().

◆ set_anim_model()

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 79 of file animControl.I.

◆ set_bound_joints()

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 81 of file animControl.cxx.

◆ set_pending_done_event()

void AnimControl::set_pending_done_event ( const std::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 134 of file animControl.cxx.

◆ setup_anim()

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 56 of file animControl.cxx.

◆ wait_pending()

void AnimControl::wait_pending ( )

Blocks the current thread until the AnimControl has finished loading and is fully bound.

Definition at line 114 of file animControl.cxx.

References ConditionVarFullDirect::wait().

Referenced by PartBundle::wait_pending().


The documentation for this class was generated from the following files: