Panda3D
 All Classes Functions Variables Enumerations
config_ptloader.cxx
1 // Filename: config_ptloader.cxx
2 // Created by: drose (26Apr01)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "config_ptloader.h"
16 
17 // This needs to be included first to work around a bug in OSX 10.4.
18 #if defined(HAVE_FCOLLADA) && defined(IS_OSX)
19 #include "daeToEggConverter.h"
20 #endif
21 
22 #include "loaderFileTypePandatool.h"
23 
24 #include "config_flt.h"
25 #include "fltToEggConverter.h"
26 #include "config_lwo.h"
27 #include "lwoToEggConverter.h"
28 #include "dxfToEggConverter.h"
29 #include "vrmlToEggConverter.h"
30 #include "objToEggConverter.h"
31 #include "eggToObjConverter.h"
32 #include "config_xfile.h"
33 #include "xFileToEggConverter.h"
34 
35 // Windows freaks out if this input is placed earlier.
36 #if defined(HAVE_FCOLLADA) && !defined(IS_OSX)
37 #include "daeToEggConverter.h"
38 #endif
39 
40 #include "dconfig.h"
41 #include "loaderFileTypeRegistry.h"
42 #include "eggData.h"
43 
44 ConfigureDef(config_ptloader);
45 NotifyCategoryDef(ptloader, "");
46 
47 ConfigureFn(config_ptloader) {
48  init_libptloader();
49 }
50 
52 ("ptloader-units", DU_invalid,
53  PRC_DESC("Specifies the preferred units into which models will be converted "
54  "when using libptloader to automatically convert files to Panda "
55  "at load time, via e.g. \"pview myMayaFile.mb\"."));
56 
57 ConfigVariableBool ptloader_load_node
58 ("ptloader-load-node", true,
59  PRC_DESC("Specify true to allow libptloader to invoke the more efficient "
60  "but possibly-experimental code to load model files directly into "
61  "PandaNode when possible. Specify false to force the loading to "
62  "always go through the egg library, which is more likely to be "
63  "reliable."));
64 
65 ////////////////////////////////////////////////////////////////////
66 // Function: init_libptloader
67 // Description: Initializes the library. This must be called at
68 // least once before any of the functions or classes in
69 // this library can be used. Normally it will be
70 // called by the static initializers and need not be
71 // called explicitly, but special cases exist.
72 ////////////////////////////////////////////////////////////////////
73 void
74 init_libptloader() {
75  static bool initialized = false;
76  if (initialized) {
77  return;
78  }
79  initialized = true;
80 
81  LoaderFileTypePandatool::init_type();
82 
84 
85  init_liblwo();
88 
89  init_libflt();
92 
95 
97  reg->register_type(new LoaderFileTypePandatool(vrml));
98 
99  init_libxfile();
101  reg->register_type(new LoaderFileTypePandatool(xfile));
102 
103  ObjToEggConverter *obj_egg = new ObjToEggConverter;
104  EggToObjConverter *egg_obj = new EggToObjConverter;
105  reg->register_type(new LoaderFileTypePandatool(obj_egg, egg_obj));
106 
107 //#ifdef HAVE_FCOLLADA
108 // DAEToEggConverter *dae = new DAEToEggConverter;
109 // reg->register_type(new LoaderFileTypePandatool(dae));
110 //#endif
111 
112 #ifdef HAVE_MAYA
113  // Register the Maya converter as a deferred type. We don't compile
114  // it in directly, because it's big and bulky; we don't need to
115  // force people to load up libmayaloader (and, along with it, all of
116  // the Maya API libraries) until they actually try to load a Maya
117  // file.
118  reg->register_deferred_type("mb", "mayaloader");
119  reg->register_deferred_type("ma", "mayaloader");
120 #endif
121 }
This is a convenience class to specialize ConfigVariable as a boolean type.
static LoaderFileTypeRegistry * get_global_ptr()
Returns a pointer to the global LoaderFileTypeRegistry object.
This class supervises the construction of an EggData structure from the data represented by the FltHe...
void register_type(LoaderFileType *type)
Defines a new LoaderFileType in the universe.
void register_deferred_type(const string &extension, const string &library)
Records a type associated with a particular extension to be loaded in the future. ...
Convert an Obj file to egg data.
This class supervises the construction of an EggData structure from a VRML file.
This class specializes ConfigVariable as an enumerated type.
This class maintains the set of all known LoaderFileTypes in the universe.
This class supervises the construction of an EggData structure from the data represented by the LwoHe...
This defines the Loader interface to files whose converters are defined within the Pandatool package ...
Convert an obj file to egg data.
This class supervises the construction of an EggData structure from a DXF file.