Panda3D
|
This is the fundamental interface for things that have a play/loop/stop type interface for frame-based animation, such as animated characters. More...
#include "animInterface.h"
Classes | |
class | CData |
Public Member Functions | |
double | get_frac () const |
Returns the fractional part of the current frame. | |
int | get_frame () const |
Returns the current integer frame number. | |
double | get_frame_rate () const |
Returns the native frame rate of the animation. | |
double | get_full_fframe () const |
Returns the current floating-point frame number. | |
int | get_full_frame () const |
Returns the current integer frame number. | |
int | get_next_frame () const |
Returns the current integer frame number + 1, constrained to the range 0 <= f < get_num_frames(). | |
virtual int | get_num_frames () const |
Returns the number of frames in the animation. | |
double | get_play_rate () const |
Returns the rate at which the animation plays. | |
bool | is_playing () const |
Returns true if the animation is currently playing, false if it is stopped (e.g. | |
void | loop (bool restart) |
Starts the entire animation looping. | |
void | loop (bool restart, double from, double to) |
Loops the animation from the frame "from" to and including the frame "to", indefinitely. | |
virtual void | output (ostream &out) const |
void | pingpong (bool restart) |
Starts the entire animation bouncing back and forth between its first frame and last frame. | |
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. | |
void | play () |
Runs the entire animation from beginning to end and stops. | |
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. | |
void | pose (double frame) |
Sets the animation to the indicated frame and holds it there. | |
void | set_play_rate (double play_rate) |
Changes the rate at which the animation plays. | |
void | stop () |
Stops a currently playing or looping animation right where it is. | |
Static Public Member Functions | |
static TypeHandle | get_class_type () |
static void | init_type () |
Protected Member Functions | |
AnimInterface (const AnimInterface ©) | |
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. | |
void | fillin (DatagramIterator &scan, BamReader *manager) |
This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new AnimInterface. | |
void | set_frame_rate (double frame_rate) |
Should be called by a derived class to specify the native frame rate of the animation. | |
void | set_num_frames (int num_frames) |
Should be called by a derived class to specify the number of frames of the animation. | |
virtual void | write_datagram (BamWriter *manager, Datagram &dg) |
Writes the contents of this object to the datagram for shipping out to a Bam file. |
This is the fundamental interface for things that have a play/loop/stop type interface for frame-based animation, such as animated characters.
This is the base class for AnimControl and other, similar classes.
Definition at line 39 of file animInterface.h.
void AnimInterface::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 in AnimControl.
Definition at line 90 of file animInterface.cxx.
Referenced by loop(), pingpong(), play(), and pose().
void AnimInterface::fillin | ( | DatagramIterator & | scan, |
BamReader * | manager | ||
) | [protected] |
This internal function is called by make_from_bam to read in all of the relevant data from the BamFile for the new AnimInterface.
Reimplemented in SequenceNode.
Definition at line 113 of file animInterface.cxx.
References DatagramIterator::get_int32(), and BamReader::read_cdata().
double AnimInterface::get_frac | ( | ) | const [inline] |
Returns the fractional part of the current frame.
Normally, this is in the range 0.0 <= f < 1.0, but in the one special case of an animation playing to its end frame and stopping, it might exactly equal 1.0.
It will always be true that get_full_frame() + get_frac() == get_full_fframe().
Definition at line 233 of file animInterface.I.
Referenced by AnimControl::channel_has_changed(), MovingPartScalar::get_blend_value(), MovingPartMatrix::get_blend_value(), and AnimControl::mark_channels().
int AnimInterface::get_frame | ( | ) | const [inline] |
Returns the current integer frame number.
This number will be in the range 0 <= f < get_num_frames().
Definition at line 190 of file animInterface.I.
References get_num_frames().
Referenced by AnimControl::channel_has_changed(), VideoTexture::consider_update(), SequenceNode::cull_callback(), MovingPartScalar::get_blend_value(), MovingPartMatrix::get_blend_value(), SequenceNode::get_first_visible_child(), AnimControlCollection::get_frame(), SequenceNode::get_visible_child(), and AnimControl::mark_channels().
double AnimInterface::get_frame_rate | ( | ) | const [inline] |
Returns the native frame rate of the animation.
This is the number of frames per second that will elapse when the play_rate is set to 1.0. It is a fixed property of the animation and may not be adjusted by the user.
Definition at line 177 of file animInterface.I.
double AnimInterface::get_full_fframe | ( | ) | const [inline] |
Returns the current floating-point frame number.
Unlike the value returned by get_frame(), this frame number may extend beyond the range of get_num_frames() if the frame range passed to play(), loop(), etc. did.
Unlike the value returned by get_full_frame(), this return value may equal (to_frame + 1.0), when the animation has played to its natural end. However, in this case the return value of get_full_frame() will be to_frame, not (to_frame + 1).
Definition at line 275 of file animInterface.I.
int AnimInterface::get_full_frame | ( | ) | const [inline] |
Returns the current integer frame number.
Unlike the value returned by get_frame(), this frame number may extend beyond the range of get_num_frames() if the frame range passed to play(), loop(), etc. did.
Unlike the value returned by get_full_fframe(), this return value will never exceed the value passed to to_frame in the play() method.
Definition at line 253 of file animInterface.I.
int AnimInterface::get_next_frame | ( | ) | const [inline] |
Returns the current integer frame number + 1, constrained to the range 0 <= f < get_num_frames().
If the play mode is PM_play, this will clamp to the same value as get_frame() at the end of the animation. If the play mode is any other value, this will wrap around to frame 0 at the end of the animation.
Definition at line 212 of file animInterface.I.
References get_num_frames().
Referenced by MovingPartScalar::get_blend_value(), and MovingPartMatrix::get_blend_value().
int AnimInterface::get_num_frames | ( | ) | const [virtual] |
Returns the number of frames in the animation.
This is a property of the animation and may not be directly adjusted by the user (although it may change without warning with certain kinds of animations, since this is a virtual method that may be overridden).
Reimplemented in SequenceNode.
Definition at line 67 of file animInterface.cxx.
Referenced by get_frame(), get_next_frame(), AnimControlCollection::get_num_frames(), loop(), pingpong(), and play().
double AnimInterface::get_play_rate | ( | ) | const [inline] |
Returns the rate at which the animation plays.
See set_play_rate().
Definition at line 162 of file animInterface.I.
bool AnimInterface::is_playing | ( | ) | const [inline] |
Returns true if the animation is currently playing, false if it is stopped (e.g.
because stop() or pose() was called, or because it reached the end of the animation after play() was called).
Definition at line 289 of file animInterface.I.
Referenced by AnimControlCollection::is_playing().
void AnimInterface::loop | ( | bool | restart | ) | [inline] |
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 57 of file animInterface.I.
References get_num_frames().
Referenced by AnimControlCollection::loop(), and EggLoader::start_sequences().
void AnimInterface::loop | ( | bool | restart, |
double | from, | ||
double | to | ||
) | [inline] |
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 71 of file animInterface.I.
References animation_activated().
void AnimInterface::pingpong | ( | bool | restart | ) | [inline] |
Starts the entire animation bouncing back and forth between its first frame and last frame.
If restart is true, the animation is restarted from the beginning; otherwise, it continues from the current frame.
Definition at line 89 of file animInterface.I.
References get_num_frames().
void AnimInterface::pingpong | ( | bool | restart, |
double | from, | ||
double | to | ||
) | [inline] |
Loops the animation from the frame "from" to and including the frame "to", and then back in the opposite direction, indefinitely.
Definition at line 101 of file animInterface.I.
References animation_activated().
void AnimInterface::play | ( | double | from, |
double | to | ||
) | [inline] |
Runs the animation from the frame "from" to and including the frame "to", at which point the animation is stopped.
Both "from" and "to" frame numbers may be outside the range (0, get_num_frames()) and the animation will follow the range correctly, reporting numbers modulo get_num_frames(). For instance, play(0, get_num_frames() * 2) will play the animation twice and then stop.
Definition at line 41 of file animInterface.I.
References animation_activated().
void AnimInterface::play | ( | ) | [inline] |
Runs the entire animation from beginning to end and stops.
Definition at line 23 of file animInterface.I.
References get_num_frames().
Referenced by AnimControlCollection::play().
void AnimInterface::pose | ( | double | frame | ) | [inline] |
Sets the animation to the indicated frame and holds it there.
Definition at line 132 of file animInterface.I.
References animation_activated().
Referenced by AnimControlCollection::pose().
void AnimInterface::set_frame_rate | ( | double | frame_rate | ) | [inline, protected] |
Should be called by a derived class to specify the native frame rate of the animation.
It is legal to call this after the animation has already started.
Reimplemented in SequenceNode.
Definition at line 302 of file animInterface.I.
Referenced by AnimControl::AnimControl(), and AnimControl::setup_anim().
void AnimInterface::set_num_frames | ( | int | num_frames | ) | [inline, protected] |
Should be called by a derived class to specify the number of frames of the animation.
It is legal to call this after the animation has already started, but doing so may suddenly change the apparent current frame number.
Definition at line 317 of file animInterface.I.
Referenced by AnimControl::AnimControl(), and AnimControl::setup_anim().
void AnimInterface::set_play_rate | ( | double | play_rate | ) | [inline] |
Changes the rate at which the animation plays.
1.0 is the normal speed, 2.0 is twice normal speed, and 0.5 is half normal speed. 0.0 is legal to pause the animation, and a negative value will play the animation backwards.
Definition at line 150 of file animInterface.I.
void AnimInterface::stop | ( | ) | [inline] |
Stops a currently playing or looping animation right where it is.
The animation remains posed at the current frame.
Definition at line 117 of file animInterface.I.
Referenced by AnimControlCollection::stop().
Writes the contents of this object to the datagram for shipping out to a Bam file.
Reimplemented in SequenceNode.
Definition at line 100 of file animInterface.cxx.
References Datagram::add_int32(), and BamWriter::write_cdata().