00001 // Filename: lwoLayer.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 "lwoLayer.h" 00020 #include "lwoInputFile.h" 00021 00022 #include "dcast.h" 00023 #include "indent.h" 00024 00025 TypeHandle LwoLayer::_type_handle; 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Function: LwoLayer::make_generic 00029 // Access: Public 00030 // Description: Resets the layer's parameters to initial defaults for 00031 // a generic layer created implicitly. 00032 //////////////////////////////////////////////////////////////////// 00033 void LwoLayer:: 00034 make_generic() { 00035 _number = -1; 00036 _flags = 0; 00037 _pivot.set(0.0, 0.0, 0.0); 00038 _name = "Generic"; 00039 _parent = -1; 00040 } 00041 00042 //////////////////////////////////////////////////////////////////// 00043 // Function: LwoLayer::read_iff 00044 // Access: Public, Virtual 00045 // Description: Reads the data of the chunk in from the given input 00046 // file, if possible. The ID and length of the chunk 00047 // have already been read. stop_at is the byte position 00048 // of the file to stop at (based on the current position 00049 // at in->get_bytes_read()). Returns true on success, 00050 // false otherwise. 00051 //////////////////////////////////////////////////////////////////// 00052 bool LwoLayer:: 00053 read_iff(IffInputFile *in, size_t stop_at) { 00054 LwoInputFile *lin = DCAST(LwoInputFile, in); 00055 00056 _number = lin->get_be_uint16(); 00057 _flags = lin->get_be_uint16(); 00058 _pivot = lin->get_vec3(); 00059 _name = lin->get_string(); 00060 00061 if (lin->get_bytes_read() >= stop_at) { 00062 _parent = -1; 00063 } else { 00064 _parent = lin->get_be_uint16(); 00065 if (_parent == 0xffff) { 00066 _parent = -1; 00067 } 00068 } 00069 00070 return true; 00071 } 00072 00073 //////////////////////////////////////////////////////////////////// 00074 // Function: LwoLayer::write 00075 // Access: Public, Virtual 00076 // Description: 00077 //////////////////////////////////////////////////////////////////// 00078 void LwoLayer:: 00079 write(ostream &out, int indent_level) const { 00080 indent(out, indent_level) 00081 << get_id() << " { number = " << _number << ", flags = 0x" 00082 << hex << _flags << dec << ", pivot = " << _pivot 00083 << ", _name = \"" << _name << "\", _parent = " << _parent << " }\n"; 00084 }