00001 // Filename: stTransform.cxx00002 // Created by: drose (06Oct10)00003 //00004 ////////////////////////////////////////////////////////////////////00005 //00006 // PANDA 3D SOFTWARE00007 // Copyright (c) Carnegie Mellon University. All rights reserved.00008 //00009 // All use of this software is subject to the terms of the revised BSD00010 // license. You should have received a copy of this license along00011 // with this source code in a file named "LICENSE."00012 //00013 ////////////////////////////////////////////////////////////////////00014
00015 #include "stTransform.h"00016
00017 STTransform STTransform::_ident_mat;
00018
00019 ////////////////////////////////////////////////////////////////////00020 // Function: STTransform::Constructor00021 // Access: Published00022 // Description: This constructor accepts a Panda TransformState, for00023 // instance as extracted from the scene graph.00024 ////////////////////////////////////////////////////////////////////00025 STTransform::00026STTransform(constTransformState *trans) {
00027 #ifndef NDEBUG00028 // Ensure these are initialized to reasonable values in case we fail00029 // an assertion below.00030 _pos.set(0.0f, 0.0f, 0.0f);
00031 _rotate = 0.0f;
00032 _scale = 1.0f;
00033 #endif00034
00035 nassertv(trans->has_components());
00036 _pos = trans->get_pos();
00037
00038 constLVecBase3 &hpr = trans->get_hpr();
00039 nassertv(IS_NEARLY_ZERO(hpr[1]) && IS_NEARLY_ZERO(hpr[2]));
00040 _rotate = hpr[0];
00041
00042 nassertv(trans->has_uniform_scale());
00043 _scale = trans->get_uniform_scale();
00044 }
00045
00046 ////////////////////////////////////////////////////////////////////00047 // Function: STTransform::output00048 // Access: Published00049 // Description: 00050 ////////////////////////////////////////////////////////////////////00051 void STTransform::
00052 output(ostream &out) const {
00053 out << "STTransform(" << _pos << ", " << _rotate << ", " << _scale << ")";
00054 }
00055
00056 ////////////////////////////////////////////////////////////////////00057 // Function: STTransform::write_datagram00058 // Access: Public00059 // Description: Writes the contents of this object to the datagram00060 // for shipping out to a Bam file.00061 ////////////////////////////////////////////////////////////////////00062 voidSTTransform::00063write_datagram(BamWriter *manager, Datagram &dg) {
00064 _pos.write_datagram(dg);
00065 dg.add_stdfloat(_rotate);
00066 dg.add_stdfloat(_scale);
00067 }
00068
00069 ////////////////////////////////////////////////////////////////////00070 // Function: STTransform::fillin00071 // Access: Public00072 // Description: This internal function is called by make_from_bam to00073 // read in all of the relevant data from the BamFile for00074 // the new SpeedTreeNode.00075 ////////////////////////////////////////////////////////////////////00076 voidSTTransform::00077fillin(DatagramIterator &scan, BamReader *manager) {
00078 _pos.read_datagram(scan);
00079 _rotate = scan.get_stdfloat();
00080 _scale = scan.get_stdfloat();
00081 }