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

panda/src/chan/animChannel.h

Go to the documentation of this file.
00001 // Filename: animChannel.h
00002 // Created by:  drose (22Feb99)
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 ANIMCHANNEL_H
00020 #define ANIMCHANNEL_H
00021 
00022 #include "pandabase.h"
00023 
00024 #include "animChannelBase.h"
00025 
00026 #include "lmatrix.h"
00027 
00028 ////////////////////////////////////////////////////////////////////
00029 //       Class : AnimChannel
00030 // Description : This template class is the parent class for all kinds
00031 //               of AnimChannels that return different values.
00032 ////////////////////////////////////////////////////////////////////
00033 template<class SwitchType>
00034 class AnimChannel : public AnimChannelBase {
00035 protected:
00036   // The default constructor is protected: don't try to create an
00037   // AnimChannel without a parent.  To create an AnimChannel hierarchy,
00038   // you must first create an AnimBundle, and use that to create any
00039   // subsequent children.
00040   INLINE AnimChannel(const string &name = "");
00041 
00042 public:
00043   typedef TYPENAME SwitchType::ValueType ValueType;
00044 
00045   INLINE AnimChannel(AnimGroup *parent, const string &name);
00046 
00047   virtual void get_value(int frame, ValueType &value)=0;
00048 
00049   // These two functions only have meaning for matrix types.
00050   virtual void get_value_no_scale(int frame, ValueType &value);
00051   virtual void get_scale(int frame, float scale[3]);
00052   // The second parameter above should really by LVector3f instead of
00053   // float[3], but there seems to be a compiler bug in EGCS that
00054   // doesn't like that.  So we have this kludge for now.
00055 
00056   virtual TypeHandle get_value_type() const;
00057 
00058   //This class has no Read/Write functions as it is abstract
00059   //and defines no new data
00060 
00061 public:
00062   virtual TypeHandle get_type() const {
00063     return get_class_type();
00064   }
00065   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00066   static TypeHandle get_class_type() {
00067     return _type_handle;
00068   }
00069   static void init_type() {
00070     AnimChannelBase::init_type();
00071     register_type(_type_handle, SwitchType::get_channel_type_name(),
00072                   AnimChannelBase::get_class_type());
00073   }
00074 
00075 private:
00076   static TypeHandle _type_handle;
00077 };
00078 
00079 
00080 // And now we instantiate a few useful types.
00081 
00082 class EXPCL_PANDA ACMatrixSwitchType {
00083 public:
00084   typedef LMatrix4f ValueType;
00085   static const char *get_channel_type_name() { return "AnimChannelMatrix"; }
00086   static const char *get_fixed_channel_type_name() { return "AnimChannelMatrixFixed"; }
00087   static const char *get_part_type_name() { return "MovingPart<LMatrix4f>"; }
00088   static void output_value(ostream &out, const ValueType &value);
00089 
00090   static void write_datagram(Datagram &dest, ValueType& me)
00091   {
00092     me.write_datagram(dest);
00093   }
00094   static void read_datagram(DatagramIterator &source, ValueType& me)
00095   {
00096     me.read_datagram(source);
00097   }
00098 };
00099 
00100 EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, AnimChannel<ACMatrixSwitchType>);
00101 typedef AnimChannel<ACMatrixSwitchType> AnimChannelMatrix;
00102 
00103 
00104 class EXPCL_PANDA ACScalarSwitchType {
00105 public:
00106   typedef float ValueType;
00107   static const char *get_channel_type_name() { return "AnimChannelScalar"; }
00108   static const char *get_fixed_channel_type_name() { return "AnimChannelScalarFixed"; }
00109   static const char *get_part_type_name() { return "MovingPart<float>"; }
00110   static void output_value(ostream &out, ValueType value) {
00111     out << value;
00112   }
00113   static void write_datagram(Datagram &dest, ValueType& me)
00114   {
00115     dest.add_float32(me);
00116   }
00117   static void read_datagram(DatagramIterator &source, ValueType& me)
00118   {
00119     me = source.get_float32();
00120   }
00121 };
00122 
00123 EXPORT_TEMPLATE_CLASS(EXPCL_PANDA, EXPTP_PANDA, AnimChannel<ACScalarSwitchType>);
00124 typedef AnimChannel<ACScalarSwitchType> AnimChannelScalar;
00125 
00126 
00127 #include "animChannel.I"
00128 
00129 
00130 // Tell GCC that we'll take care of the instantiation explicitly here.
00131 #ifdef __GNUC__
00132 #pragma interface
00133 #endif
00134 
00135 #endif
00136 

Generated on Fri May 2 00:34:56 2003 for Panda by doxygen1.3