Panda3D
 All Classes Functions Variables Enumerations
fltVectorRecord.cxx
00001 // Filename: fltVectorRecord.cxx
00002 // Created by:  drose (30Aug02)
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 "fltVectorRecord.h"
00016 #include "fltRecordReader.h"
00017 #include "fltRecordWriter.h"
00018 
00019 TypeHandle FltVectorRecord::_type_handle;
00020 
00021 ////////////////////////////////////////////////////////////////////
00022 //     Function: FltVectorRecord::Constructor
00023 //       Access: Public
00024 //  Description:
00025 ////////////////////////////////////////////////////////////////////
00026 FltVectorRecord::
00027 FltVectorRecord(FltHeader *header) : FltRecord(header) {
00028   _vector.set(0.0f, 0.0f, 0.0f);
00029 }
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: FltVectorRecord::get_vector
00033 //       Access: Public
00034 //  Description: Returns the vector value.
00035 ////////////////////////////////////////////////////////////////////
00036 const LVector3 &FltVectorRecord::
00037 get_vector() const {
00038   return _vector;
00039 }
00040 
00041 ////////////////////////////////////////////////////////////////////
00042 //     Function: FltVectorRecord::extract_record
00043 //       Access: Protected, Virtual
00044 //  Description: Fills in the information in this record based on the
00045 //               information given in the indicated datagram, whose
00046 //               opcode has already been read.  Returns true on
00047 //               success, false if the datagram is invalid.
00048 ////////////////////////////////////////////////////////////////////
00049 bool FltVectorRecord::
00050 extract_record(FltRecordReader &reader) {
00051   if (!FltRecord::extract_record(reader)) {
00052     return false;
00053   }
00054 
00055   nassertr(reader.get_opcode() == FO_vector, false);
00056   DatagramIterator &iterator = reader.get_iterator();
00057 
00058   _vector[0] = iterator.get_be_float32();
00059   _vector[1] = iterator.get_be_float32();
00060   _vector[2] = iterator.get_be_float32();
00061 
00062   check_remaining_size(iterator);
00063   return true;
00064 }
00065 
00066 ////////////////////////////////////////////////////////////////////
00067 //     Function: FltVectorRecord::build_record
00068 //       Access: Protected, Virtual
00069 //  Description: Fills up the current record on the FltRecordWriter with
00070 //               data for this record, but does not advance the
00071 //               writer.  Returns true on success, false if there is
00072 //               some error.
00073 ////////////////////////////////////////////////////////////////////
00074 bool FltVectorRecord::
00075 build_record(FltRecordWriter &writer) const {
00076   if (!FltRecord::build_record(writer)) {
00077     return false;
00078   }
00079 
00080   writer.set_opcode(FO_vector);
00081   Datagram &datagram = writer.update_datagram();
00082 
00083   datagram.add_be_float32(_vector[0]);
00084   datagram.add_be_float32(_vector[1]);
00085   datagram.add_be_float32(_vector[2]);
00086 
00087   return true;
00088 }
00089 
 All Classes Functions Variables Enumerations