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

panda/src/chan/animControlCollection.h

Go to the documentation of this file.
00001 // Filename: animControlCollection.h
00002 // Created by:  drose (22Feb00)
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 #ifndef ANIMCONTROLCOLLECTION_H
00020 #define ANIMCONTROLCOLLECTION_H
00021 
00022 #include <pandabase.h>
00023 
00024 #include "animControl.h"
00025 
00026 #include <event.h>
00027 #include <pt_Event.h>
00028 
00029 #include <string>
00030 #include "pmap.h"
00031 
00032 ////////////////////////////////////////////////////////////////////
00033 //       Class : AnimControlCollection
00034 // Description : This is a named collection of AnimControl pointers.
00035 //               An AnimControl may be added to the collection by
00036 //               name.  While an AnimControl is associated, its
00037 //               reference count is maintained; associating a new
00038 //               AnimControl with the same name will decrement the
00039 //               previous control's reference count (and possibly
00040 //               delete it, unbinding its animation).
00041 ////////////////////////////////////////////////////////////////////
00042 class EXPCL_PANDA AnimControlCollection {
00043 PUBLISHED:
00044   AnimControlCollection();
00045   ~AnimControlCollection();
00046 
00047   void store_anim(AnimControl *control, const string &name);
00048   AnimControl *find_anim(const string &name) const;
00049   bool unbind_anim(const string &name);
00050 
00051   int get_num_anims() const;
00052   void clear_anims();
00053 
00054   INLINE void set_stop_event(const CPT_Event &stop_event);
00055   INLINE void clear_stop_event();
00056   INLINE bool has_stop_event() const;
00057   INLINE CPT_Event get_stop_event() const;
00058 
00059   // The following functions are convenience functions that vector
00060   // directly into the AnimControl's functionality by anim name.
00061 
00062   INLINE bool play(const string &anim_name);
00063   INLINE bool play(const string &anim_name, int from, int to);
00064   INLINE bool loop(const string &anim_name, bool restart);
00065   INLINE bool loop(const string &anim_name, bool restart, int from, int to);
00066   INLINE bool stop(const string &anim_name);
00067   INLINE bool pose(const string &anim_name, int frame);
00068 
00069   // These functions operate on all anims at once.
00070   void play_all();
00071   void play_all(int from, int to);
00072   void loop_all(bool restart);
00073   void loop_all(bool restart, int from, int to);
00074   bool stop_all();
00075   void pose_all(int frame);
00076 
00077   INLINE int get_frame(const string &anim_name) const;
00078   INLINE int get_frame() const;
00079 
00080   INLINE int get_num_frames(const string &anim_name) const;
00081 
00082   INLINE bool is_playing(const string &anim_name) const;
00083   INLINE bool is_playing() const;
00084 
00085   string which_anim_playing() const;
00086 
00087 private:
00088   typedef pmap<string,  PT(AnimControl) > Controls;
00089   Controls _controls;
00090   CPT_Event _stop_event;
00091   AnimControl *_last_started_control;
00092 };
00093 
00094 #include "animControlCollection.I"
00095 
00096 #endif

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