00001 // Filename: lwoClip.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 "lwoClip.h" 00020 #include "iffInputFile.h" 00021 #include "lwoStillImage.h" 00022 00023 #include <indent.h> 00024 00025 TypeHandle LwoClip::_type_handle; 00026 00027 //////////////////////////////////////////////////////////////////// 00028 // Function: LwoClip::read_iff 00029 // Access: Public, Virtual 00030 // Description: Reads the data of the chunk in from the given input 00031 // file, if possible. The ID and length of the chunk 00032 // have already been read. stop_at is the byte position 00033 // of the file to stop at (based on the current position 00034 // at in->get_bytes_read()). Returns true on success, 00035 // false otherwise. 00036 //////////////////////////////////////////////////////////////////// 00037 bool LwoClip:: 00038 read_iff(IffInputFile *in, size_t stop_at) { 00039 _index = in->get_be_int32(); 00040 read_subchunks_iff(in, stop_at); 00041 return true; 00042 } 00043 00044 //////////////////////////////////////////////////////////////////// 00045 // Function: LwoClip::write 00046 // Access: Public, Virtual 00047 // Description: 00048 //////////////////////////////////////////////////////////////////// 00049 void LwoClip:: 00050 write(ostream &out, int indent_level) const { 00051 indent(out, indent_level) 00052 << get_id() << " {\n"; 00053 indent(out, indent_level + 2) 00054 << "index = " << _index << "\n"; 00055 write_chunks(out, indent_level + 2); 00056 indent(out, indent_level) 00057 << "}\n"; 00058 } 00059 00060 //////////////////////////////////////////////////////////////////// 00061 // Function: LwoClip::make_new_chunk 00062 // Access: Protected, Virtual 00063 // Description: Allocates and returns a new chunk of the appropriate 00064 // type based on the given ID, according to the context 00065 // given by this chunk itself. 00066 //////////////////////////////////////////////////////////////////// 00067 IffChunk *LwoClip:: 00068 make_new_chunk(IffInputFile *in, IffId id) { 00069 if (id == IffId("STIL")) { 00070 return new LwoStillImage; 00071 00072 } else { 00073 return IffChunk::make_new_chunk(in, id); 00074 } 00075 } 00076