Browse Source

*** empty log message ***

Dave Schuyler 20 years ago
parent
commit
0fc3e0fdcc

+ 6 - 6
pandatool/src/mayaegg/mayaegg_composite1.cxx

@@ -1,6 +1,6 @@
-#include "config_mayaegg.cxx"
-#include "mayaEggGroupUserData.cxx"
-#include "mayaBlendDesc.cxx"
-#include "mayaNodeDesc.cxx"
-#include "mayaNodeTree.cxx"
-#include "mayaToEggConverter.cxx"
+#include "config_mayaegg.cxx"
+#include "mayaEggGroupUserData.cxx"
+#include "mayaBlendDesc.cxx"
+#include "mayaNodeDesc.cxx"
+#include "mayaNodeTree.cxx"
+#include "mayaToEggConverter.cxx"

+ 118 - 118
pandatool/src/mayaprogs/eggToMaya.cxx

@@ -1,118 +1,118 @@
-// Filename: eggToMaya.cxx
-// Created by:  drose (11Aug05)
-//
-////////////////////////////////////////////////////////////////////
-//
-// PANDA 3D SOFTWARE
-// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
-//
-// All use of this software is subject to the terms of the Panda 3d
-// Software license.  You should have received a copy of this license
-// along with this source code; you will also find a current copy of
-// the license at http://etc.cmu.edu/panda3d/docs/license/ .
-//
-// To contact the maintainers of this program write to
-// [email protected] .
-//
-////////////////////////////////////////////////////////////////////
-
-#include "eggToMaya.h"
-#include "mayaEggLoader.h"
-#include "mayaApi.h"
-
-// We must define this to prevent Maya from doubly-declaring its
-// MApiVersion string in this file as well as in libmayaegg.
-#define _MApiVersion
-
-#include "pre_maya_include.h"
-#include <maya/MString.h>
-#include <maya/MFileIO.h>
-#include "post_maya_include.h"
-
-////////////////////////////////////////////////////////////////////
-//     Function: EggToMaya::Constructor
-//       Access: Public
-//  Description: 
-////////////////////////////////////////////////////////////////////
-EggToMaya::
-EggToMaya() :
-  EggToSomething("Maya", ".mb", true, false)
-{
-  add_units_options();
-
-  set_binary_output(true);
-  set_program_description
-    ("egg2maya converts files from egg format to Maya .mb or .ma "
-     "format.  At the moment, it contains support for basic geometry "
-     "(polygons with textures).");
-
-  add_option
-    ("a", "", 0,
-     "Convert animation tables.",
-     &EggToMaya::dispatch_none, &_convert_anim);
-
-  add_option
-    ("m", "", 0,
-     "Convert polygon models.  You may specify both -a and -m at the same "
-     "time.  If you specify neither, the default is -m.",
-     &EggToMaya::dispatch_none, &_convert_model);
-
-  // Maya files always store centimeters.
-  _output_units = DU_centimeters;
-}
-
-////////////////////////////////////////////////////////////////////
-//     Function: EggToMaya::run
-//       Access: Public
-//  Description:
-////////////////////////////////////////////////////////////////////
-void EggToMaya::
-run() {
-  if (!_convert_anim && !_convert_model) {
-    _convert_model = true;
-  }
-
-  // Let's convert the output file to a full path before we initialize
-  // Maya, since Maya now has a nasty habit of changing the current
-  // directory.
-  _output_filename.make_absolute();
-
-  nout << "Initializing Maya.\n";
-  PT(MayaApi) maya = MayaApi::open_api(_program_name);
-  if (!maya->is_valid()) {
-    nout << "Unable to initialize Maya.\n";
-    exit(1);
-  }
-
-  MStatus status;
-  status = MFileIO::newFile(true);
-  if (!status) {
-    status.perror("Could not initialize file");
-    exit(1);
-  }
-
-  // Now convert the data.
-  if (!MayaLoadEggData(_data, true, _convert_model, _convert_anim)) {
-    nout << "Unable to convert egg file.\n";
-    exit(1);
-  }
-
-  // And write out the resulting Maya file.
-  string os_specific = _output_filename.to_os_generic();
-  const char *file_type = NULL;
-  if (_output_filename.get_extension() == "mb") {
-    file_type = "mayaBinary";
-  }
-  status = MFileIO::saveAs(os_specific.c_str(), file_type);
-  if (!status) {
-    status.perror("Could not save file");
-    exit(1);
-  }
-}
-
-int main(int argc, char *argv[]) {
-  EggToMaya prog;
-  prog.parse_command_line(argc, argv);
-  prog.run();
-  return 0;
-}
+// Filename: eggToMaya.cxx
+// Created by:  drose (11Aug05)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#include "eggToMaya.h"
+#include "mayaEggLoader.h"
+#include "mayaApi.h"
+
+// We must define this to prevent Maya from doubly-declaring its
+// MApiVersion string in this file as well as in libmayaegg.
+#define _MApiVersion
+
+#include "pre_maya_include.h"
+#include <maya/MString.h>
+#include <maya/MFileIO.h>
+#include "post_maya_include.h"
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggToMaya::Constructor
+//       Access: Public
+//  Description: 
+////////////////////////////////////////////////////////////////////
+EggToMaya::
+EggToMaya() :
+  EggToSomething("Maya", ".mb", true, false)
+{
+  add_units_options();
+
+  set_binary_output(true);
+  set_program_description
+    ("egg2maya converts files from egg format to Maya .mb or .ma "
+     "format.  At the moment, it contains support for basic geometry "
+     "(polygons with textures).");
+
+  add_option
+    ("a", "", 0,
+     "Convert animation tables.",
+     &EggToMaya::dispatch_none, &_convert_anim);
+
+  add_option
+    ("m", "", 0,
+     "Convert polygon models.  You may specify both -a and -m at the same "
+     "time.  If you specify neither, the default is -m.",
+     &EggToMaya::dispatch_none, &_convert_model);
+
+  // Maya files always store centimeters.
+  _output_units = DU_centimeters;
+}
+
+////////////////////////////////////////////////////////////////////
+//     Function: EggToMaya::run
+//       Access: Public
+//  Description:
+////////////////////////////////////////////////////////////////////
+void EggToMaya::
+run() {
+  if (!_convert_anim && !_convert_model) {
+    _convert_model = true;
+  }
+
+  // Let's convert the output file to a full path before we initialize
+  // Maya, since Maya now has a nasty habit of changing the current
+  // directory.
+  _output_filename.make_absolute();
+
+  nout << "Initializing Maya.\n";
+  PT(MayaApi) maya = MayaApi::open_api(_program_name);
+  if (!maya->is_valid()) {
+    nout << "Unable to initialize Maya.\n";
+    exit(1);
+  }
+
+  MStatus status;
+  status = MFileIO::newFile(true);
+  if (!status) {
+    status.perror("Could not initialize file");
+    exit(1);
+  }
+
+  // Now convert the data.
+  if (!MayaLoadEggData(_data, true, _convert_model, _convert_anim)) {
+    nout << "Unable to convert egg file.\n";
+    exit(1);
+  }
+
+  // And write out the resulting Maya file.
+  string os_specific = _output_filename.to_os_generic();
+  const char *file_type = NULL;
+  if (_output_filename.get_extension() == "mb") {
+    file_type = "mayaBinary";
+  }
+  status = MFileIO::saveAs(os_specific.c_str(), file_type);
+  if (!status) {
+    status.perror("Could not save file");
+    exit(1);
+  }
+}
+
+int main(int argc, char *argv[]) {
+  EggToMaya prog;
+  prog.parse_command_line(argc, argv);
+  prog.run();
+  return 0;
+}

+ 42 - 42
pandatool/src/mayaprogs/eggToMaya.h

@@ -1,42 +1,42 @@
-// Filename: eggToMaya.h
-// Created by:  drose (11Aug05)
-//
-////////////////////////////////////////////////////////////////////
-//
-// PANDA 3D SOFTWARE
-// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
-//
-// All use of this software is subject to the terms of the Panda 3d
-// Software license.  You should have received a copy of this license
-// along with this source code; you will also find a current copy of
-// the license at http://etc.cmu.edu/panda3d/docs/license/ .
-//
-// To contact the maintainers of this program write to
-// [email protected] .
-//
-////////////////////////////////////////////////////////////////////
-
-#ifndef EGGTOMAYA_H
-#define EGGTOMAYA_H
-
-#include "pandatoolbase.h"
-
-#include "eggToSomething.h"
-
-////////////////////////////////////////////////////////////////////
-//       Class : EggToMaya
-// Description : A program to read an egg file and write a maya file.
-////////////////////////////////////////////////////////////////////
-class EggToMaya : public EggToSomething {
-public:
-  EggToMaya();
-
-  void run();
-
-private:
-  bool _convert_anim;
-  bool _convert_model;
-};
-
-#endif
-
+// Filename: eggToMaya.h
+// Created by:  drose (11Aug05)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+
+#ifndef EGGTOMAYA_H
+#define EGGTOMAYA_H
+
+#include "pandatoolbase.h"
+
+#include "eggToSomething.h"
+
+////////////////////////////////////////////////////////////////////
+//       Class : EggToMaya
+// Description : A program to read an egg file and write a maya file.
+////////////////////////////////////////////////////////////////////
+class EggToMaya : public EggToSomething {
+public:
+  EggToMaya();
+
+  void run();
+
+private:
+  bool _convert_anim;
+  bool _convert_model;
+};
+
+#endif
+

+ 175 - 175
pandatool/src/mayaprogs/mayaEggImport.cxx

@@ -1,175 +1,175 @@
-// Filename: mayaEggImport.cxx
-// Created by:  jyelon (20Jul05)
-//
-////////////////////////////////////////////////////////////////////
-//
-// PANDA 3D SOFTWARE
-// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
-//
-// All use of this software is subject to the terms of the Panda 3d
-// Software license.  You should have received a copy of this license
-// along with this source code; you will also find a current copy of
-// the license at http://etc.cmu.edu/panda3d/docs/license/ .
-//
-// To contact the maintainers of this program write to
-// [email protected] .
-//
-////////////////////////////////////////////////////////////////////
-//
-// This is the wrapper code for the maya importer plugin.
-// It includes:
-//
-//   - user interface dialogs and popups
-//   - plugin initialization/registration
-//
-// It does not include the actual code to traverse the EggData.
-//
-////////////////////////////////////////////////////////////////////
-
-#include <string.h> 
-#include <sys/types.h>
-
-#include "dtoolbase.h"
-
-// We must define this to prevent Maya from doubly-declaring its
-// MApiVersion string in this file as well as in libmayaegg.
-#define _MApiVersion
-
-#include "pre_maya_include.h"
-#include <maya/MStatus.h>
-#include <maya/MPxCommand.h>
-#include <maya/MString.h>
-#include <maya/MStringArray.h>
-#include <maya/MArgList.h>
-#include <maya/MGlobal.h>
-#include <maya/MFnPlugin.h>
-#include <maya/MObject.h>
-#include <maya/MPlug.h>
-#include <maya/MPxFileTranslator.h>
-#include "post_maya_include.h"
-
-#include "mayaEggLoader.h"
-#include "notifyCategoryProxy.h"
-
-//////////////////////////////////////////////////////////////
-
-class MayaEggImporter : public MPxFileTranslator
-{
-public:
-  MayaEggImporter () {};
-  virtual         ~MayaEggImporter () {};
-  static void*    creator();
-  
-  MStatus         reader ( const MFileObject& file,
-                           const MString& optionsString,
-                           FileAccessMode mode);
-  
-  MStatus         writer ( const MFileObject& file,
-                           const MString& optionsString,
-                           FileAccessMode mode );
-  
-  bool            haveReadMethod () const { return true; }
-  bool            haveWriteMethod () const { return false; }
-  MString         defaultExtension () const { return "egg"; }
-  MFileKind       identifyFile ( const MFileObject& fileName,
-                                 const char* buffer,
-                                 short size) const;
-};
-
-
-void* MayaEggImporter::creator()
-{
-  return new MayaEggImporter();
-}
-
-MStatus MayaEggImporter::reader ( const MFileObject& file,
-                                const MString& options,
-                                FileAccessMode mode)
-{
-  MString fileName = file.fullName();
-  bool model=false;
-  bool anim=false;
-
-  if (options.length() > 0) {
-    const MString flagModel("model");
-    const MString flagAnim("anim");
-
-    //	Start parsing.
-    //
-    MStringArray optionList;
-    MStringArray theOption;
-    options.split(';', optionList);
-
-    unsigned nOptions = optionList.length();
-    for (unsigned i = 0; i < nOptions; i++) {
-
-      theOption.clear();
-      optionList[i].split('=', theOption);
-      if (theOption.length() < 1) {
-        continue;
-      }
-      
-      if (theOption[0] == flagModel && theOption.length() > 1) {
-        model = atoi(theOption[1].asChar()) ? true:false;
-      } else if (theOption[0] == flagAnim && theOption.length() > 1) {
-        anim = atoi(theOption[1].asChar()) ? true:false;
-      } 
-    }
-  }
-  
-  if ((mode != kImportAccessMode)&&(mode != kOpenAccessMode))
-    return MS::kFailure;
-
-  bool merge = (mode == kImportAccessMode);
-  std::ostringstream log;
-  Notify::ptr()->set_ostream_ptr(&log, false);
-  bool ok = MayaLoadEggFile(fileName.asChar(), merge, model, anim);
-  string txt = log.str();
-  if (txt != "") {
-    MGlobal::displayError(txt.c_str());
-  } else {
-    if (!ok) MGlobal::displayError("Cannot import Egg file, unknown reason");
-  }
-  return ok ? MS::kSuccess : MS::kFailure;
-}
-
-MStatus MayaEggImporter::writer ( const MFileObject& file,
-                                const MString& options,
-                                FileAccessMode mode )
-
-{
-  fprintf(stderr, "MayaEggImporter::writer called in error\n");
-  return MS::kFailure;
-}
-
-MPxFileTranslator::MFileKind MayaEggImporter::identifyFile (
-                                                          const MFileObject& fileName,
-                                                          const char* buffer,
-                                                          short size) const
-{
-  const char * name = fileName.name().asChar();
-  int   nameLength = strlen(name);
-  
-  if ((nameLength > 4) && !stricmp(name+nameLength-4, ".egg"))
-    return kCouldBeMyFileType;
-  else
-    return kNotMyFileType;
-}
-
-EXPCL_MISC MStatus initializePlugin( MObject obj )
-{
-  MFnPlugin plugin( obj, "Alias", "3.0", "Any");
-  
-  // Register the translator with the system
-  return plugin.registerFileTranslator( "Panda3D Egg Import", "none",
-                                        MayaEggImporter::creator,
-                                        
-                                        "eggImportOptions",
-                                        "merge=1;model=1;anim=0;");
-}
-
-EXPCL_MISC MStatus uninitializePlugin( MObject obj )
-{
-  MFnPlugin plugin( obj );
-  return plugin.deregisterFileTranslator( "Panda3D Egg Import" );
-}
+// Filename: mayaEggImport.cxx
+// Created by:  jyelon (20Jul05)
+//
+////////////////////////////////////////////////////////////////////
+//
+// PANDA 3D SOFTWARE
+// Copyright (c) 2001 - 2004, Disney Enterprises, Inc.  All rights reserved
+//
+// All use of this software is subject to the terms of the Panda 3d
+// Software license.  You should have received a copy of this license
+// along with this source code; you will also find a current copy of
+// the license at http://etc.cmu.edu/panda3d/docs/license/ .
+//
+// To contact the maintainers of this program write to
+// [email protected] .
+//
+////////////////////////////////////////////////////////////////////
+//
+// This is the wrapper code for the maya importer plugin.
+// It includes:
+//
+//   - user interface dialogs and popups
+//   - plugin initialization/registration
+//
+// It does not include the actual code to traverse the EggData.
+//
+////////////////////////////////////////////////////////////////////
+
+#include <string.h> 
+#include <sys/types.h>
+
+#include "dtoolbase.h"
+
+// We must define this to prevent Maya from doubly-declaring its
+// MApiVersion string in this file as well as in libmayaegg.
+#define _MApiVersion
+
+#include "pre_maya_include.h"
+#include <maya/MStatus.h>
+#include <maya/MPxCommand.h>
+#include <maya/MString.h>
+#include <maya/MStringArray.h>
+#include <maya/MArgList.h>
+#include <maya/MGlobal.h>
+#include <maya/MFnPlugin.h>
+#include <maya/MObject.h>
+#include <maya/MPlug.h>
+#include <maya/MPxFileTranslator.h>
+#include "post_maya_include.h"
+
+#include "mayaEggLoader.h"
+#include "notifyCategoryProxy.h"
+
+//////////////////////////////////////////////////////////////
+
+class MayaEggImporter : public MPxFileTranslator
+{
+public:
+  MayaEggImporter () {};
+  virtual         ~MayaEggImporter () {};
+  static void*    creator();
+  
+  MStatus         reader ( const MFileObject& file,
+                           const MString& optionsString,
+                           FileAccessMode mode);
+  
+  MStatus         writer ( const MFileObject& file,
+                           const MString& optionsString,
+                           FileAccessMode mode );
+  
+  bool            haveReadMethod () const { return true; }
+  bool            haveWriteMethod () const { return false; }
+  MString         defaultExtension () const { return "egg"; }
+  MFileKind       identifyFile ( const MFileObject& fileName,
+                                 const char* buffer,
+                                 short size) const;
+};
+
+
+void* MayaEggImporter::creator()
+{
+  return new MayaEggImporter();
+}
+
+MStatus MayaEggImporter::reader ( const MFileObject& file,
+                                const MString& options,
+                                FileAccessMode mode)
+{
+  MString fileName = file.fullName();
+  bool model=false;
+  bool anim=false;
+
+  if (options.length() > 0) {
+    const MString flagModel("model");
+    const MString flagAnim("anim");
+
+    //	Start parsing.
+    //
+    MStringArray optionList;
+    MStringArray theOption;
+    options.split(';', optionList);
+
+    unsigned nOptions = optionList.length();
+    for (unsigned i = 0; i < nOptions; i++) {
+
+      theOption.clear();
+      optionList[i].split('=', theOption);
+      if (theOption.length() < 1) {
+        continue;
+      }
+      
+      if (theOption[0] == flagModel && theOption.length() > 1) {
+        model = atoi(theOption[1].asChar()) ? true:false;
+      } else if (theOption[0] == flagAnim && theOption.length() > 1) {
+        anim = atoi(theOption[1].asChar()) ? true:false;
+      } 
+    }
+  }
+  
+  if ((mode != kImportAccessMode)&&(mode != kOpenAccessMode))
+    return MS::kFailure;
+
+  bool merge = (mode == kImportAccessMode);
+  std::ostringstream log;
+  Notify::ptr()->set_ostream_ptr(&log, false);
+  bool ok = MayaLoadEggFile(fileName.asChar(), merge, model, anim);
+  string txt = log.str();
+  if (txt != "") {
+    MGlobal::displayError(txt.c_str());
+  } else {
+    if (!ok) MGlobal::displayError("Cannot import Egg file, unknown reason");
+  }
+  return ok ? MS::kSuccess : MS::kFailure;
+}
+
+MStatus MayaEggImporter::writer ( const MFileObject& file,
+                                const MString& options,
+                                FileAccessMode mode )
+
+{
+  fprintf(stderr, "MayaEggImporter::writer called in error\n");
+  return MS::kFailure;
+}
+
+MPxFileTranslator::MFileKind MayaEggImporter::identifyFile (
+                                                          const MFileObject& fileName,
+                                                          const char* buffer,
+                                                          short size) const
+{
+  const char * name = fileName.name().asChar();
+  int   nameLength = strlen(name);
+  
+  if ((nameLength > 4) && !stricmp(name+nameLength-4, ".egg"))
+    return kCouldBeMyFileType;
+  else
+    return kNotMyFileType;
+}
+
+EXPCL_MISC MStatus initializePlugin( MObject obj )
+{
+  MFnPlugin plugin( obj, "Alias", "3.0", "Any");
+  
+  // Register the translator with the system
+  return plugin.registerFileTranslator( "Panda3D Egg Import", "none",
+                                        MayaEggImporter::creator,
+                                        
+                                        "eggImportOptions",
+                                        "merge=1;model=1;anim=0;");
+}
+
+EXPCL_MISC MStatus uninitializePlugin( MObject obj )
+{
+  MFnPlugin plugin( obj );
+  return plugin.deregisterFileTranslator( "Panda3D Egg Import" );
+}