Panda3D

animChannelMatrixXfmTable.h

00001 // Filename: animChannelMatrixXfmTable.h
00002 // Created by:  drose (20Feb99)
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 ANIMCHANNELMATRIXXFMTABLE_H
00016 #define ANIMCHANNELMATRIXXFMTABLE_H
00017 
00018 #include "pandabase.h"
00019 
00020 #include "animChannel.h"
00021 
00022 #include "pointerToArray.h"
00023 #include "pta_stdfloat.h"
00024 #include "compose_matrix.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //       Class : AnimChannelMatrixXfmTable
00028 // Description : An animation channel that issues a matrix each frame,
00029 //               read from a table such as might have been read from
00030 //               an egg file.  The table actually consists of nine
00031 //               sub-tables, each representing one component of the
00032 //               transform: scale, rotate, translate.
00033 ////////////////////////////////////////////////////////////////////
00034 class EXPCL_PANDA_CHAN AnimChannelMatrixXfmTable : public AnimChannelMatrix {
00035 protected:
00036   AnimChannelMatrixXfmTable();
00037   AnimChannelMatrixXfmTable(AnimGroup *parent, const AnimChannelMatrixXfmTable &copy);
00038 
00039 PUBLISHED:
00040   AnimChannelMatrixXfmTable(AnimGroup *parent, const string &name);
00041   virtual ~AnimChannelMatrixXfmTable();
00042   
00043 public:
00044   virtual bool has_changed(int last_frame, double last_frac, 
00045                            int this_frame, double this_frac);
00046   virtual void get_value(int frame, LMatrix4 &mat);
00047 
00048   virtual void get_value_no_scale_shear(int frame, LMatrix4 &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 PUBLISHED:
00056   static INLINE bool is_valid_id(char table_id);
00057 
00058   void set_table(char table_id, const CPTA_stdfloat &table);
00059   INLINE CPTA_stdfloat get_table(char table_id) const;
00060 
00061   void clear_all_tables();
00062   INLINE bool has_table(char table_id) const;
00063   INLINE void clear_table(char table_id);
00064 
00065 public:
00066   virtual void write(ostream &out, int indent_level) const;
00067 
00068 protected:
00069   virtual AnimGroup *make_copy(AnimGroup *parent) const;
00070 
00071   INLINE static char get_table_id(int table_index);
00072   static int get_table_index(char table_id);
00073   INLINE static PN_stdfloat get_default_value(int table_index);
00074 
00075   CPTA_stdfloat _tables[num_matrix_components];
00076 
00077 public:
00078   static void register_with_read_factory();
00079   virtual void write_datagram(BamWriter* manager, Datagram &me);
00080 
00081   static TypedWritable *make_AnimChannelMatrixXfmTable(const FactoryParams &params);
00082 
00083 protected:
00084   void fillin(DatagramIterator& scan, BamReader* manager);
00085 
00086 public:
00087   virtual TypeHandle get_type() const {
00088     return get_class_type();
00089   }
00090   virtual TypeHandle force_init_type() {init_type(); return get_class_type();}
00091   static TypeHandle get_class_type() {
00092     return _type_handle;
00093   }
00094   static void init_type() {
00095     AnimChannelMatrix::init_type();
00096     register_type(_type_handle, "AnimChannelMatrixXfmTable",
00097                   AnimChannelMatrix::get_class_type());
00098   }
00099 
00100 private:
00101   static TypeHandle _type_handle;
00102 };
00103 
00104 #include "animChannelMatrixXfmTable.I"
00105 
00106 #endif
 All Classes Functions Variables Enumerations