Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members  

pandatool/src/lwo/lwoSurfaceBlockHeader.cxx

Go to the documentation of this file.
00001 // Filename: lwoSurfaceBlockHeader.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 "lwoSurfaceBlockHeader.h"
00020 #include "lwoInputFile.h"
00021 #include "lwoSurfaceBlockChannel.h"
00022 #include "lwoSurfaceBlockEnabled.h"
00023 #include "lwoSurfaceBlockOpacity.h"
00024 #include "lwoSurfaceBlockAxis.h"
00025 
00026 #include "dcast.h"
00027 #include "indent.h"
00028 
00029 TypeHandle LwoSurfaceBlockHeader::_type_handle;
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: LwoSurfaceBlockHeader::read_iff
00033 //       Access: Public, Virtual
00034 //  Description: Reads the data of the chunk in from the given input
00035 //               file, if possible.  The ID and length of the chunk
00036 //               have already been read.  stop_at is the byte position
00037 //               of the file to stop at (based on the current position
00038 //               at in->get_bytes_read()).  Returns true on success,
00039 //               false otherwise.
00040 ////////////////////////////////////////////////////////////////////
00041 bool LwoSurfaceBlockHeader::
00042 read_iff(IffInputFile *in, size_t stop_at) {
00043   LwoInputFile *lin = DCAST(LwoInputFile, in);
00044 
00045   _ordinal = lin->get_string();
00046   read_subchunks_iff(lin, stop_at);
00047 
00048   return true;
00049 }
00050 
00051 ////////////////////////////////////////////////////////////////////
00052 //     Function: LwoSurfaceBlockHeader::write
00053 //       Access: Public, Virtual
00054 //  Description:
00055 ////////////////////////////////////////////////////////////////////
00056 void LwoSurfaceBlockHeader::
00057 write(ostream &out, int indent_level) const {
00058   indent(out, indent_level)
00059     << get_id() << " {\n";
00060   indent(out, indent_level + 2)
00061     << "ordinal = 0x" << hex << setfill('0');
00062 
00063   string::const_iterator si;
00064   for (si = _ordinal.begin(); si != _ordinal.end(); ++si) {
00065     out << setw(2) << (int)(unsigned char)(*si);
00066   }
00067 
00068   out << dec << setfill(' ') << "\n";
00069 
00070   write_chunks(out, indent_level + 2);
00071   indent(out, indent_level)
00072     << "}\n";
00073 }
00074 
00075 ////////////////////////////////////////////////////////////////////
00076 //     Function: LwoSurfaceBlockHeader::make_new_chunk
00077 //       Access: Protected, Virtual
00078 //  Description: Allocates and returns a new chunk of the appropriate
00079 //               type based on the given ID, according to the context
00080 //               given by this chunk itself.
00081 ////////////////////////////////////////////////////////////////////
00082 IffChunk *LwoSurfaceBlockHeader::
00083 make_new_chunk(IffInputFile *in, IffId id) {
00084   if (id == IffId("CHAN")) {
00085     return new LwoSurfaceBlockChannel;
00086 
00087   } else if (id == IffId("ENAB")) {
00088     return new LwoSurfaceBlockEnabled;
00089 
00090   } else if (id == IffId("OPAC")) {
00091     return new LwoSurfaceBlockOpacity;
00092 
00093   } else if (id == IffId("AXIS")) {
00094     return new LwoSurfaceBlockAxis;
00095 
00096   } else {
00097     return IffChunk::make_new_chunk(in, id);
00098   }
00099 }
00100 

Generated on Fri May 2 03:20:50 2003 for Panda-Tool by doxygen1.3