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