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