mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
Initial stub version
This commit is contained in:
parent
ded6cbdc4e
commit
c20b1d95b9
132
pandatool/src/mayaeggimport/mayaEggImport.cxx
Executable file
132
pandatool/src/mayaeggimport/mayaEggImport.cxx
Executable file
@ -0,0 +1,132 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include "dtoolbase.h"
|
||||
|
||||
#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/MSelectionList.h>
|
||||
#include <maya/MItSelectionList.h>
|
||||
#include <maya/MPoint.h>
|
||||
#include <maya/MPointArray.h>
|
||||
#include <maya/MDagPath.h>
|
||||
#include <maya/MDagPathArray.h>
|
||||
#include <maya/MFnPlugin.h>
|
||||
#include <maya/MFnMesh.h>
|
||||
#include <maya/MFnSet.h>
|
||||
#include <maya/MItMeshPolygon.h>
|
||||
#include <maya/MItMeshVertex.h>
|
||||
#include <maya/MItMeshEdge.h>
|
||||
#include <maya/MFloatVector.h>
|
||||
#include <maya/MFloatVectorArray.h>
|
||||
#include <maya/MFloatArray.h>
|
||||
#include <maya/MObjectArray.h>
|
||||
#include <maya/MObject.h>
|
||||
#include <maya/MPlug.h>
|
||||
#include <maya/MPxFileTranslator.h>
|
||||
#include <maya/MFnDagNode.h>
|
||||
#include <maya/MItDag.h>
|
||||
#include <maya/MDistance.h>
|
||||
#include <maya/MIntArray.h>
|
||||
#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" );
|
||||
}
|
110
pandatool/src/mayaeggimport/mayaEggImport.mel
Executable file
110
pandatool/src/mayaeggimport/mayaEggImport.mel
Executable file
@ -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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user