Panda3D

config_ptloader.cxx

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