Panda3D
|
00001 // Filename: animControlCollection.I 00002 // Created by: drose (22Feb00) 00003 // 00004 //////////////////////////////////////////////////////////////////// 00005 // 00006 // PANDA 3D SOFTWARE 00007 // Copyright (c) Carnegie Mellon University. All rights reserved. 00008 // 00009 // All use of this software is subject to the terms of the revised BSD 00010 // license. You should have received a copy of this license along 00011 // with this source code in a file named "LICENSE." 00012 // 00013 //////////////////////////////////////////////////////////////////// 00014 00015 00016 //////////////////////////////////////////////////////////////////// 00017 // Function: AnimControlCollection::play 00018 // Access: Public 00019 // Description: Starts the named animation playing. 00020 //////////////////////////////////////////////////////////////////// 00021 INLINE bool AnimControlCollection:: 00022 play(const string &anim_name) { 00023 AnimControl *control = find_anim(anim_name); 00024 if (control == (AnimControl *)NULL) { 00025 return false; 00026 } 00027 _last_started_control = control; 00028 control->play(); 00029 return true; 00030 } 00031 00032 //////////////////////////////////////////////////////////////////// 00033 // Function: AnimControlCollection::play 00034 // Access: Public 00035 // Description: Starts the named animation playing. 00036 //////////////////////////////////////////////////////////////////// 00037 INLINE bool AnimControlCollection:: 00038 play(const string &anim_name, int from, int to) { 00039 AnimControl *control = find_anim(anim_name); 00040 if (control == (AnimControl *)NULL) { 00041 return false; 00042 } 00043 _last_started_control = control; 00044 control->play(from, to); 00045 return true; 00046 } 00047 00048 //////////////////////////////////////////////////////////////////// 00049 // Function: AnimControlCollection::loop 00050 // Access: Public 00051 // Description: Starts the named animation looping. 00052 //////////////////////////////////////////////////////////////////// 00053 INLINE bool AnimControlCollection:: 00054 loop(const string &anim_name, bool restart) { 00055 AnimControl *control = find_anim(anim_name); 00056 if (control == (AnimControl *)NULL) { 00057 return false; 00058 } 00059 _last_started_control = control; 00060 control->loop(restart); 00061 return true; 00062 } 00063 00064 //////////////////////////////////////////////////////////////////// 00065 // Function: AnimControlCollection::loop 00066 // Access: Public 00067 // Description: Starts the named animation looping. 00068 //////////////////////////////////////////////////////////////////// 00069 INLINE bool AnimControlCollection:: 00070 loop(const string &anim_name, bool restart, int from, int to) { 00071 AnimControl *control = find_anim(anim_name); 00072 if (control == (AnimControl *)NULL) { 00073 return false; 00074 } 00075 _last_started_control = control; 00076 control->loop(restart, from, to); 00077 return true; 00078 } 00079 00080 //////////////////////////////////////////////////////////////////// 00081 // Function: AnimControlCollection::stop 00082 // Access: Public 00083 // Description: Stops the named animation. 00084 //////////////////////////////////////////////////////////////////// 00085 INLINE bool AnimControlCollection:: 00086 stop(const string &anim_name) { 00087 AnimControl *control = find_anim(anim_name); 00088 if (control == (AnimControl *)NULL) { 00089 return false; 00090 } 00091 control->stop(); 00092 return true; 00093 } 00094 00095 00096 //////////////////////////////////////////////////////////////////// 00097 // Function: AnimControlCollection::pose 00098 // Access: Public 00099 // Description: Sets to a particular frame in the named animation. 00100 //////////////////////////////////////////////////////////////////// 00101 INLINE bool AnimControlCollection:: 00102 pose(const string &anim_name, int frame) { 00103 AnimControl *control = find_anim(anim_name); 00104 if (control == (AnimControl *)NULL) { 00105 return false; 00106 } 00107 _last_started_control = control; 00108 control->pose(frame); 00109 return true; 00110 } 00111 00112 //////////////////////////////////////////////////////////////////// 00113 // Function: AnimControlCollection::get_frame 00114 // Access: Public 00115 // Description: Returns the current frame in the named animation, or 00116 // 0 if the animation is not found. 00117 //////////////////////////////////////////////////////////////////// 00118 INLINE int AnimControlCollection:: 00119 get_frame(const string &anim_name) const { 00120 AnimControl *control = find_anim(anim_name); 00121 if (control == (AnimControl *)NULL) { 00122 return 0; 00123 } 00124 return control->get_frame(); 00125 } 00126 00127 //////////////////////////////////////////////////////////////////// 00128 // Function: AnimControlCollection::get_frame 00129 // Access: Public 00130 // Description: Returns the current frame in the last-started 00131 // animation. 00132 //////////////////////////////////////////////////////////////////// 00133 INLINE int AnimControlCollection:: 00134 get_frame() const { 00135 if (_last_started_control == (AnimControl *)NULL) { 00136 return 0; 00137 } 00138 return _last_started_control->get_frame(); 00139 } 00140 00141 //////////////////////////////////////////////////////////////////// 00142 // Function: AnimControlCollection::is_playing 00143 // Access: Public 00144 // Description: Returns true if the named animation is currently 00145 // playing, false otherwise. 00146 //////////////////////////////////////////////////////////////////// 00147 INLINE bool AnimControlCollection:: 00148 is_playing(const string &anim_name) const { 00149 AnimControl *control = find_anim(anim_name); 00150 if (control == (AnimControl *)NULL) { 00151 return false; 00152 } 00153 return control->is_playing(); 00154 } 00155 00156 //////////////////////////////////////////////////////////////////// 00157 // Function: AnimControlCollection::is_playing 00158 // Access: Public 00159 // Description: Returns true if the last-started animation is 00160 // currently playing, false otherwise. 00161 //////////////////////////////////////////////////////////////////// 00162 INLINE bool AnimControlCollection:: 00163 is_playing() const { 00164 if (_last_started_control == (AnimControl *)NULL) { 00165 return false; 00166 } 00167 return _last_started_control->is_playing(); 00168 } 00169 00170 //////////////////////////////////////////////////////////////////// 00171 // Function: AnimControlCollection::get_num_frames 00172 // Access: Public 00173 // Description: Returns the total number of frames in the named 00174 // animation, or 0 if the animation is not found. 00175 //////////////////////////////////////////////////////////////////// 00176 INLINE int AnimControlCollection:: 00177 get_num_frames(const string &anim_name) const { 00178 AnimControl *control = find_anim(anim_name); 00179 if (control == (AnimControl *)NULL) { 00180 return 0; 00181 } 00182 return control->get_num_frames(); 00183 } 00184 00185 //////////////////////////////////////////////////////////////////// 00186 // Function: AnimControlCollection::get_num_frames 00187 // Access: Public 00188 // Description: Returns the total number of frames in the 00189 // last-started animation. 00190 //////////////////////////////////////////////////////////////////// 00191 INLINE int AnimControlCollection:: 00192 get_num_frames() const { 00193 if (_last_started_control == (AnimControl *)NULL) { 00194 return 0; 00195 } 00196 return _last_started_control->get_num_frames(); 00197 } 00198 00199 INLINE ostream & 00200 operator << (ostream &out, const AnimControlCollection &collection) { 00201 collection.output(out); 00202 return out; 00203 } 00204