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