Panda3D
 All Classes Functions Variables Enumerations
animChannelScalarDynamic.h
00001 // Filename: animChannelScalarDynamic.h
00002 // Created by:  drose (20Oct03)
00003 //
00004 ////////////////////////////////////////////////////////////////////
00005 //
00006 // PANDA 3D SOFTWARE
00007 // Copyright (c) Carnegie Mellon University.  All rights reserved.
00008 //
00009 // All use of this software is subject to the terms of the revised BSD
00010 // license.  You should have received a copy of this license along
00011 // with this source code in a file named "LICENSE."
00012 //
00013 ////////////////////////////////////////////////////////////////////
00014 
00015 #ifndef ANIMCHANNELSCALARDYNAMIC_H
00016 #define ANIMCHANNELSCALARDYNAMIC_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "animChannel.h"
00021 
00022 class PandaNode;
00023 class TransformState;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //       Class : AnimChannelScalarDynamic
00027 // Description : An animation channel that accepts a scalar each frame
00028 //               from some dynamic input provided by code.
00029 //
00030 //               This object operates in two modes: in explicit mode,
00031 //               the programmer should call set_value() each frame to
00032 //               indicate the new value; in implicit mode, the
00033 //               programmer should call set_value_node() to indicate
00034 //               the node whose X component will be copied to the
00035 //               scalar each frame.
00036 ////////////////////////////////////////////////////////////////////
00037 class EXPCL_PANDA_CHAN AnimChannelScalarDynamic : public AnimChannelScalar {
00038 protected:
00039   AnimChannelScalarDynamic();
00040   AnimChannelScalarDynamic(AnimGroup *parent, const AnimChannelScalarDynamic &copy);
00041 
00042 public:
00043   AnimChannelScalarDynamic(const string &name);
00044 
00045   virtual bool has_changed(int last_frame, double last_frac, 
00046                            int this_frame, double this_frac);
00047   virtual void get_value(int frame, PN_stdfloat &value);
00048 
00049 PUBLISHED:
00050   void set_value(PN_stdfloat value);
00051   void set_value_node(PandaNode *node);
00052 
00053 protected:
00054   virtual AnimGroup *make_copy(AnimGroup *parent) const;
00055 
00056 private:
00057   // This is filled in only if we are using the set_value_node()
00058   // interface to get an implicit value from the transform on the
00059   // indicated node each frame.
00060   PT(PandaNode) _value_node;
00061   CPT(TransformState) _value;
00062   CPT(TransformState) _last_value;
00063 
00064   // This is used only if we are using the explicit set_value()
00065   // interface.
00066   bool _value_changed;
00067   PN_stdfloat _float_value;
00068 
00069 public:
00070   static void register_with_read_factory();
00071   virtual void write_datagram(BamWriter *manager, Datagram &dg);
00072   virtual int complete_pointers(TypedWritable **plist, BamReader *manager);
00073   void fillin(DatagramIterator &scan, BamReader *manager);
00074 
00075   static TypedWritable *make_AnimChannelScalarDynamic(const FactoryParams &params);
00076 
00077 public:
00078   virtual TypeHandle get_type() const {
00079     return get_class_type();
00080   }
00081   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00082   static TypeHandle get_class_type() {
00083     return _type_handle;
00084   }
00085   static void init_type() {
00086     AnimChannelScalar::init_type();
00087     register_type(_type_handle, "AnimChannelScalarDynamic",
00088                   AnimChannelScalar::get_class_type());
00089   }
00090 
00091 private:
00092   static TypeHandle _type_handle;
00093 };
00094 
00095 #include "animChannelScalarDynamic.I"
00096 
00097 #endif
 All Classes Functions Variables Enumerations