Panda3D
|
00001 // Filename: animChannelMatrixDynamic.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 ANIMCHANNELMATRIXDYNAMIC_H 00016 #define ANIMCHANNELMATRIXDYNAMIC_H 00017 00018 #include "pandabase.h" 00019 00020 #include "animChannel.h" 00021 #include "transformState.h" 00022 #include "pandaNode.h" 00023 #include "pointerTo.h" 00024 00025 //////////////////////////////////////////////////////////////////// 00026 // Class : AnimChannelMatrixDynamic 00027 // Description : An animation channel that accepts a matrix 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 transform will be copied to the joint 00035 // each frame. 00036 //////////////////////////////////////////////////////////////////// 00037 class EXPCL_PANDA_CHAN AnimChannelMatrixDynamic : public AnimChannelMatrix { 00038 protected: 00039 AnimChannelMatrixDynamic(); 00040 AnimChannelMatrixDynamic(AnimGroup *parent, const AnimChannelMatrixDynamic ©); 00041 00042 public: 00043 AnimChannelMatrixDynamic(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, LMatrix4 &mat); 00048 00049 virtual void get_value_no_scale_shear(int frame, LMatrix4 &value); 00050 virtual void get_scale(int frame, LVecBase3 &scale); 00051 virtual void get_hpr(int frame, LVecBase3 &hpr); 00052 virtual void get_quat(int frame, LQuaternion &quat); 00053 virtual void get_pos(int frame, LVecBase3 &pos); 00054 virtual void get_shear(int frame, LVecBase3 &shear); 00055 00056 PUBLISHED: 00057 void set_value(const LMatrix4 &value); 00058 void set_value(const TransformState *value); 00059 void set_value_node(PandaNode *node); 00060 00061 INLINE const TransformState *get_value_transform() const; 00062 INLINE PandaNode *get_value_node() const; 00063 00064 protected: 00065 virtual AnimGroup *make_copy(AnimGroup *parent) const; 00066 00067 00068 private: 00069 // This is filled in only if we are using the set_value_node() 00070 // interface to get an implicit value from the transform on the 00071 // indicated node each frame. 00072 PT(PandaNode) _value_node; 00073 00074 CPT(TransformState) _value; 00075 CPT(TransformState) _last_value; 00076 00077 public: 00078 static void register_with_read_factory(); 00079 virtual void write_datagram(BamWriter *manager, Datagram &dg); 00080 virtual int complete_pointers(TypedWritable **plist, BamReader *manager); 00081 void fillin(DatagramIterator &scan, BamReader *manager); 00082 00083 static TypedWritable *make_AnimChannelMatrixDynamic(const FactoryParams ¶ms); 00084 00085 public: 00086 virtual TypeHandle get_type() const { 00087 return get_class_type(); 00088 } 00089 virtual TypeHandle force_init_type() {init_type(); return get_class_type();} 00090 static TypeHandle get_class_type() { 00091 return _type_handle; 00092 } 00093 static void init_type() { 00094 AnimChannelMatrix::init_type(); 00095 register_type(_type_handle, "AnimChannelMatrixDynamic", 00096 AnimChannelMatrix::get_class_type()); 00097 } 00098 00099 private: 00100 static TypeHandle _type_handle; 00101 }; 00102 00103 #include "animChannelMatrixDynamic.I" 00104 00105 #endif