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