diff --git a/pandatool/src/mayaeggimport/mayaEggImport.cxx b/pandatool/src/mayaeggimport/mayaEggImport.cxx new file mode 100755 index 0000000000..f955b625f4 --- /dev/null +++ b/pandatool/src/mayaeggimport/mayaEggImport.cxx @@ -0,0 +1,132 @@ + +#include +#include + +#include "dtoolbase.h" + +#include "pre_maya_include.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include "post_maya_include.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; + bool haveWriteMethod () const; + MString defaultExtension () const; + 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) +{ + fprintf(stderr, "MayaEggImporter::reader called in error\n"); + return MS::kFailure; +} + +MStatus MayaEggImporter::writer ( const MFileObject& file, + const MString& options, + FileAccessMode mode ) + +{ + fprintf(stderr, "MayaEggImporter::writer called in error\n"); + return MS::kFailure; +} + +bool MayaEggImporter::haveReadMethod () const +{ + return false; +} + +bool MayaEggImporter::haveWriteMethod () const +{ + return false; +} + +MString MayaEggImporter::defaultExtension () const +{ + return "egg"; +} + +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=1;"); +} + +EXPCL_MISC MStatus uninitializePlugin( MObject obj ) +{ + MFnPlugin plugin( obj ); + return plugin.deregisterFileTranslator( "Panda3D Egg Import" ); +} diff --git a/pandatool/src/mayaeggimport/mayaEggImport.mel b/pandatool/src/mayaeggimport/mayaEggImport.mel new file mode 100755 index 0000000000..e67ea384de --- /dev/null +++ b/pandatool/src/mayaeggimport/mayaEggImport.mel @@ -0,0 +1,110 @@ + +global proc int eggImportOptions ( string $parent, + string $action, + string $initialSettings, + string $resultCallback ) +// +// Description: +// This script posts the OBJ file translator options. +// The optionsString is of the form: +// varName1=value1;varName2=value2;... +// +// Parameters: +// $parent - the elf parent layout for this options layout. It is +// always a scrollLayout. +// $action - the action that is to be performed with this invokation +// of this proc. Valid options are: +// "query" - construct the options string and pass it +// to the resultCallback. +// "post" - post all the elf controls. +// $initialSettings - the current options string in effect at the +// time this script is invoked. +// $resultCallback - +// This is the proc to be called with the result string. +// resultCallback ( string $optionsString ) +// +// Returns: +// 1 if successfull. +// 0 otherwise. +// +{ + int $bResult; + string $currentOptions; + string $optionList[]; + string $optionBreakDown[]; + int $index; + + if ($action == "post") { + setParent $parent; + + columnLayout -adj true objTypeCol; + radioButtonGrp + -l "Merge with Current Scene" + -nrb 2 -cw3 175 75 75 + -la2 "On" "Off" objMerge; + radioButtonGrp + -l "Import Model" + -nrb 2 -cw3 175 75 75 + -la2 "On" "Off" objModel; + radioButtonGrp + -l "Import Animation" + -nrb 2 -cw3 175 75 75 + -la2 "On" "Off" objAnim; + + $currentOptions = $initialSettings; + if (size($currentOptions) > 0) { + tokenize($currentOptions, ";", $optionList); + for ($index = 0; $index < size($optionList); $index++) { + tokenize($optionList[$index], "=", $optionBreakDown); + + if ($optionBreakDown[0] == "merge") { + if ($optionBreakDown[1] == "0") { + radioButtonGrp -e -sl 2 objMerge; + } else { + radioButtonGrp -e -sl 1 objMerge; + } + } else if ($optionBreakDown[0] == "model") { + if ($optionBreakDown[1] == "0") { + radioButtonGrp -e -sl 2 objModel; + } else { + radioButtonGrp -e -sl 1 objModel; + } + } else if ($optionBreakDown[0] == "anim") { + if ($optionBreakDown[1] == "0") { + radioButtonGrp -e -sl 2 objAnim; + } else { + radioButtonGrp -e -sl 1 objAnim; + } + } + } + } + $result = 1; + + } else if ($action == "query") { + + if (`radioButtonGrp -q -sl objMerge` == 1) { + $currentOptions = $currentOptions + "merge=1"; + } else { + $currentOptions = $currentOptions + "merge=0"; + } + + if (`radioButtonGrp -q -sl objModel` == 1) { + $currentOptions = $currentOptions + ";model=1"; + } else { + $currentOptions = $currentOptions + ";model=0"; + } + + if (`radioButtonGrp -q -sl objAnim` == 1) { + $currentOptions = $currentOptions + ";anim=1"; + } else { + $currentOptions = $currentOptions + ";anim=0"; + } + + eval($resultCallback+" \""+$currentOptions+"\""); + $result = 1; + } else { + $bResult = 0; + } + + return $bResult; +}