Panda3D

eggXfmAnimData.I

00001 // Filename: eggXfmAnimData.I
00002 // Created by:  drose (19Feb99)
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 
00016 ////////////////////////////////////////////////////////////////////
00017 //     Function: EggXfmAnimData::Constructor
00018 //       Access: Public
00019 //  Description:
00020 ////////////////////////////////////////////////////////////////////
00021 INLINE EggXfmAnimData::
00022 EggXfmAnimData(const string &name, CoordinateSystem cs) : EggAnimData(name) {
00023   _coordsys = cs;
00024 }
00025 
00026 
00027 ////////////////////////////////////////////////////////////////////
00028 //     Function: EggXfmAnimData::Copy constructor
00029 //       Access: Public
00030 //  Description:
00031 ////////////////////////////////////////////////////////////////////
00032 INLINE EggXfmAnimData::
00033 EggXfmAnimData(const EggXfmAnimData &copy)
00034   : EggAnimData(copy),
00035     _order(copy._order),
00036     _contents(copy._contents),
00037     _coordsys(copy._coordsys) {
00038 }
00039 
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //     Function: EggXfmAnimData::Copy assignment operator
00043 //       Access: Public
00044 //  Description:
00045 ////////////////////////////////////////////////////////////////////
00046 INLINE EggXfmAnimData &EggXfmAnimData::
00047 operator = (const EggXfmAnimData &copy) {
00048   EggAnimData::operator = (copy);
00049   _order = copy._order;
00050   _contents = copy._contents;
00051   _coordsys = copy._coordsys;
00052 
00053   return *this;
00054 }
00055 
00056 
00057 ////////////////////////////////////////////////////////////////////
00058 //     Function: EggXfmAnimData::set_order
00059 //       Access: Public
00060 //  Description:
00061 ////////////////////////////////////////////////////////////////////
00062 INLINE void EggXfmAnimData::
00063 set_order(const string &order) {
00064   _order = order;
00065 }
00066 
00067 ////////////////////////////////////////////////////////////////////
00068 //     Function: EggXfmAnimData::clear_order
00069 //       Access: Public
00070 //  Description:
00071 ////////////////////////////////////////////////////////////////////
00072 INLINE void EggXfmAnimData::
00073 clear_order() {
00074   _order = "";
00075 }
00076 
00077 ////////////////////////////////////////////////////////////////////
00078 //     Function: EggXfmAnimData::has_order
00079 //       Access: Public
00080 //  Description:
00081 ////////////////////////////////////////////////////////////////////
00082 INLINE bool EggXfmAnimData::
00083 has_order() const {
00084   return !_order.empty();
00085 }
00086 
00087 ////////////////////////////////////////////////////////////////////
00088 //     Function: EggXfmAnimData::get_order
00089 //       Access: Public
00090 //  Description:
00091 ////////////////////////////////////////////////////////////////////
00092 INLINE const string &EggXfmAnimData::
00093 get_order() const {
00094   if (has_order()) {
00095     return _order;
00096   } else {
00097     return get_standard_order();
00098   }
00099 }
00100 
00101 ////////////////////////////////////////////////////////////////////
00102 //     Function: EggXfmAnimData::get_standard_order
00103 //       Access: Public, Static
00104 //  Description: Returns the standard order of matrix component
00105 //               composition.  This is what the order string must be
00106 //               set to in order to use set_value() or add_data()
00107 //               successfully.
00108 ////////////////////////////////////////////////////////////////////
00109 INLINE const string &EggXfmAnimData::
00110 get_standard_order() {
00111   return EggXfmSAnim::get_standard_order();
00112 }
00113 
00114 
00115 ////////////////////////////////////////////////////////////////////
00116 //     Function: EggXfmAnimData::set_contents
00117 //       Access: Public
00118 //  Description:
00119 ////////////////////////////////////////////////////////////////////
00120 INLINE void EggXfmAnimData::
00121 set_contents(const string &contents) {
00122   _contents = contents;
00123 }
00124 
00125 ////////////////////////////////////////////////////////////////////
00126 //     Function: EggXfmAnimData::clear_contents
00127 //       Access: Public
00128 //  Description:
00129 ////////////////////////////////////////////////////////////////////
00130 INLINE void EggXfmAnimData::
00131 clear_contents() {
00132   _contents = "";
00133 }
00134 
00135 ////////////////////////////////////////////////////////////////////
00136 //     Function: EggXfmAnimData::has_contents
00137 //       Access: Public
00138 //  Description:
00139 ////////////////////////////////////////////////////////////////////
00140 INLINE bool EggXfmAnimData::
00141 has_contents() const {
00142   return !_contents.empty();
00143 }
00144 
00145 ////////////////////////////////////////////////////////////////////
00146 //     Function: EggXfmAnimData::get_contents
00147 //       Access: Public
00148 //  Description:
00149 ////////////////////////////////////////////////////////////////////
00150 INLINE const string &EggXfmAnimData::
00151 get_contents() const {
00152   return _contents;
00153 }
00154 
00155 ////////////////////////////////////////////////////////////////////
00156 //     Function: EggXfmAnimData::get_coordinate_system
00157 //       Access: Public
00158 //  Description: Returns the coordinate system this table believes it
00159 //               is defined within.  This should always match the
00160 //               coordinate system of the EggData structure that owns
00161 //               it.  It is necessary to store it here because the
00162 //               meaning of the h, p, and r columns depends on the
00163 //               coordinate system.
00164 ////////////////////////////////////////////////////////////////////
00165 INLINE CoordinateSystem EggXfmAnimData::
00166 get_coordinate_system() const {
00167   return _coordsys;
00168 }
00169 
00170 
00171 ////////////////////////////////////////////////////////////////////
00172 //     Function: EggXfmAnimData::get_num_rows
00173 //       Access: Public
00174 //  Description: Returns the number of rows in the table.
00175 ////////////////////////////////////////////////////////////////////
00176 INLINE int EggXfmAnimData::
00177 get_num_rows() const {
00178   if (get_num_cols() == 0) {
00179     return 0;
00180   }
00181   return get_size() / get_num_cols();
00182 }
00183 
00184 ////////////////////////////////////////////////////////////////////
00185 //     Function: EggXfmAnimData::get_num_cols
00186 //       Access: Public
00187 //  Description: Returns the number of columns in the table.  This is
00188 //               set according to the "contents" string, which defines
00189 //               the meaning of each column.
00190 ////////////////////////////////////////////////////////////////////
00191 INLINE int EggXfmAnimData::
00192 get_num_cols() const {
00193   return _contents.length();
00194 }
00195 
00196 
00197 ////////////////////////////////////////////////////////////////////
00198 //     Function: EggXfmAnimData::get_value
00199 //       Access: Public
00200 //  Description: Returns the value at the indicated row.  Row must be
00201 //               in the range 0 <= row < get_num_rows(); col must be
00202 //               in the range 0 <= col < get_num_cols().
00203 ////////////////////////////////////////////////////////////////////
00204 INLINE double EggXfmAnimData::
00205 get_value(int row, int col) const {
00206   nassertr(get_num_cols() != 0, 0.0);
00207   nassertr(row >= 0 && row < get_num_rows(), 0.0);
00208   nassertr(col >= 0 && col < get_num_cols(), 0.0);
00209   return _data[row * get_num_cols() + col];
00210 }
00211 
00212 
 All Classes Functions Variables Enumerations