Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

panda/src/chan/animControl.I

Go to the documentation of this file.
00001 // Filename: animControl.I
00002 // Created by:  drose (19Feb99)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) 2001, Disney Enterprises, Inc.  All rights reserved
00008 //
00009 // All use of this software is subject to the terms of the Panda 3d
00010 // Software license.  You should have received a copy of this license
00011 // along with this source code; you will also find a current copy of
00012 // the license at http://www.panda3d.org/license.txt .
00013 //
00014 // To contact the maintainers of this program write to
00015 // panda3d@yahoogroups.com .
00016 //
00017 ////////////////////////////////////////////////////////////////////
00018 
00019 #include <math.h>
00020 
00021 
00022 ////////////////////////////////////////////////////////////////////
00023 //     Function: AnimControl::set_play_rate
00024 //       Access: Published
00025 //  Description: Sets the speed of the animation, relative to its
00026 //               "normal" speed.  Setting this number to 2.0 plays it
00027 //               twice as fast, 0.5 half as fast.  -1.0 plays it
00028 //               backwards, and 0.0 stops it.  The change is actually
00029 //               retroactive to the last frame.
00030 //
00031 //               If you are going to change the play_rate from a
00032 //               positive number to a negative number, or vice-versa,
00033 //               you should do this before starting the animation.
00034 //               The various flavors of play() and loop() do slightly
00035 //               different behavior based on whether play_rate is
00036 //               positive or negative.
00037 ////////////////////////////////////////////////////////////////////
00038 INLINE void AnimControl::
00039 set_play_rate(double play_rate) {
00040   _play_rate = play_rate;
00041 }
00042 
00043 ////////////////////////////////////////////////////////////////////
00044 //     Function: AnimControl::get_play_rate
00045 //       Access: Published
00046 //  Description: Returns the current speed of the animation.  See
00047 //               set_play_rate().
00048 ////////////////////////////////////////////////////////////////////
00049 INLINE double AnimControl::
00050 get_play_rate() const {
00051   return _play_rate;
00052 }
00053 
00054 ////////////////////////////////////////////////////////////////////
00055 //     Function: AnimControl::get_frame_rate
00056 //       Access: Published
00057 //  Description: Returns the actual frame rate of the animation, based
00058 //               on the play_rate (see set_play_rate()) and the
00059 //               animation's base frame rate (see
00060 //               AnimBundle::get_base_frame_rate()).  This is in
00061 //               frames per second.
00062 ////////////////////////////////////////////////////////////////////
00063 INLINE double AnimControl::
00064 get_frame_rate() const {
00065   return get_play_rate() * get_anim()->get_base_frame_rate();
00066 }
00067 
00068 ////////////////////////////////////////////////////////////////////
00069 //     Function: AnimControl::get_frame
00070 //       Access: Published
00071 //  Description: Returns the current frame number of the animation.
00072 ////////////////////////////////////////////////////////////////////
00073 INLINE int AnimControl::
00074 get_frame() const {
00075   // We have to use floor() here instead of simply casting the number
00076   // to an integer, becase the frame number might have become
00077   // negative.
00078   return (int)cfloor(_frame + 0.0001);
00079 }
00080 
00081 ////////////////////////////////////////////////////////////////////
00082 //     Function: AnimControl::get_num_frames
00083 //       Access: Published
00084 //  Description: Returns the number of frames of animation.  This is
00085 //               actually just extracted directly from the AnimBundle;
00086 //               the function is duplicated here for convenience.  The
00087 //               frame number will never be outside the range 0 <=
00088 //               frame < get_num_frames().
00089 ////////////////////////////////////////////////////////////////////
00090 INLINE int AnimControl::
00091 get_num_frames() const {
00092   return get_anim()->get_num_frames();
00093 }
00094 
00095 ////////////////////////////////////////////////////////////////////
00096 //     Function: AnimControl::is_playing
00097 //       Access: Published
00098 //  Description: Returns true if the AnimControl is currently playing,
00099 //               false otherwise.
00100 ////////////////////////////////////////////////////////////////////
00101 INLINE bool AnimControl::
00102 is_playing() const {
00103   return _playing;
00104 }
00105 
00106 ////////////////////////////////////////////////////////////////////
00107 //     Function: AnimControl::get_anim
00108 //       Access: Published
00109 //  Description: Returns the AnimBundle bound in with this
00110 //               AnimControl.
00111 ////////////////////////////////////////////////////////////////////
00112 INLINE AnimBundle *AnimControl::
00113 get_anim() const {
00114   return _anim;
00115 }
00116 
00117 ////////////////////////////////////////////////////////////////////
00118 //     Function: AnimControl::get_channel_index
00119 //       Access: Public
00120 //  Description:
00121 ////////////////////////////////////////////////////////////////////
00122 INLINE int AnimControl::
00123 get_channel_index() const {
00124   return _channel_index;
00125 }

Generated on Fri May 2 00:35:03 2003 for Panda by doxygen1.3