00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef ANIMCHANNEL_H
00016 #define ANIMCHANNEL_H
00017
00018 #include "pandabase.h"
00019
00020 #include "animChannelBase.h"
00021
00022 #include "luse.h"
00023
00024
00025
00026
00027
00028
00029 template<class SwitchType>
00030 class AnimChannel : public AnimChannelBase {
00031 protected:
00032
00033
00034
00035
00036 INLINE AnimChannel(const string &name = "");
00037 INLINE AnimChannel(AnimGroup *parent, const AnimChannel ©);
00038 public:
00039 typedef TYPENAME SwitchType::ValueType ValueType;
00040
00041 INLINE AnimChannel(AnimGroup *parent, const string &name);
00042 INLINE ~AnimChannel();
00043
00044 PUBLISHED:
00045 virtual void get_value(int frame, ValueType &value)=0;
00046
00047
00048 virtual void get_value_no_scale_shear(int frame, ValueType &value);
00049 virtual void get_scale(int frame, LVecBase3 &scale);
00050 virtual void get_hpr(int frame, LVecBase3 &hpr);
00051 virtual void get_quat(int frame, LQuaternion &quat);
00052 virtual void get_pos(int frame, LVecBase3 &pos);
00053 virtual void get_shear(int frame, LVecBase3 &shear);
00054
00055 virtual TypeHandle get_value_type() const;
00056
00057
00058
00059
00060 public:
00061 virtual TypeHandle get_type() const {
00062 return get_class_type();
00063 }
00064 virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00065 static TypeHandle get_class_type() {
00066 return _type_handle;
00067 }
00068 static void init_type() {
00069 AnimChannelBase::init_type();
00070 register_type(_type_handle, SwitchType::get_channel_type_name(),
00071 AnimChannelBase::get_class_type());
00072 }
00073
00074 private:
00075 static TypeHandle _type_handle;
00076 };
00077
00078
00079
00080
00081 class EXPCL_PANDA_CHAN ACMatrixSwitchType {
00082 public:
00083 typedef LMatrix4 ValueType;
00084 static const char *get_channel_type_name() { return "AnimChannelMatrix"; }
00085 static const char *get_fixed_channel_type_name() { return "AnimChannelFixed<LMatrix4>"; }
00086 static const char *get_part_type_name() { return "MovingPart<LMatrix4>"; }
00087 static void output_value(ostream &out, const ValueType &value);
00088
00089 static void write_datagram(Datagram &dest, ValueType& me)
00090 {
00091 me.write_datagram(dest);
00092 }
00093 static void read_datagram(DatagramIterator &source, ValueType& me)
00094 {
00095 me.read_datagram(source);
00096 }
00097 };
00098
00099 EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_CHAN, EXPTP_PANDA_CHAN, AnimChannel<ACMatrixSwitchType>);
00100 typedef AnimChannel<ACMatrixSwitchType> AnimChannelMatrix;
00101
00102
00103 class EXPCL_PANDA_CHAN ACScalarSwitchType {
00104 public:
00105 typedef PN_stdfloat ValueType;
00106 static const char *get_channel_type_name() { return "AnimChannelScalar"; }
00107 static const char *get_fixed_channel_type_name() { return "AnimChannelScalarFixed"; }
00108 static const char *get_part_type_name() { return "MovingPart<PN_stdfloat>"; }
00109 static void output_value(ostream &out, ValueType value) {
00110 out << value;
00111 }
00112 static void write_datagram(Datagram &dest, ValueType& me)
00113 {
00114 dest.add_stdfloat(me);
00115 }
00116 static void read_datagram(DatagramIterator &source, ValueType& me)
00117 {
00118 me = source.get_stdfloat();
00119 }
00120 };
00121
00122 EXPORT_TEMPLATE_CLASS(EXPCL_PANDA_CHAN, EXPTP_PANDA_CHAN, AnimChannel<ACScalarSwitchType>);
00123 typedef AnimChannel<ACScalarSwitchType> AnimChannelScalar;
00124
00125
00126 #include "animChannel.I"
00127
00128
00129
00130 #ifdef __GNUC__
00131 #pragma interface
00132 #endif
00133
00134 #endif
00135