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