show ".bullet" as file extension in the Maya plugin, by implementing MString filter() const;
This commit is contained in:
@@ -1,153 +1,160 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library Maya Plugin
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising
|
||||
from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
01/27/2010 : Replaced COLLADA export with Bullet binary export
|
||||
*/
|
||||
|
||||
#include "bulletExport.h"
|
||||
#include "solver.h"
|
||||
#include "solver_impl.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#define strcasecmp stricmp
|
||||
#elif defined (OSMac_)
|
||||
extern "C" int strcasecmp (const char *, const char *);
|
||||
|
||||
#endif
|
||||
|
||||
#define NO_SMOOTHING_GROUP -1
|
||||
#define INITIALIZE_SMOOTHING -2
|
||||
#define INVALID_ID -1
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library Maya Plugin
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising
|
||||
from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
01/27/2010 : Replaced COLLADA export with Bullet binary export
|
||||
*/
|
||||
|
||||
#include "bulletExport.h"
|
||||
#include "solver.h"
|
||||
#include "solver_impl.h"
|
||||
|
||||
#if defined (_WIN32)
|
||||
#define strcasecmp stricmp
|
||||
#elif defined (OSMac_)
|
||||
extern "C" int strcasecmp (const char *, const char *);
|
||||
|
||||
#endif
|
||||
|
||||
#define NO_SMOOTHING_GROUP -1
|
||||
#define INITIALIZE_SMOOTHING -2
|
||||
#define INVALID_ID -1
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
MString ObjTranslator::fExtension = "bullet";
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
void* ObjTranslator::creator()
|
||||
{
|
||||
return new ObjTranslator();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
MStatus ObjTranslator::reader ( const MFileObject& file,
|
||||
const MString& options,
|
||||
FileAccessMode mode)
|
||||
{
|
||||
fprintf(stderr, "Bullet Physics import is not available yet\n");
|
||||
return MS::kFailure;
|
||||
}
|
||||
|
||||
|
||||
|
||||
MStatus ObjTranslator::writer ( const MFileObject& file,
|
||||
const MString& options,
|
||||
FileAccessMode mode )
|
||||
|
||||
{
|
||||
MStatus status;
|
||||
|
||||
MString mname = file.fullName(), unitName;
|
||||
|
||||
//just pass in the filename
|
||||
|
||||
#if defined (OSMac_)
|
||||
char fname[256];//MAXPATHLEN];
|
||||
strcpy (fname, file.fullName().asChar());
|
||||
// fp = fopen(fname,"wb");//MAYAMACTODO
|
||||
#else
|
||||
const char *fname = mname.asChar();
|
||||
// fp = fopen(fname,"w");
|
||||
#endif
|
||||
|
||||
shared_ptr<solver_impl_t> solv = solver_t::get_solver();
|
||||
|
||||
solv->export_bullet_file(fname);
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
bool ObjTranslator::haveReadMethod () const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
bool ObjTranslator::haveWriteMethod () const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
MString ObjTranslator::defaultExtension () const
|
||||
{
|
||||
// return MString("bullet");
|
||||
return fExtension;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
MPxFileTranslator::MFileKind ObjTranslator::identifyFile (
|
||||
const MFileObject& fileName,
|
||||
const char* buffer,
|
||||
short size) const
|
||||
{
|
||||
const char * name = fileName.name().asChar();
|
||||
int nameLength = strlen(name);
|
||||
|
||||
if ((nameLength > 7) && !strcasecmp(name+nameLength-7, ".bullet"))
|
||||
return kCouldBeMyFileType;
|
||||
else
|
||||
return kNotMyFileType;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
MStatus ObjTranslator::exportSelected( )
|
||||
{
|
||||
MStatus status;
|
||||
MString filename;
|
||||
|
||||
|
||||
// Create an iterator for the active selection list
|
||||
//
|
||||
MSelectionList slist;
|
||||
MGlobal::getActiveSelectionList( slist );
|
||||
MItSelectionList iter( slist );
|
||||
|
||||
if (iter.isDone()) {
|
||||
fprintf(stderr,"Error: Nothing is selected.\n");
|
||||
return MS::kFailure;
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
MStatus ObjTranslator::exportAll( )
|
||||
{
|
||||
MStatus status = MS::kSuccess;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
void* ObjTranslator::creator()
|
||||
{
|
||||
return new ObjTranslator();
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
MStatus ObjTranslator::reader ( const MFileObject& file,
|
||||
const MString& options,
|
||||
FileAccessMode mode)
|
||||
{
|
||||
fprintf(stderr, "Bullet Physics import is not available yet\n");
|
||||
return MS::kFailure;
|
||||
}
|
||||
|
||||
|
||||
|
||||
MStatus ObjTranslator::writer ( const MFileObject& file,
|
||||
const MString& options,
|
||||
FileAccessMode mode )
|
||||
|
||||
{
|
||||
MStatus status;
|
||||
|
||||
MString mname = file.fullName(), unitName;
|
||||
|
||||
//just pass in the filename
|
||||
|
||||
#if defined (OSMac_)
|
||||
char fname[256];//MAXPATHLEN];
|
||||
strcpy (fname, file.fullName().asChar());
|
||||
// fp = fopen(fname,"wb");//MAYAMACTODO
|
||||
#else
|
||||
const char *fname = mname.asChar();
|
||||
// fp = fopen(fname,"w");
|
||||
#endif
|
||||
|
||||
shared_ptr<solver_impl_t> solv = solver_t::get_solver();
|
||||
|
||||
solv->export_bullet_file(fname);
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
bool ObjTranslator::haveReadMethod () const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
bool ObjTranslator::haveWriteMethod () const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
MString ObjTranslator::defaultExtension () const
|
||||
{
|
||||
// return MString("bullet");
|
||||
return fExtension;
|
||||
}
|
||||
|
||||
MString ObjTranslator::filter() const
|
||||
{
|
||||
//return "*.bullet;*.dae";
|
||||
return "*.bullet";
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
MPxFileTranslator::MFileKind ObjTranslator::identifyFile (
|
||||
const MFileObject& fileName,
|
||||
const char* buffer,
|
||||
short size) const
|
||||
{
|
||||
const char * name = fileName.name().asChar();
|
||||
int nameLength = strlen(name);
|
||||
|
||||
if ((nameLength > 7) && !strcasecmp(name+nameLength-7, ".bullet"))
|
||||
return kCouldBeMyFileType;
|
||||
else
|
||||
return kNotMyFileType;
|
||||
}
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
MStatus ObjTranslator::exportSelected( )
|
||||
{
|
||||
MStatus status;
|
||||
MString filename;
|
||||
|
||||
|
||||
// Create an iterator for the active selection list
|
||||
//
|
||||
MSelectionList slist;
|
||||
MGlobal::getActiveSelectionList( slist );
|
||||
MItSelectionList iter( slist );
|
||||
|
||||
if (iter.isDone()) {
|
||||
fprintf(stderr,"Error: Nothing is selected.\n");
|
||||
return MS::kFailure;
|
||||
}
|
||||
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
|
||||
MStatus ObjTranslator::exportAll( )
|
||||
{
|
||||
MStatus status = MS::kSuccess;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
@@ -1,94 +1,97 @@
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library Maya Plugin
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising
|
||||
from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
01/27/2010 : Replaced COLLADA export with Bullet binary export
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BULLET_EXPORT_H
|
||||
#define BULLET_EXPORT_H
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/types.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 <maya/MIOStream.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
class ObjTranslator : public MPxFileTranslator {
|
||||
public:
|
||||
ObjTranslator () {};
|
||||
virtual ~ObjTranslator () {};
|
||||
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;
|
||||
protected:
|
||||
/*
|
||||
Bullet Continuous Collision Detection and Physics Library Maya Plugin
|
||||
|
||||
This software is provided 'as-is', without any express or implied warranty.
|
||||
In no event will the authors be held liable for any damages arising
|
||||
from the use of this software.
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it freely,
|
||||
subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must
|
||||
not claim that you wrote the original software. If you use this
|
||||
software in a product, an acknowledgment in the product documentation
|
||||
would be appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must
|
||||
not be misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Modified by Roman Ponomarev <rponom@gmail.com>
|
||||
01/27/2010 : Replaced COLLADA export with Bullet binary export
|
||||
*/
|
||||
|
||||
|
||||
#ifndef BULLET_EXPORT_H
|
||||
#define BULLET_EXPORT_H
|
||||
|
||||
#include <string.h>
|
||||
#include <sys/types.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 <maya/MIOStream.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////
|
||||
class ObjTranslator : public MPxFileTranslator {
|
||||
public:
|
||||
ObjTranslator () {};
|
||||
virtual ~ObjTranslator () {};
|
||||
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;
|
||||
|
||||
MString filter() const;
|
||||
|
||||
MFileKind identifyFile ( const MFileObject& fileName,
|
||||
const char* buffer,
|
||||
short size) const;
|
||||
protected:
|
||||
static MString fExtension;
|
||||
|
||||
private:
|
||||
MStatus exportSelected();
|
||||
MStatus exportAll();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //BULLET_EXPORT_H
|
||||
|
||||
|
||||
private:
|
||||
MStatus exportSelected();
|
||||
MStatus exportAll();
|
||||
|
||||
private:
|
||||
|
||||
};
|
||||
|
||||
|
||||
#endif //BULLET_EXPORT_H
|
||||
|
||||
|
||||
Reference in New Issue
Block a user