15 #define __OPENTRANSPORTPROVIDERS__    35 #include <maya/MString.h>    36 #include <maya/MFnPlugin.h>    37 #include <maya/MFileIO.h>    38 #include <maya/MArgParser.h>    39 #include <maya/MArgList.h>    40 #include <maya/MSyntax.h>    41 #include <maya/MProgressWindow.h>    49 #define SEPARATE_PVIEW 1    63 doIt(
const MArgList &args) {
    68   syntax.addFlag(
"a", 
"animate");
    70   MArgParser parser(syntax, args, &result);
    72     result.perror(
"arguments");
    76   bool animate = parser.isFlagSet(
"a", &result);
    78     result.perror(
"isFlagSet");
    82   if (!MProgressWindow::reserve()) {
    83     nout << 
"Couldn't reserve progress window.\n";
    86   MProgressWindow::setTitle(
"Sending to pview");
    87   MProgressWindow::setInterruptable(
false);
    88   MProgressWindow::setProgressRange(0, 3);
    89   MProgressWindow::setProgressStatus(
"Converting scene");
    90   MProgressWindow::startProgress();
   100   textures_header_only = 
true;
   103   if (!convert(root, animate)) {
   104     nout << 
"failure in conversion.\n";
   105     MProgressWindow::endProgress();
   109   MProgressWindow::setProgressStatus(
"Writing bam file");
   110   MProgressWindow::advanceProgress(1);
   113     nout << 
"Couldn't write to " << bam_filename << 
".\n";
   114     MProgressWindow::endProgress();
   118   MProgressWindow::setProgressStatus(
"Spawning pview");
   119   MProgressWindow::advanceProgress(1);
   122   std::string pview_args = 
"-clD";
   124     pview_args = 
"-clDa";
   128   std::string quoted = std::string(
"\"") + bam_filename.
get_fullpath() + std::string(
"\"");
   129   nout << 
"pview " << pview_args << 
" " << quoted << 
"\n";
   130   int retval = _spawnlp(_P_DETACH, 
"pview",
   131                         "pview", pview_args.c_str(), quoted.c_str(), 
nullptr);
   134     MProgressWindow::endProgress();
   138   nout << 
"pview running.\n";
   139   MProgressWindow::endProgress();
   141 #else  // SEPARATE_PVIEW   149   char **argv = 
nullptr;
   157   if (window == 
nullptr) {
   159     nout << 
"Couldn't open a window!\n";
   160     MProgressWindow::endProgress();
   167   NodePath aspect_2d = window->get_aspect_2d();
   171   loading->set_text_color(1.0f, 1.0f, 1.0f, 1.0f);
   172   loading->set_shadow_color(0.0f, 0.0f, 0.0f, 1.0f);
   173   loading->set_shadow(0.04, 0.04);
   174   loading->set_align(TextNode::A_center);
   175   loading->set_text(
"Loading...");
   179   framework.
do_frame(Thread::get_current_thread());
   180   framework.
do_frame(Thread::get_current_thread());
   182   window->enable_keyboard();
   183   window->setup_trackball();
   186   if (!convert(framework.
get_models(), animate)) {
   187     nout << 
"failure in conversion.\n";
   188     MProgressWindow::endProgress();
   192   nout << 
"successfully converted.\n";
   195   window->center_trackball(framework.
get_models());
   196   window->loop_animations();
   199     window->set_anim_controls(
true);
   202   MProgressWindow::endProgress();
   204 #endif  // SEPARATE_PVIEW   222 convert(
const NodePath &parent, 
bool animate) {
   228   converter._polygon_output = 
true;
   229   converter._polygon_tolerance = 0.01;
   233     converter.set_animation_convert(AC_both);
   237     compress_channels = 
false;
   240   PathReplace *path_replace = converter.get_path_replace();
   245   std::string source_dir = source_file.
get_dirname();
   246   if (!source_dir.empty()) {
   254   converter.set_egg_data(egg_data);
   255   converter.set_from_selection(
true);
   256   converter.set_neutral_frame(-1);
   258   if (!converter.convert_maya()) {
   259     nout << 
"Errors in conversion.\n";
   263   MProgressWindow::setProgressStatus(
"Converting to bam");
   264   MProgressWindow::advanceProgress(1);
   270   if (input_units != DU_invalid && ptloader_units != DU_invalid &&
   271       input_units != ptloader_units) {
   278     egg_data->transform(LMatrix4d::scale_mat(scale));
   281   egg_data->set_coordinate_system(CS_default);
   282   PT(
PandaNode) result = load_egg_data(egg_data);
   284   if (result == 
nullptr) {
   285     nout << 
"Unable to load converted egg data.\n";
   312   MFnPlugin plugin(obj, 
"VR Studio", 
"1.0");
   316     status.perror(
"registerCommand");
   327   MFnPlugin plugin(obj);
   329   status = plugin.deregisterCommand(
"pview");
   332     status.perror(
"deregisterCommand");
 std::string get_dirname() const
Returns the directory part of the filename.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void set_extension(const std::string &s)
Replaces the file extension.
A basic node of the scene graph or data graph.
EXPCL_MISC MStatus uninitializePlugin(MObject obj)
Called by Maya when the plugin is unloaded.
string format_long_unit(DistanceUnit unit)
Returns the string representing the full name (plural) for the given unit.
void enable_default_keys()
Sets callbacks on the event handler to handle all of the normal viewer keys, like t to toggle texture...
NodePath & get_models()
Returns the root of the scene graph normally reserved for parenting models and such.
void set_scale(PN_stdfloat scale)
Sets the scale component of the transform, leaving translation and rotation untouched.
double convert_units(DistanceUnit from, DistanceUnit to)
Returns the scaling factor that must be applied to convert from units of "from" to "to".
This encapsulates the data that is normally associated with a single window, or with a single display...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void open_framework()
Should be called once at the beginning of the application to initialize Panda (and the framework) for...
NodePath instance_to(const NodePath &other, int sort=0, Thread *current_thread=Thread::get_current_thread()) const
Adds the referenced node of the NodePath as a child of the referenced node of the indicated other Nod...
void append_directory(const Filename &directory)
Adds a new directory to the end of the search list.
This is the primary interface into all the egg data, and the root of the egg file structure.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
DistanceUnit
This enumerated type lists all the kinds of units we're likely to come across in model conversion pro...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
This class serves as a plug-in to Maya to allow viewing the current Maya selection as it will be conv...
The name of a file, such as a texture file or an Egg file.
NodePath attach_new_node(PandaNode *node, int sort=0, Thread *current_thread=Thread::get_current_thread()) const
Attaches a new node, with or without existing parents, to the scene graph below the referenced node o...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
std::string get_fullpath() const
Returns the entire filename: directory, basename, extension.
void main_loop()
Called to yield control to the panda framework.
bool write_bam_file(const Filename &filename) const
Writes the contents of this node and below out to a bam file with the indicated filename.
This class specializes ConfigVariable as an enumerated type.
bool unlink() const
Permanently deletes the file associated with the filename, if possible.
WindowFramework * open_window()
Opens a window on the default graphics pipe.
This class supervises the construction of an EggData structure from a single Maya file,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
static void * creator()
This is used to create a new instance of the plugin.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
void remove_node(Thread *current_thread=Thread::get_current_thread())
Disconnects the referenced node from the scene graph.
This encapsulates the user's command-line request to replace existing, incorrect pathnames to models ...
void set_window_title(const std::string &title)
Specifies the title that is set for all subsequently created windows.
The primary interface to this module.
static Filename temporary(const std::string &dirname, const std::string &prefix, const std::string &suffix=std::string(), Type type=T_general)
Generates a temporary filename within the indicated directory, using the indicated prefix.
void append_path(const std::string &path, const std::string &separator=std::string())
Adds all of the directories listed in the search path to the end of the search list.
This class serves to provide a high-level framework for basic applications that use Panda in simple w...
virtual MStatus doIt(const MArgList &args)
Called when the plugin command is invoked.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
NodePath is the fundamental system for disambiguating instances, and also provides a higher-level int...
static Filename from_os_specific(const std::string &os_specific, Type type=T_general)
This named constructor returns a Panda-style filename (that is, using forward slashes,...
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
EXPCL_MISC MStatus initializePlugin(MObject obj)
Called by Maya when the plugin is loaded.
virtual bool do_frame(Thread *current_thread)
Renders one frame and performs all associated processing.