Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/flt/fltTransformTranslate.cxx

Go to the documentation of this file.
00001 // Filename: fltTransformTranslate.cxx
00002 // Created by:  drose (30Aug00)
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 #include "fltTransformTranslate.h"
00020 #include "fltRecordReader.h"
00021 #include "fltRecordWriter.h"
00022 
00023 TypeHandle FltTransformTranslate::_type_handle;
00024 
00025 ////////////////////////////////////////////////////////////////////
00026 //     Function: FltTransformTranslate::Constructor
00027 //       Access: Public
00028 //  Description:
00029 ////////////////////////////////////////////////////////////////////
00030 FltTransformTranslate::
00031 FltTransformTranslate(FltHeader *header) : FltTransformRecord(header) {
00032   _from.set(0.0, 0.0, 0.0);
00033   _delta.set(0.0, 0.0, 0.0);
00034 }
00035 
00036 ////////////////////////////////////////////////////////////////////
00037 //     Function: FltTransformTranslate::set
00038 //       Access: Public
00039 //  Description: Defines the translation.  The "from" point seems to
00040 //               be pretty much ignored.
00041 ////////////////////////////////////////////////////////////////////
00042 void FltTransformTranslate::
00043 set(const LPoint3d &from, const LVector3d &delta) {
00044   _from = from;
00045   _delta = delta;
00046 
00047   recompute_matrix();
00048 }
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: FltTransformTranslate::get_from
00052 //       Access: Public
00053 //  Description: Returns the reference point of the translation.  This
00054 //               is largely meaningless.
00055 ////////////////////////////////////////////////////////////////////
00056 const LPoint3d &FltTransformTranslate::
00057 get_from() const {
00058   return _from;
00059 }
00060 
00061 ////////////////////////////////////////////////////////////////////
00062 //     Function: FltTransformTranslate::get_delta
00063 //       Access: Public
00064 //  Description:
00065 ////////////////////////////////////////////////////////////////////
00066 const LVector3d &FltTransformTranslate::
00067 get_delta() const {
00068   return _delta;
00069 }
00070 
00071 ////////////////////////////////////////////////////////////////////
00072 //     Function: FltTransformTranslate::recompute_matrix
00073 //       Access: Private
00074 //  Description:
00075 ////////////////////////////////////////////////////////////////////
00076 void FltTransformTranslate::
00077 recompute_matrix() {
00078   _matrix = LMatrix4d::translate_mat(_delta);
00079 }
00080 
00081 ////////////////////////////////////////////////////////////////////
00082 //     Function: FltTransformTranslate::extract_record
00083 //       Access: Protected, Virtual
00084 //  Description: Fills in the information in this record based on the
00085 //               information given in the indicated datagram, whose
00086 //               opcode has already been read.  Returns true on
00087 //               success, false if the datagram is invalid.
00088 ////////////////////////////////////////////////////////////////////
00089 bool FltTransformTranslate::
00090 extract_record(FltRecordReader &reader) {
00091   if (!FltTransformRecord::extract_record(reader)) {
00092     return false;
00093   }
00094 
00095   nassertr(reader.get_opcode() == FO_translate, false);
00096   DatagramIterator &iterator = reader.get_iterator();
00097 
00098   iterator.skip_bytes(4);   // Undocumented additional padding.
00099 
00100   _from[0] = iterator.get_be_float64();
00101   _from[1] = iterator.get_be_float64();
00102   _from[2] = iterator.get_be_float64();
00103   _delta[0] = iterator.get_be_float64();
00104   _delta[1] = iterator.get_be_float64();
00105   _delta[2] = iterator.get_be_float64();
00106 
00107   //  iterator.skip_bytes(4);   // Undocumented additional padding.
00108 
00109   recompute_matrix();
00110 
00111   check_remaining_size(iterator);
00112   return true;
00113 }
00114 
00115 ////////////////////////////////////////////////////////////////////
00116 //     Function: FltTransformTranslate::build_record
00117 //       Access: Protected, Virtual
00118 //  Description: Fills up the current record on the FltRecordWriter with
00119 //               data for this record, but does not advance the
00120 //               writer.  Returns true on success, false if there is
00121 //               some error.
00122 ////////////////////////////////////////////////////////////////////
00123 bool FltTransformTranslate::
00124 build_record(FltRecordWriter &writer) const {
00125   if (!FltTransformRecord::build_record(writer)) {
00126     return false;
00127   }
00128 
00129   writer.set_opcode(FO_translate);
00130   Datagram &datagram = writer.update_datagram();
00131 
00132   datagram.pad_bytes(4);   // Undocumented additional padding.
00133 
00134   datagram.add_be_float64(_from[0]);
00135   datagram.add_be_float64(_from[1]);
00136   datagram.add_be_float64(_from[2]);
00137   datagram.add_be_float64(_delta[0]);
00138   datagram.add_be_float64(_delta[1]);
00139   datagram.add_be_float64(_delta[2]);
00140 
00141   //  datagram.pad_bytes(4);   // Undocumented additional padding.
00142 
00143   return true;
00144 }
00145 

Generated on Fri May 2 03:19:45 2003 for Panda-Tool by doxygen1.3