#include <maya/MIOStream.h>
#include <stdio.h>
#include <stdlib.h>
#include <maya/MPxToolCommand.h>
#include <maya/MFnPlugin.h>
#include <maya/MArgList.h>
#include <maya/MGlobal.h>
#include <maya/MRichSelection.h>
#include <maya/MItSelectionList.h>
#include <maya/MPoint.h>
#include <maya/MVector.h>
#include <maya/MDagPath.h>
#include <maya/MFnTransform.h>
#include <maya/MItGeometry.h>
#include <maya/MWeight.h>
#include <maya/MMatrix.h>
#include <maya/MPlane.h>
#define CHECKRESULT(stat,msg) \
if ( MS::kSuccess != stat ) { \
cerr << msg << endl; \
}
#define kVectorEpsilon 1.0e-3
#define RICHMOVENAME "richMoveCmd"
#define DOIT 0
#define UNDOIT 1
#define REDOIT 2
{
public:
richMoveCmd();
virtual ~richMoveCmd();
public:
static void* creator();
void setVector( double x, double y, double z);
private:
};
richMoveCmd::richMoveCmd( )
{
setCommandString( RICHMOVENAME );
}
richMoveCmd::~richMoveCmd()
{}
void* richMoveCmd::creator()
{
return new richMoveCmd;
}
bool richMoveCmd::isUndoable() const
{
return true;
}
void richMoveCmd::setVector( double x, double y, double z)
{
delta.x = x;
delta.y = y;
delta.z = z;
}
{
command.
addArg( commandString() );
}
{
unsigned i = 0;
{
case 1:
break;
case 2:
break;
case 3:
break;
case 0:
default:
break;
}
delta = vector;
return action( DOIT );
}
{
return action( UNDOIT );
}
{
return action( REDOIT );
}
MStatus richMoveCmd::action(
int flag )
{
switch( flag )
{
case UNDOIT:
break;
case REDOIT:
break;
case DOIT:
break;
default:
break;
}
{
{
iter.getDagPath( mdagPath, mComponent );
{
stat = transFn.translateBy( vector, spc );
CHECKRESULT(stat,"Error doing translate on transform");
continue;
}
}
else
{
iter.getDagPath( mdagPath, mComponent );
{
MVector origPosition = geoIter.position( spc);
geoIter.setPosition( position, spc);
}
}
}
}
{
{
iter.getDagPath( mdagPath, mComponent );
MVector symmetryVector = vector * symmetryMatrix;
{
stat = transFn.translateBy( symmetryVector, spc );
CHECKRESULT(stat,"Error doing translate on transform");
continue;
}
}
else
{
iter.getDagPath( mdagPath, mComponent );
{
MVector origPosition = geoIter.position( spc);
geoIter.setPosition( position, spc);
}
}
}
}
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"9.0",
"Any" );
status = plugin.registerCommand( RICHMOVENAME, &richMoveCmd::creator );
if (!status) {
status.
perror(
"registerCommand");
return status;
}
return status;
}
{
status = plugin.deregisterCommand( RICHMOVENAME );
if (!status) {
status.
perror(
"deregisterCommand");
return status;
}
return status;
}