25 _last_started_control =
nullptr;
31 AnimControlCollection::
32 ~AnimControlCollection() {
43 ControlsByName::iterator ci = _controls_by_name.find(name);
45 if (ci == _controls_by_name.end()) {
47 size_t index = _controls.size();
49 cdef._control = control;
51 _controls.push_back(cdef);
52 _controls_by_name.insert(ControlsByName::value_type(name, index));
56 size_t index = (*ci).second;
57 nassertv(index < _controls.size());
58 nassertv(_controls[index]._name == name);
59 if (_last_started_control == _controls[index]._control) {
60 _last_started_control =
nullptr;
62 _controls[index]._control = control;
72 ControlsByName::const_iterator ci = _controls_by_name.find(name);
73 if (ci == _controls_by_name.end()) {
76 size_t index = (*ci).second;
77 nassertr(index < _controls.size(),
nullptr);
78 nassertr(_controls[index]._name == name,
nullptr);
79 return _controls[index]._control;
89 ControlsByName::iterator ci = _controls_by_name.find(name);
90 if (ci == _controls_by_name.end()) {
93 size_t index = (*ci).second;
94 nassertr(index < _controls.size(),
false);
95 nassertr(_controls[index]._name == name,
false);
97 if (_last_started_control == _controls[index]._control) {
98 _last_started_control =
nullptr;
100 _controls_by_name.erase(ci);
102 _controls.erase(_controls.begin() + index);
105 for (ci = _controls_by_name.begin();
106 ci != _controls_by_name.end();
108 if ((*ci).second > index) {
119 int AnimControlCollection::
120 get_num_anims()
const {
121 return _controls.size();
129 nassertr(n >= 0 && n < (
int)_controls.size(),
nullptr);
130 return _controls[n]._control;
138 nassertr(n >= 0 && n < (
int)_controls.size(), string());
139 return _controls[n]._name;
148 _controls_by_name.clear();
156 Controls::const_iterator ci;
157 for (ci = _controls.begin(); ci != _controls.end(); ++ci) {
158 (*ci)._control->play();
159 _last_started_control = (*ci)._control;
168 Controls::const_iterator ci;
169 for (ci = _controls.begin(); ci != _controls.end(); ++ci) {
170 (*ci)._control->play(from, to);
171 _last_started_control = (*ci)._control;
180 Controls::const_iterator ci;
181 for (ci = _controls.begin(); ci != _controls.end(); ++ci) {
182 (*ci)._control->loop(restart);
183 _last_started_control = (*ci)._control;
192 Controls::const_iterator ci;
193 for (ci = _controls.begin(); ci != _controls.end(); ++ci) {
194 (*ci)._control->loop(restart, from, to);
195 _last_started_control = (*ci)._control;
206 Controls::const_iterator ci;
207 for (ci = _controls.begin(); ci != _controls.end(); ++ci) {
208 if ((*ci)._control->is_playing()) {
210 (*ci)._control->stop();
222 Controls::const_iterator ci;
223 for (ci = _controls.begin(); ci != _controls.end(); ++ci) {
224 (*ci)._control->pose(frame);
225 _last_started_control = (*ci)._control;
238 Controls::const_iterator ci;
239 for (ci = _controls.begin();
240 ci != _controls.end();
242 if ((*ci)._control->is_playing()) {
243 if (!result.empty()) {
246 result += (*ci)._name;
256 void AnimControlCollection::
257 output(std::ostream &out)
const {
258 out << _controls.size() <<
" anims.";
264 void AnimControlCollection::
265 write(std::ostream &out)
const {
266 ControlsByName::const_iterator ci;
267 for (ci = _controls_by_name.begin();
268 ci != _controls_by_name.end();
270 out << (*ci).first <<
": " << *_controls[(*ci).second]._control <<
"\n";
get_anim
Returns the nth AnimControl associated with this collection.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void loop_all(bool restart)
Starts all animations looping.
void play_all()
Starts all animations playing.
AnimControlCollection()
Returns the AnimControl associated with the given name, or NULL if no such control has been associate...
void clear_anims()
Disassociates all anims from this collection.
void pose_all(double frame)
Sets all animations to the indicated frame.
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...
bool unbind_anim(const std::string &name)
Removes the AnimControl associated with the given name, if any.
bool stop_all()
Stops all currently playing animations.
void store_anim(AnimControl *control, const std::string &name)
Associates the given AnimControl with this collection under the given name.
Controls the timing of a character animation.
std::string which_anim_playing() const
Returns the name of the bound AnimControl currently playing, if any.
get_anim_name
Returns the name of the nth AnimControl associated with this collection.