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

pandatool/src/eggbase/eggMultiBase.cxx

Go to the documentation of this file.
00001 // Filename: eggMultiBase.cxx
00002 // Created by:  drose (02Nov00)
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 "eggMultiBase.h"
00020 #include "eggBase.h"
00021 #include "eggData.h"
00022 #include "eggComment.h"
00023 #include "filename.h"
00024 #include "dSearchPath.h"
00025 
00026 ////////////////////////////////////////////////////////////////////
00027 //     Function: EggMultiBase::Constructor
00028 //       Access: Public
00029 //  Description:
00030 ////////////////////////////////////////////////////////////////////
00031 EggMultiBase::
00032 EggMultiBase() {
00033   add_option
00034     ("cs", "coordinate-system", 80,
00035      "Specify the coordinate system to operate in.  This may be one of "
00036      "'y-up', 'z-up', 'y-up-left', or 'z-up-left'.",
00037      &EggMultiBase::dispatch_coordinate_system,
00038      &_got_coordinate_system, &_coordinate_system);
00039 
00040   add_option
00041     ("f", "", 80,
00042      "Force complete loading: load up the egg file along with all of its "
00043      "external references.",
00044      &EggMultiBase::dispatch_none, &_force_complete);
00045 
00046   _coordinate_system = CS_yup_right;
00047 }
00048 
00049 
00050 ////////////////////////////////////////////////////////////////////
00051 //     Function: EggMultiBase::append_command_comment
00052 //       Access: Protected
00053 //  Description: Inserts a comment into the beginning of the indicated
00054 //               egg file corresponding to the command line that
00055 //               invoked this program.
00056 //
00057 //               Normally this function is called automatically when
00058 //               appropriate by EggWriter, and it's not necessary to
00059 //               call it explicitly.
00060 ////////////////////////////////////////////////////////////////////
00061 void EggMultiBase::
00062 append_command_comment(EggData &data) {
00063   append_command_comment(data, get_exec_command());
00064 }
00065 
00066 ////////////////////////////////////////////////////////////////////
00067 //     Function: EggMultiBase::append_command_comment
00068 //       Access: Protected, Static
00069 //  Description: Inserts a comment into the beginning of the indicated
00070 //               egg file corresponding to the command line that
00071 //               invoked this program.
00072 //
00073 //               Normally this function is called automatically when
00074 //               appropriate by EggWriter, and it's not necessary to
00075 //               call it explicitly.
00076 ////////////////////////////////////////////////////////////////////
00077 void EggMultiBase::
00078 append_command_comment(EggData &data, const string &comment) {
00079   data.insert(data.begin(), new EggComment("", comment));
00080 }
00081 
00082 ////////////////////////////////////////////////////////////////////
00083 //     Function: EggMultiBase::read_egg
00084 //       Access: Protected, Virtual
00085 //  Description: Allocates and returns a new EggData structure that
00086 //               represents the indicated egg file.  If the egg file
00087 //               cannot be read for some reason, returns NULL.
00088 //
00089 //               This can be overridden by derived classes to control
00090 //               how the egg files are read, or to extend the
00091 //               information stored with each egg structure, by
00092 //               deriving from EggData.
00093 ////////////////////////////////////////////////////////////////////
00094 PT(EggData) EggMultiBase::
00095 read_egg(const Filename &filename) {
00096   PT(EggData) data = new EggData;
00097 
00098   if (!data->read(filename)) {
00099     // Failure reading.
00100     return (EggData *)NULL;
00101   }
00102 
00103   DSearchPath file_path;
00104   file_path.append_directory(filename.get_dirname());
00105 
00106   // We always resolve filenames first based on the source egg
00107   // filename, since egg files almost always store relative paths.
00108   // This is a temporary kludge around integrating the path_replace
00109   // system with the EggData better.
00110   data->resolve_filenames(file_path);
00111 
00112   if (_force_complete) {
00113     if (!data->load_externals()) {
00114       return (EggData *)NULL;
00115     }
00116   }
00117 
00118   // Now resolve the filenames again according to the user's
00119   // specified _path_replace.
00120   EggBase::convert_paths(data, _path_replace, file_path);
00121 
00122   if (_got_coordinate_system) {
00123     data->set_coordinate_system(_coordinate_system);
00124   } else {
00125     _coordinate_system = data->get_coordinate_system();
00126     _got_coordinate_system = true;
00127   }
00128 
00129   return data;
00130 }

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