awaytools / awd-sdk

10 stars 8 forks source link

Instantiate AWDGeomUtil crashes Maya 2014 #5

Closed velenoise closed 10 years ago

velenoise commented 10 years ago

I'm trying to put together a basic Maya AWD exporter, based on the available 3dMax exporter, but when I instantiate an AWDGeomUtil the software crashes immediately. To test the issue, I set a blank exporter (code attached), with a single instantiation on the writer function, and it still crashes.

#include <maya/MStatus.h>
#include <maya/MFnPlugin.h>
#include <maya/MString.h>
#include <maya/MStringArray.h>
#include <maya/MPxFileTranslator.h>
#include <maya/MGlobal.h>
#include <maya/MPlug.h>

#include <string.h>
#include <vector>

#include "awd.h"
#include "geomutil.h"

using namespace std;

class BlankPlugin : public MPxFileTranslator {
public:

    BlankPlugin () {};

    virtual            ~BlankPlugin () {};

    bool haveReadMethod() const { return false; }

    bool haveWriteMethod() const { return true; }

    bool haveReferenceMethod() const { return false; }

    bool haveNamespaceSupport()    const { return true; }

    static void* creator();

    MString defaultExtension () const;

    bool canBeOpened() const { return false; }

    MStatus writer ( const MFileObject& file,
                                        const MString& optionsString,
                             MPxFileTranslator::FileAccessMode mode);

private:

};

void* BlankPlugin::creator()
{
    return new BlankPlugin();
}

MStatus BlankPlugin::writer ( const MFileObject& file,
                                const MString& options,
                                MPxFileTranslator::FileAccessMode mode)
{
    AWDGeomUtil util;  // if this line gets removed it doesn't crash
    return MS::kSuccess;
}

MString BlankPlugin::defaultExtension () const
{
    return "awd";
}

MStatus initializePlugin( MObject obj )
{
    MStatus   status;
    MFnPlugin plugin( obj, PLUGIN_COMPANY, "3.0", "Any");

    status =  plugin.registerFileTranslator( "Tester",
                                        "",
                                        BlankPlugin::creator,
                                        "",
                                        "",
                                        true );
    if (!status) 
    {
        status.perror("registerFileTranslator");
        return status;
    }

    return status;
}

MStatus uninitializePlugin( MObject obj )
{
    MStatus   status;
    MFnPlugin plugin( obj );

    status =  plugin.deregisterFileTranslator( "Tester" );
    if (!status)
    {
        status.perror("deregisterFileTranslator");
        return status;
    }

    return status;
}

Using Maya 2014 on Mac OSX 10.7.5

velenoise commented 10 years ago

I managed to work around it. The problem was the variable num_idx_lists wasn't being initialized, so it exploded on the destructor. I'll be running a couple more tests, and later send a pull request on it.

80prozent commented 10 years ago

The GeomUtil has gotten a major refactor.

It now allows for export of multiple materials / subMeshes per mesh.

Have a look at the 3dsmax exporter to see how it should be used.