00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef ANIMINTERFACE_H
00016 #define ANIMINTERFACE_H
00017
00018 #include "pandabase.h"
00019 #include "typeHandle.h"
00020 #include "register_type.h"
00021 #include "cycleData.h"
00022 #include "cycleDataReader.h"
00023 #include "cycleDataWriter.h"
00024 #include "pipelineCycler.h"
00025
00026 class BamWriter;
00027 class BamReader;
00028 class Datagram;
00029 class DatagramIterator;
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039 class EXPCL_PANDA_PUTIL AnimInterface {
00040 protected:
00041 AnimInterface();
00042 AnimInterface(const AnimInterface ©);
00043
00044 PUBLISHED:
00045 virtual ~AnimInterface();
00046 INLINE void play();
00047 INLINE void play(double from, double to);
00048 INLINE void loop(bool restart);
00049 INLINE void loop(bool restart, double from, double to);
00050 INLINE void pingpong(bool restart);
00051 INLINE void pingpong(bool restart, double from, double to);
00052 INLINE void stop();
00053 INLINE void pose(double frame);
00054
00055 INLINE void set_play_rate(double play_rate);
00056 INLINE double get_play_rate() const;
00057 INLINE double get_frame_rate() const;
00058 virtual int get_num_frames() const;
00059
00060 INLINE int get_frame() const;
00061 INLINE int get_next_frame() const;
00062 INLINE double get_frac() const;
00063 INLINE int get_full_frame() const;
00064 INLINE double get_full_fframe() const;
00065 INLINE bool is_playing() const;
00066
00067 virtual void output(ostream &out) const;
00068
00069 protected:
00070 INLINE void set_frame_rate(double frame_rate);
00071 INLINE void set_num_frames(int num_frames);
00072 virtual void animation_activated();
00073
00074 private:
00075 enum PlayMode {
00076 PM_pose,
00077 PM_play,
00078 PM_loop,
00079 PM_pingpong,
00080 };
00081
00082
00083
00084
00085 int _num_frames;
00086
00087
00088 class EXPCL_PANDA_PUTIL CData : public CycleData {
00089 public:
00090 CData();
00091 CData(const CData ©);
00092 virtual CycleData *make_copy() const;
00093 virtual void write_datagram(BamWriter *manager, Datagram &dg) const;
00094 virtual void fillin(DatagramIterator &scan, BamReader *manager);
00095 virtual TypeHandle get_parent_type() const {
00096 return AnimInterface::get_class_type();
00097 }
00098
00099 void play(double from, double to);
00100 void loop(bool restart, double from, double to);
00101 void pingpong(bool restart, double from, double to);
00102 void pose(double frame);
00103
00104 INLINE double get_frac() const;
00105 int get_full_frame(int increment) const;
00106 double get_full_fframe() const;
00107 bool is_playing() const;
00108
00109 virtual void output(ostream &out) const;
00110
00111 void internal_set_rate(double frame_rate, double play_rate);
00112 double get_f() const;
00113
00114 double _frame_rate;
00115
00116 PlayMode _play_mode;
00117 double _start_time;
00118 double _start_frame;
00119 double _play_frames;
00120 int _from_frame;
00121 int _to_frame;
00122
00123 double _play_rate;
00124 double _effective_frame_rate;
00125 bool _paused;
00126 double _paused_f;
00127 };
00128
00129 PipelineCycler<CData> _cycler;
00130 typedef CycleDataReader<CData> CDReader;
00131 typedef CycleDataWriter<CData> CDWriter;
00132
00133 protected:
00134 virtual void write_datagram(BamWriter *manager, Datagram &dg);
00135 void fillin(DatagramIterator &scan, BamReader *manager);
00136
00137 public:
00138 static TypeHandle get_class_type() {
00139 return _type_handle;
00140 }
00141 static void init_type() {
00142 register_type(_type_handle, "AnimInterface");
00143 }
00144
00145 private:
00146 static TypeHandle _type_handle;
00147 };
00148
00149 INLINE ostream &operator << (ostream &out, const AnimInterface &ai);
00150
00151 #include "animInterface.I"
00152
00153 #endif