Panda3D

lwoSurfaceBlockTMap.cxx

00001 // Filename: lwoSurfaceBlockTMap.cxx
00002 // Created by:  drose (24Apr01)
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 "lwoSurfaceBlockTMap.h"
00016 #include "lwoInputFile.h"
00017 #include "lwoSurfaceBlockCoordSys.h"
00018 #include "lwoSurfaceBlockTransform.h"
00019 #include "lwoSurfaceBlockRefObj.h"
00020 
00021 #include "dcast.h"
00022 #include "indent.h"
00023 
00024 TypeHandle LwoSurfaceBlockTMap::_type_handle;
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: LwoSurfaceBlockTMap::read_iff
00028 //       Access: Public, Virtual
00029 //  Description: Reads the data of the chunk in from the given input
00030 //               file, if possible.  The ID and length of the chunk
00031 //               have already been read.  stop_at is the byte position
00032 //               of the file to stop at (based on the current position
00033 //               at in->get_bytes_read()).  Returns true on success,
00034 //               false otherwise.
00035 ////////////////////////////////////////////////////////////////////
00036 bool LwoSurfaceBlockTMap::
00037 read_iff(IffInputFile *in, size_t stop_at) {
00038   LwoInputFile *lin = DCAST(LwoInputFile, in);
00039 
00040   read_subchunks_iff(lin, stop_at);
00041 
00042   return true;
00043 }
00044 
00045 ////////////////////////////////////////////////////////////////////
00046 //     Function: LwoSurfaceBlockTMap::write
00047 //       Access: Public, Virtual
00048 //  Description:
00049 ////////////////////////////////////////////////////////////////////
00050 void LwoSurfaceBlockTMap::
00051 write(ostream &out, int indent_level) const {
00052   indent(out, indent_level)
00053     << get_id() << " {\n";
00054   write_chunks(out, indent_level + 2);
00055   indent(out, indent_level)
00056     << "}\n";
00057 }
00058 
00059 ////////////////////////////////////////////////////////////////////
00060 //     Function: LwoSurfaceBlockTMap::make_new_chunk
00061 //       Access: Protected, Virtual
00062 //  Description: Allocates and returns a new chunk of the appropriate
00063 //               type based on the given ID, according to the context
00064 //               given by this chunk itself.
00065 ////////////////////////////////////////////////////////////////////
00066 IffChunk *LwoSurfaceBlockTMap::
00067 make_new_chunk(IffInputFile *in, IffId id) {
00068   if (id == IffId("CNTR") ||
00069       id == IffId("SIZE") ||
00070       id == IffId("ROTA")) {
00071     return new LwoSurfaceBlockTransform;
00072 
00073   } else if (id == IffId("OREF")) {
00074     return new LwoSurfaceBlockRefObj;
00075 
00076   } else if (id == IffId("CSYS")) {
00077     return new LwoSurfaceBlockCoordSys;
00078 
00079   } else {
00080     return IffChunk::make_new_chunk(in, id);
00081   }
00082 }
00083 
 All Classes Functions Variables Enumerations