Panda3D
|
00001 // Filename: config_ptloader.cxx 00002 // Created by: drose (26Apr01) 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 "config_ptloader.h" 00016 00017 // This needs to be included first to work around a bug in OSX 10.4. 00018 #if defined(HAVE_FCOLLADA) && defined(IS_OSX) 00019 #include "daeToEggConverter.h" 00020 #endif 00021 00022 #include "loaderFileTypePandatool.h" 00023 00024 #include "config_flt.h" 00025 #include "fltToEggConverter.h" 00026 #include "config_lwo.h" 00027 #include "lwoToEggConverter.h" 00028 #include "dxfToEggConverter.h" 00029 #include "vrmlToEggConverter.h" 00030 #include "config_xfile.h" 00031 #include "xFileToEggConverter.h" 00032 00033 // Windows freaks out if this input is placed earlier. 00034 #if defined(HAVE_FCOLLADA) && !defined(IS_OSX) 00035 #include "daeToEggConverter.h" 00036 #endif 00037 00038 #include "dconfig.h" 00039 #include "loaderFileTypeRegistry.h" 00040 #include "eggData.h" 00041 00042 ConfigureDef(config_ptloader); 00043 NotifyCategoryDef(ptloader, ""); 00044 00045 ConfigureFn(config_ptloader) { 00046 init_libptloader(); 00047 } 00048 00049 ConfigVariableEnum<DistanceUnit> ptloader_units 00050 ("ptloader-units", DU_invalid, 00051 PRC_DESC("Specifies the preferred units into which models will be converted " 00052 "when using libptloader to automatically convert files to Panda " 00053 "at load time, via e.g. \"pview myMayaFile.mb\".")); 00054 00055 //////////////////////////////////////////////////////////////////// 00056 // Function: init_libptloader 00057 // Description: Initializes the library. This must be called at 00058 // least once before any of the functions or classes in 00059 // this library can be used. Normally it will be 00060 // called by the static initializers and need not be 00061 // called explicitly, but special cases exist. 00062 //////////////////////////////////////////////////////////////////// 00063 void 00064 init_libptloader() { 00065 static bool initialized = false; 00066 if (initialized) { 00067 return; 00068 } 00069 initialized = true; 00070 00071 LoaderFileTypePandatool::init_type(); 00072 00073 LoaderFileTypeRegistry *reg = LoaderFileTypeRegistry::get_global_ptr(); 00074 00075 init_liblwo(); 00076 FltToEggConverter *flt = new FltToEggConverter; 00077 reg->register_type(new LoaderFileTypePandatool(flt)); 00078 00079 init_libflt(); 00080 LwoToEggConverter *lwo = new LwoToEggConverter; 00081 reg->register_type(new LoaderFileTypePandatool(lwo)); 00082 00083 DXFToEggConverter *dxf = new DXFToEggConverter; 00084 reg->register_type(new LoaderFileTypePandatool(dxf)); 00085 00086 VRMLToEggConverter *vrml = new VRMLToEggConverter; 00087 reg->register_type(new LoaderFileTypePandatool(vrml)); 00088 00089 init_libxfile(); 00090 XFileToEggConverter *xfile = new XFileToEggConverter; 00091 reg->register_type(new LoaderFileTypePandatool(xfile)); 00092 00093 #ifdef HAVE_FCOLLADA 00094 DAEToEggConverter *dae = new DAEToEggConverter; 00095 reg->register_type(new LoaderFileTypePandatool(dae)); 00096 #endif 00097 00098 #ifdef HAVE_MAYA 00099 // Register the Maya converter as a deferred type. We don't compile 00100 // it in directly, because it's big and bulky; we don't need to 00101 // force people to load up libmayaloader (and, along with it, all of 00102 // the Maya API libraries) until they actually try to load a Maya 00103 // file. 00104 reg->register_deferred_type("mb", "mayaloader"); 00105 reg->register_deferred_type("ma", "mayaloader"); 00106 #endif 00107 }