Panda3D
Loading...
Searching...
No Matches
animControlCollection.I
Go to the documentation of this file.
1/**
2 * PANDA 3D SOFTWARE
3 * Copyright (c) Carnegie Mellon University. All rights reserved.
4 *
5 * All use of this software is subject to the terms of the revised BSD
6 * license. You should have received a copy of this license along
7 * with this source code in a file named "LICENSE."
8 *
9 * @file animControlCollection.I
10 * @author drose
11 * @date 2000-02-22
12 */
13
14/**
15 * Starts the named animation playing.
16 */
18play(const std::string &anim_name) {
19 AnimControl *control = find_anim(anim_name);
20 if (control == nullptr) {
21 return false;
22 }
23 _last_started_control = control;
24 control->play();
25 return true;
26}
27
28/**
29 * Starts the named animation playing.
30 */
32play(const std::string &anim_name, double from, double to) {
33 AnimControl *control = find_anim(anim_name);
34 if (control == nullptr) {
35 return false;
36 }
37 _last_started_control = control;
38 control->play(from, to);
39 return true;
40}
41
42/**
43 * Starts the named animation looping.
44 */
46loop(const std::string &anim_name, bool restart) {
47 AnimControl *control = find_anim(anim_name);
48 if (control == nullptr) {
49 return false;
50 }
51 _last_started_control = control;
52 control->loop(restart);
53 return true;
54}
55
56/**
57 * Starts the named animation looping.
58 */
60loop(const std::string &anim_name, bool restart, double from, double to) {
61 AnimControl *control = find_anim(anim_name);
62 if (control == nullptr) {
63 return false;
64 }
65 _last_started_control = control;
66 control->loop(restart, from, to);
67 return true;
68}
69
70/**
71 * Stops the named animation.
72 */
74stop(const std::string &anim_name) {
75 AnimControl *control = find_anim(anim_name);
76 if (control == nullptr) {
77 return false;
78 }
79 control->stop();
80 return true;
81}
82
83
84/**
85 * Sets to a particular frame in the named animation.
86 */
88pose(const std::string &anim_name, double frame) {
89 AnimControl *control = find_anim(anim_name);
90 if (control == nullptr) {
91 return false;
92 }
93 _last_started_control = control;
94 control->pose(frame);
95 return true;
96}
97
98/**
99 * Returns the current frame in the named animation, or 0 if the animation is
100 * not found.
101 */
103get_frame(const std::string &anim_name) const {
104 AnimControl *control = find_anim(anim_name);
105 if (control == nullptr) {
106 return 0;
107 }
108 return control->get_frame();
109}
110
111/**
112 * Returns the current frame in the last-started animation.
113 */
115get_frame() const {
116 if (_last_started_control == nullptr) {
117 return 0;
118 }
119 return _last_started_control->get_frame();
120}
121
122/**
123 * Returns true if the named animation is currently playing, false otherwise.
124 */
126is_playing(const std::string &anim_name) const {
127 AnimControl *control = find_anim(anim_name);
128 if (control == nullptr) {
129 return false;
130 }
131 return control->is_playing();
132}
133
134/**
135 * Returns true if the last-started animation is currently playing, false
136 * otherwise.
137 */
139is_playing() const {
140 if (_last_started_control == nullptr) {
141 return false;
142 }
143 return _last_started_control->is_playing();
144}
145
146/**
147 * Returns the total number of frames in the named animation, or 0 if the
148 * animation is not found.
149 */
151get_num_frames(const std::string &anim_name) const {
152 AnimControl *control = find_anim(anim_name);
153 if (control == nullptr) {
154 return 0;
155 }
156 return control->get_num_frames();
157}
158
159/**
160 * Returns the total number of frames in the last-started animation.
161 */
163get_num_frames() const {
164 if (_last_started_control == nullptr) {
165 return 0;
166 }
167 return _last_started_control->get_num_frames();
168}
169
170INLINE std::ostream &
171operator << (std::ostream &out, const AnimControlCollection &collection) {
172 collection.output(out);
173 return out;
174}
This is a named collection of AnimControl pointers.
int get_num_frames() const
Returns the total number of frames in the last-started animation.
bool is_playing() const
Returns true if the last-started animation is currently playing, false otherwise.
bool play(const std::string &anim_name)
Starts the named animation playing.
int get_frame() const
Returns the current frame in the last-started animation.
bool stop(const std::string &anim_name)
Stops the named animation.
bool loop(const std::string &anim_name, bool restart)
Starts the named animation looping.
bool pose(const std::string &anim_name, double frame)
Sets to a particular frame in the named animation.
AnimControl * find_anim(const std::string &name) const
Returns the AnimControl associated with the given name, or NULL if no such control has been associate...
Controls the timing of a character animation.
Definition animControl.h:38
void pose(double frame)
Sets the animation to the indicated frame and holds it there.
get_frame
Returns the current integer frame number.
is_playing
Returns true if the animation is currently playing, false if it is stopped (e.g.
get_num_frames
Returns the number of frames in the animation.
void stop()
Stops a currently playing or looping animation right where it is.
void loop(bool restart)
Starts the entire animation looping.
void play()
Runs the entire animation from beginning to end and stops.