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

pandatool/src/lwo/lwoSurface.cxx

Go to the documentation of this file.
00001 // Filename: lwoSurface.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 "lwoSurface.h"
00020 #include "iffInputFile.h"
00021 #include "lwoSurfaceBlock.h"
00022 #include "lwoSurfaceColor.h"
00023 #include "lwoSurfaceParameter.h"
00024 #include "lwoSurfaceSidedness.h"
00025 #include "lwoSurfaceSmoothingAngle.h"
00026 
00027 #include <indent.h>
00028 
00029 TypeHandle LwoSurface::_type_handle;
00030 
00031 ////////////////////////////////////////////////////////////////////
00032 //     Function: LwoSurface::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 LwoSurface::
00042 read_iff(IffInputFile *in, size_t stop_at) {
00043   _name = in->get_string();
00044   _source = in->get_string();
00045   read_subchunks_iff(in, stop_at);
00046   return true;
00047 }
00048 
00049 ////////////////////////////////////////////////////////////////////
00050 //     Function: LwoSurface::write
00051 //       Access: Public, Virtual
00052 //  Description:
00053 ////////////////////////////////////////////////////////////////////
00054 void LwoSurface::
00055 write(ostream &out, int indent_level) const {
00056   indent(out, indent_level)
00057     << get_id() << " {\n";
00058   indent(out, indent_level + 2)
00059     << "name = \"" << _name << "\", source = \"" << _source << "\"\n";
00060   write_chunks(out, indent_level + 2);
00061   indent(out, indent_level)
00062     << "}\n";
00063 }
00064 
00065 ////////////////////////////////////////////////////////////////////
00066 //     Function: LwoSurface::make_new_chunk
00067 //       Access: Protected, Virtual
00068 //  Description: Allocates and returns a new chunk of the appropriate
00069 //               type based on the given ID, according to the context
00070 //               given by this chunk itself.
00071 ////////////////////////////////////////////////////////////////////
00072 IffChunk *LwoSurface::
00073 make_new_chunk(IffInputFile *in, IffId id) {
00074   if (id == IffId("COLR")) {
00075     return new LwoSurfaceColor;
00076 
00077   } else if (id == IffId("DIFF") ||
00078              id == IffId("LUMI") ||
00079              id == IffId("SPEC") ||
00080              id == IffId("REFL") ||
00081              id == IffId("TRAN") ||
00082              id == IffId("TRNL") ||
00083              id == IffId("GLOS") ||
00084              id == IffId("SHRP") ||
00085              id == IffId("BUMP") ||
00086              id == IffId("RSAN") ||
00087              id == IffId("RIND")) {
00088     return new LwoSurfaceParameter;
00089 
00090   } else if (id == IffId("SIDE")) {
00091     return new LwoSurfaceSidedness;
00092 
00093   } else if (id == IffId("SMAN")) {
00094     return new LwoSurfaceSmoothingAngle;
00095 
00096   } else if (id == IffId("BLOK")) {
00097     return new LwoSurfaceBlock;
00098 
00099   } else {
00100     return IffChunk::make_new_chunk(in, id);
00101   }
00102 }
00103 

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