00001 // Filename: lwoHeader.cxx 00002 // Created by: drose (24Apr01) 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 "lwoHeader.h" 00020 #include "lwoInputFile.h" 00021 00022 #include "dcast.h" 00023 #include "indent.h" 00024 00025 TypeHandle LwoHeader::_type_handle; 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Function: LwoHeader::Constructor 00029 // Access: Public 00030 // Description: 00031 //////////////////////////////////////////////////////////////////// 00032 LwoHeader:: 00033 LwoHeader() { 00034 _valid = false; 00035 _version = 0.0; 00036 } 00037 00038 //////////////////////////////////////////////////////////////////// 00039 // Function: LwoHeader::read_iff 00040 // Access: Public, Virtual 00041 // Description: Reads the data of the chunk in from the given input 00042 // file, if possible. The ID and length of the chunk 00043 // have already been read. stop_at is the byte position 00044 // of the file to stop at (based on the current position 00045 // at in->get_bytes_read()). Returns true on success, 00046 // false otherwise. 00047 //////////////////////////////////////////////////////////////////// 00048 bool LwoHeader:: 00049 read_iff(IffInputFile *in, size_t stop_at) { 00050 LwoInputFile *lin = DCAST(LwoInputFile, in); 00051 00052 _lwid = lin->get_id(); 00053 00054 if (_lwid == IffId("LWO2")) { 00055 _valid = true; 00056 _version = 6.0; 00057 } else if (_lwid == IffId("LWOB")) { 00058 _valid = true; 00059 _version = 5.0; 00060 } 00061 00062 if (_valid) { 00063 lin->set_lwo_version(_version); 00064 } 00065 00066 read_chunks_iff(lin, stop_at); 00067 00068 return true; 00069 } 00070 00071 //////////////////////////////////////////////////////////////////// 00072 // Function: LwoHeader::write 00073 // Access: Public, Virtual 00074 // Description: 00075 //////////////////////////////////////////////////////////////////// 00076 void LwoHeader:: 00077 write(ostream &out, int indent_level) const { 00078 indent(out, indent_level) 00079 << get_id() << " {\n"; 00080 indent(out, indent_level + 2) 00081 << "id = " << _lwid << "\n"; 00082 write_chunks(out, indent_level + 2); 00083 indent(out, indent_level) 00084 << "}\n"; 00085 }