00001 // Filename: fltVectorRecord.cxx00002 // Created by: drose (30Aug02)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 "fltVectorRecord.h"00016 #include "fltRecordReader.h"00017 #include "fltRecordWriter.h"00018
00019 TypeHandle FltVectorRecord::_type_handle;
00020
00021 ////////////////////////////////////////////////////////////////////00022 // Function: FltVectorRecord::Constructor00023 // Access: Public00024 // 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_vector00033 // Access: Public00034 // Description: Returns the vector value.00035 ////////////////////////////////////////////////////////////////////00036 constLVector3 &FltVectorRecord::00037get_vector() const {
00038 return _vector;
00039 }
00040
00041 ////////////////////////////////////////////////////////////////////00042 // Function: FltVectorRecord::extract_record00043 // Access: Protected, Virtual00044 // Description: Fills in the information in this record based on the00045 // information given in the indicated datagram, whose00046 // opcode has already been read. Returns true on00047 // success, false if the datagram is invalid.00048 ////////////////////////////////////////////////////////////////////00049 boolFltVectorRecord::00050extract_record(FltRecordReader &reader) {
00051 if (!FltRecord::extract_record(reader)) {
00052 returnfalse;
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 returntrue;
00064 }
00065
00066 ////////////////////////////////////////////////////////////////////00067 // Function: FltVectorRecord::build_record00068 // Access: Protected, Virtual00069 // Description: Fills up the current record on the FltRecordWriter with00070 // data for this record, but does not advance the00071 // writer. Returns true on success, false if there is00072 // some error.00073 ////////////////////////////////////////////////////////////////////00074 boolFltVectorRecord::00075build_record(FltRecordWriter &writer) const {
00076 if (!FltRecord::build_record(writer)) {
00077 returnfalse;
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 returntrue;
00088 }
00089