AnimInterface
from panda3d.core import AnimInterface
- class AnimInterface
Bases:
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.Inheritance diagram
- property frac float
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
getFullFrame()
+getFrac()
==getFullFframe()
.
- property frame int
Returns the current integer frame number. This number will be in the range 0 <= f <
getNumFrames()
.
- property frame_rate float
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.
- property full_fframe float
Returns the current floating-point frame number.
Unlike the value returned by
getFrame()
, this frame number may extend beyond the range ofgetNumFrames()
if the frame range passed toplay()
,loop()
, etc. did.Unlike the value returned by
getFullFrame()
, 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 ofgetFullFrame()
will be to_frame, not (to_frame + 1).
- property full_frame int
Returns the current integer frame number.
Unlike the value returned by
getFrame()
, this frame number may extend beyond the range ofgetNumFrames()
if the frame range passed toplay()
,loop()
, etc. did.Unlike the value returned by
getFullFframe()
, this return value will never exceed the value passed to to_frame in theplay()
method.
- static getClassType() TypeHandle
- getFrac() float
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
getFullFrame()
+getFrac()
==getFullFframe()
.
- getFrame() int
Returns the current integer frame number. This number will be in the range 0 <= f <
getNumFrames()
.
- getFrameRate() float
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.
- getFullFframe() float
Returns the current floating-point frame number.
Unlike the value returned by
getFrame()
, this frame number may extend beyond the range ofgetNumFrames()
if the frame range passed toplay()
,loop()
, etc. did.Unlike the value returned by
getFullFrame()
, 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 ofgetFullFrame()
will be to_frame, not (to_frame + 1).
- getFullFrame() int
Returns the current integer frame number.
Unlike the value returned by
getFrame()
, this frame number may extend beyond the range ofgetNumFrames()
if the frame range passed toplay()
,loop()
, etc. did.Unlike the value returned by
getFullFframe()
, this return value will never exceed the value passed to to_frame in theplay()
method.
- getNextFrame() int
Returns the current integer frame number + 1, constrained to the range 0 <= f <
getNumFrames()
.If the play mode is PM_play, this will clamp to the same value as
getFrame()
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.
- getNumFrames() int
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).
- getPlayRate() float
Returns the rate at which the animation plays. See
setPlayRate()
.
- isPlaying() bool
Returns true if the animation is currently playing, false if it is stopped (e.g. because
stop()
orpose()
was called, or because it reached the end of the animation afterplay()
was called).
- loop(restart: bool)
Starts the entire animation looping. If restart is true, the animation is restarted from the beginning; otherwise, it continues from the current frame.
- loop(restart: bool, from: float, to: float)
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.
- property next_frame int
Returns the current integer frame number + 1, constrained to the range 0 <= f <
getNumFrames()
.If the play mode is PM_play, this will clamp to the same value as
getFrame()
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.
- property num_frames int
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).
- pingpong(restart: bool)
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.
- pingpong(restart: bool, from: float, to: float)
Loops the animation from the frame “from” to and including the frame “to”, and then back in the opposite direction, indefinitely.
- play()
Runs the entire animation from beginning to end and stops.
- play(from: float, to: float)
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,
getNumFrames()
) and the animation will follow the range correctly, reporting numbers modulogetNumFrames()
. For instance, play(0,getNumFrames()
* 2) will play the animation twice and then stop.
- property play_rate float
- Getter
Returns the rate at which the animation plays. See
setPlayRate()
.- Setter
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.
- property playing bool
Returns true if the animation is currently playing, false if it is stopped (e.g. because
stop()
orpose()
was called, or because it reached the end of the animation afterplay()
was called).
- setPlayRate(play_rate: float)
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.
- stop()
Stops a currently playing or looping animation right where it is. The animation remains posed at the current frame.