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