mirror of
https://github.com/panda3d/panda3d.git
synced 2025-09-30 08:44:19 -04:00
add getPlayMode() for actor and anim interface
This commit is contained in:
parent
ee9b0b9c78
commit
3ffcce2cc2
@ -737,6 +737,13 @@ class Actor(DirectObject, NodePath):
|
||||
else:
|
||||
return None
|
||||
|
||||
def getPlayMode(self, animName=None, partName=None):
|
||||
if self.__animControlDict:
|
||||
controls = self.getAnimControls(animName, partName, onlyPlaying=False)
|
||||
if controls:
|
||||
return controls[0].getPlayMode()
|
||||
return None
|
||||
|
||||
def hasLOD(self):
|
||||
"""
|
||||
Return 1 if the actor has LODs, 0 otherwise
|
||||
@ -1762,7 +1769,7 @@ class Actor(DirectObject, NodePath):
|
||||
return None
|
||||
|
||||
def getAnimControls(self, animName=None, partName=None, lodName=None,
|
||||
allowAsyncBind = True):
|
||||
allowAsyncBind = True, onlyPlaying = True):
|
||||
"""getAnimControls(self, string, string=None, string=None)
|
||||
|
||||
Returns a list of the AnimControls that represent the given
|
||||
@ -1840,7 +1847,7 @@ class Actor(DirectObject, NodePath):
|
||||
# get all playing animations
|
||||
for thisPart, animDict in animDictItems:
|
||||
for anim in animDict.values():
|
||||
if anim.animControl and anim.animControl.isPlaying():
|
||||
if anim.animControl and (not onlyPlaying or anim.animControl.isPlaying()):
|
||||
controls.append(anim.animControl)
|
||||
else:
|
||||
# get the named animation(s) only.
|
||||
@ -2660,3 +2667,4 @@ class Actor(DirectObject, NodePath):
|
||||
get_base_frame_rate = getBaseFrameRate
|
||||
remove_anim_control_dict = removeAnimControlDict
|
||||
load_anims_on_all_lods = loadAnimsOnAllLODs
|
||||
get_play_mode = getPlayMode
|
||||
|
@ -231,6 +231,16 @@ is_playing() const {
|
||||
return cdata->is_playing();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the current play mode of the animation; whether the animation is
|
||||
* playing normally, looping, posing, or in ping-pong mode.
|
||||
*/
|
||||
INLINE AnimInterface::PlayMode AnimInterface::
|
||||
get_play_mode() const {
|
||||
CDReader cdata(_cycler);
|
||||
return cdata->get_play_mode();
|
||||
}
|
||||
|
||||
/**
|
||||
* 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
|
||||
@ -266,6 +276,11 @@ get_frac() const {
|
||||
return get_full_fframe() - (double)get_full_frame(0);
|
||||
}
|
||||
|
||||
INLINE AnimInterface::PlayMode AnimInterface::CData::
|
||||
get_play_mode() const {
|
||||
return _play_mode;
|
||||
}
|
||||
|
||||
INLINE std::ostream &
|
||||
operator << (std::ostream &out, const AnimInterface &ai) {
|
||||
ai.output(out);
|
||||
|
@ -38,6 +38,13 @@ protected:
|
||||
AnimInterface(const AnimInterface ©);
|
||||
|
||||
PUBLISHED:
|
||||
enum PlayMode {
|
||||
PM_pose,
|
||||
PM_play,
|
||||
PM_loop,
|
||||
PM_pingpong,
|
||||
};
|
||||
|
||||
virtual ~AnimInterface();
|
||||
INLINE void play();
|
||||
INLINE void play(double from, double to);
|
||||
@ -59,6 +66,7 @@ PUBLISHED:
|
||||
INLINE int get_full_frame() const;
|
||||
INLINE double get_full_fframe() const;
|
||||
INLINE bool is_playing() const;
|
||||
INLINE PlayMode get_play_mode() const;
|
||||
|
||||
virtual void output(std::ostream &out) const;
|
||||
|
||||
@ -73,6 +81,7 @@ PUBLISHED:
|
||||
MAKE_PROPERTY(full_frame, get_full_frame);
|
||||
MAKE_PROPERTY(full_fframe, get_full_fframe);
|
||||
MAKE_PROPERTY(playing, is_playing);
|
||||
MAKE_PROPERTY(play_mode, get_play_mode);
|
||||
|
||||
protected:
|
||||
INLINE void set_frame_rate(double frame_rate);
|
||||
@ -80,13 +89,6 @@ protected:
|
||||
virtual void animation_activated();
|
||||
|
||||
private:
|
||||
enum PlayMode {
|
||||
PM_pose,
|
||||
PM_play,
|
||||
PM_loop,
|
||||
PM_pingpong,
|
||||
};
|
||||
|
||||
// This data is not cycled, because it is a semi-permanent part of the
|
||||
// interface. Also, some derivatives of AnimInterface don't even use it.
|
||||
int _num_frames;
|
||||
@ -112,6 +114,7 @@ private:
|
||||
int get_full_frame(int increment) const;
|
||||
double get_full_fframe() const;
|
||||
bool is_playing() const;
|
||||
INLINE PlayMode get_play_mode() const;
|
||||
|
||||
virtual void output(std::ostream &out) const;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user