Panda3D
|
00001 // Filename: animChannelMatrixFixed.cxx 00002 // Created by: drose (19Jan06) 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 #include "animChannelMatrixFixed.h" 00016 #include "compose_matrix.h" 00017 00018 TypeHandle AnimChannelMatrixFixed::_type_handle; 00019 00020 //////////////////////////////////////////////////////////////////// 00021 // Function: AnimChannelMatrixFixed::Copy Constructor 00022 // Access: Protected 00023 // Description: Creates a new AnimChannelMatrixFixed, just like this 00024 // one, without copying any children. The new copy is 00025 // added to the indicated parent. Intended to be called 00026 // by make_copy() only. 00027 //////////////////////////////////////////////////////////////////// 00028 AnimChannelMatrixFixed:: 00029 AnimChannelMatrixFixed(AnimGroup *parent, const AnimChannelMatrixFixed ©) : 00030 AnimChannel<ACMatrixSwitchType>(parent, copy), 00031 _pos(copy._pos), 00032 _hpr(copy._hpr), 00033 _scale(copy._scale) 00034 { 00035 } 00036 00037 //////////////////////////////////////////////////////////////////// 00038 // Function: AnimChannelMatrixFixed::Constructor 00039 // Access: Public 00040 // Description: 00041 //////////////////////////////////////////////////////////////////// 00042 AnimChannelMatrixFixed:: 00043 AnimChannelMatrixFixed(const string &name, const LVecBase3 &pos, const LVecBase3 &hpr, const LVecBase3 &scale) : 00044 AnimChannel<ACMatrixSwitchType>(name), 00045 _pos(pos), _hpr(hpr), _scale(scale) 00046 { 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function: AnimChannelFixed::has_changed 00051 // Access: Public, Virtual 00052 // Description: 00053 //////////////////////////////////////////////////////////////////// 00054 bool AnimChannelMatrixFixed:: 00055 has_changed(int, double, int, double) { 00056 return false; 00057 } 00058 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Function: AnimChannelFixed::get_value 00062 // Access: Public, Virtual 00063 // Description: 00064 //////////////////////////////////////////////////////////////////// 00065 void AnimChannelMatrixFixed:: 00066 get_value(int, LMatrix4 &value) { 00067 compose_matrix(value, _scale, LVecBase3::zero(), _hpr, _pos); 00068 } 00069 00070 //////////////////////////////////////////////////////////////////// 00071 // Function: AnimChannelMatrixFixed::get_value_no_scale_shear 00072 // Access: Public, Virtual 00073 // Description: Gets the value of the channel at the indicated frame, 00074 // without any scale or shear information. 00075 //////////////////////////////////////////////////////////////////// 00076 void AnimChannelMatrixFixed:: 00077 get_value_no_scale_shear(int, LMatrix4 &mat) { 00078 compose_matrix(mat, LVecBase3(1.0f, 1.0f, 1.0f), LVecBase3::zero(), 00079 _hpr, _pos); 00080 } 00081 00082 //////////////////////////////////////////////////////////////////// 00083 // Function: AnimChannelMatrixFixed::get_scale 00084 // Access: Public, Virtual 00085 // Description: Gets the scale value at the indicated frame. 00086 //////////////////////////////////////////////////////////////////// 00087 void AnimChannelMatrixFixed:: 00088 get_scale(int, LVecBase3 &scale) { 00089 scale = _scale; 00090 } 00091 00092 //////////////////////////////////////////////////////////////////// 00093 // Function: AnimChannelMatrixFixed::get_hpr 00094 // Access: Public, Virtual 00095 // Description: Returns the h, p, and r components associated 00096 // with the current frame. As above, this only makes 00097 // sense for a matrix-type channel. 00098 //////////////////////////////////////////////////////////////////// 00099 void AnimChannelMatrixFixed:: 00100 get_hpr(int, LVecBase3 &hpr) { 00101 hpr = _hpr; 00102 } 00103 00104 //////////////////////////////////////////////////////////////////// 00105 // Function: AnimChannelMatrixFixed::get_quat 00106 // Access: Public, Virtual 00107 // Description: Returns the rotation component associated with the 00108 // current frame, expressed as a quaternion. As above, 00109 // this only makes sense for a matrix-type channel. 00110 //////////////////////////////////////////////////////////////////// 00111 void AnimChannelMatrixFixed:: 00112 get_quat(int, LQuaternion &quat) { 00113 quat.set_hpr(_hpr); 00114 } 00115 00116 //////////////////////////////////////////////////////////////////// 00117 // Function: AnimChannelMatrixFixed::get_pos 00118 // Access: Public, Virtual 00119 // Description: Returns the x, y, and z translation components 00120 // associated with the current frame. As above, this 00121 // only makes sense for a matrix-type channel. 00122 //////////////////////////////////////////////////////////////////// 00123 void AnimChannelMatrixFixed:: 00124 get_pos(int, LVecBase3 &pos) { 00125 pos = _pos; 00126 } 00127 00128 //////////////////////////////////////////////////////////////////// 00129 // Function: AnimChannelMatrixFixed::get_shear 00130 // Access: Public, Virtual 00131 // Description: Returns the a, b, and c shear components associated 00132 // with the current frame. As above, this only makes 00133 // sense for a matrix-type channel. 00134 //////////////////////////////////////////////////////////////////// 00135 void AnimChannelMatrixFixed:: 00136 get_shear(int, LVecBase3 &shear) { 00137 shear = LVecBase3::zero(); 00138 } 00139 00140 //////////////////////////////////////////////////////////////////// 00141 // Function: AnimChannelMatrixFixed::output 00142 // Access: Public, Virtual 00143 // Description: 00144 //////////////////////////////////////////////////////////////////// 00145 void AnimChannelMatrixFixed:: 00146 output(ostream &out) const { 00147 AnimChannel<ACMatrixSwitchType>::output(out); 00148 out << ": pos " << _pos << " hpr " << _hpr << " scale " << _scale; 00149 } 00150 00151 //////////////////////////////////////////////////////////////////// 00152 // Function: AnimChannelMatrixFixed::register_with_read_factory 00153 // Access: Public, Static 00154 // Description: Tells the BamReader how to create objects of type 00155 // AnimChannelMatrixFixed. 00156 //////////////////////////////////////////////////////////////////// 00157 void AnimChannelMatrixFixed:: 00158 register_with_read_factory() { 00159 BamReader::get_factory()->register_factory(get_class_type(), make_from_bam); 00160 } 00161 00162 //////////////////////////////////////////////////////////////////// 00163 // Function: AnimChannelMatrixFixed::write_datagram 00164 // Access: Public, Virtual 00165 // Description: Writes the contents of this object to the datagram 00166 // for shipping out to a Bam file. 00167 //////////////////////////////////////////////////////////////////// 00168 void AnimChannelMatrixFixed:: 00169 write_datagram(BamWriter *manager, Datagram &dg) { 00170 AnimChannel<ACMatrixSwitchType>::write_datagram(manager, dg); 00171 00172 _pos.write_datagram(dg); 00173 _hpr.write_datagram(dg); 00174 _scale.write_datagram(dg); 00175 } 00176 00177 //////////////////////////////////////////////////////////////////// 00178 // Function: AnimChannelMatrixFixed::make_from_bam 00179 // Access: Protected, Static 00180 // Description: This function is called by the BamReader's factory 00181 // when a new object of type AnimChannelMatrixFixed is encountered 00182 // in the Bam file. It should create the AnimChannelMatrixFixed 00183 // and extract its information from the file. 00184 //////////////////////////////////////////////////////////////////// 00185 TypedWritable *AnimChannelMatrixFixed:: 00186 make_from_bam(const FactoryParams ¶ms) { 00187 AnimChannelMatrixFixed *chan = new AnimChannelMatrixFixed("", LVecBase3::zero(), LVecBase3::zero(), LVecBase3::zero()); 00188 DatagramIterator scan; 00189 BamReader *manager; 00190 00191 parse_params(params, scan, manager); 00192 chan->fillin(scan, manager); 00193 00194 return chan; 00195 } 00196 00197 //////////////////////////////////////////////////////////////////// 00198 // Function: AnimChannelMatrixFixed::fillin 00199 // Access: Protected 00200 // Description: This internal function is called by make_from_bam to 00201 // read in all of the relevant data from the BamFile for 00202 // the new AnimChannelMatrixFixed. 00203 //////////////////////////////////////////////////////////////////// 00204 void AnimChannelMatrixFixed:: 00205 fillin(DatagramIterator &scan, BamReader *manager) { 00206 AnimChannel<ACMatrixSwitchType>::fillin(scan, manager); 00207 00208 _pos.read_datagram(scan); 00209 _hpr.read_datagram(scan); 00210 _scale.read_datagram(scan); 00211 }