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