00001 // Filename: loaderFileTypePandatool.cxx 00002 // Created by: drose (26Apr01) 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 "loaderFileTypePandatool.h" 00020 00021 #include "somethingToEggConverter.h" 00022 #include "config_util.h" 00023 #include "load_egg_file.h" 00024 #include "eggData.h" 00025 00026 TypeHandle LoaderFileTypePandatool::_type_handle; 00027 00028 //////////////////////////////////////////////////////////////////// 00029 // Function: LoaderFileTypePandatool::Constructor 00030 // Access: Public 00031 // Description: 00032 //////////////////////////////////////////////////////////////////// 00033 LoaderFileTypePandatool:: 00034 LoaderFileTypePandatool(SomethingToEggConverter *converter) : 00035 _converter(converter) 00036 { 00037 converter->set_merge_externals(true); 00038 } 00039 00040 //////////////////////////////////////////////////////////////////// 00041 // Function: LoaderFileTypePandatool::Destructor 00042 // Access: Public, Virtual 00043 // Description: 00044 //////////////////////////////////////////////////////////////////// 00045 LoaderFileTypePandatool:: 00046 ~LoaderFileTypePandatool() { 00047 } 00048 00049 //////////////////////////////////////////////////////////////////// 00050 // Function: LoaderFileTypePandatool::get_name 00051 // Access: Public, Virtual 00052 // Description: 00053 //////////////////////////////////////////////////////////////////// 00054 string LoaderFileTypePandatool:: 00055 get_name() const { 00056 return _converter->get_name(); 00057 } 00058 00059 //////////////////////////////////////////////////////////////////// 00060 // Function: LoaderFileTypePandatool::get_extension 00061 // Access: Public, Virtual 00062 // Description: 00063 //////////////////////////////////////////////////////////////////// 00064 string LoaderFileTypePandatool:: 00065 get_extension() const { 00066 return _converter->get_extension(); 00067 } 00068 00069 //////////////////////////////////////////////////////////////////// 00070 // Function: LoaderFileTypePandatool::resolve_filename 00071 // Access: Public, Virtual 00072 // Description: Searches for the indicated filename on whatever paths 00073 // are appropriate to this file type, and updates it if 00074 // it is found. 00075 //////////////////////////////////////////////////////////////////// 00076 void LoaderFileTypePandatool:: 00077 resolve_filename(Filename &path) const { 00078 path.resolve_filename(get_model_path(), get_extension()); 00079 } 00080 00081 //////////////////////////////////////////////////////////////////// 00082 // Function: LoaderFileTypePandatool::load_file 00083 // Access: Public, Virtual 00084 // Description: 00085 //////////////////////////////////////////////////////////////////// 00086 PT(PandaNode) LoaderFileTypePandatool:: 00087 load_file(const Filename &path, bool) const { 00088 PT(PandaNode) result; 00089 00090 EggData egg_data; 00091 _converter->set_egg_data(&egg_data, false); 00092 00093 DSearchPath file_path; 00094 file_path.append_directory(path.get_dirname()); 00095 _converter->get_path_replace()->_path = file_path; 00096 00097 if (_converter->convert_file(path)) { 00098 egg_data.set_coordinate_system(CS_default); 00099 result = load_egg_data(egg_data); 00100 } 00101 _converter->clear_egg_data(); 00102 return result.p(); 00103 }