#include <math.h>
#include <maya/MIOStream.h>
#include <maya/MPxCommand.h>
#include <maya/MStatus.h>
#include <maya/MObject.h>
#include <maya/MFnPlugin.h>
#include <maya/MString.h>
#include <maya/MArgList.h>
#include <maya/MGlobal.h>
#include <maya/MPoint.h>
#include <maya/MVector.h>
#include <maya/MMatrix.h>
#include <maya/MDagPath.h>
#include <maya/MSelectionList.h>
#include <maya/MItSelectionList.h>
#include <maya/MItSurfaceCV.h>
#include <maya/MItMeshVertex.h>
public:
surfaceTwist();
virtual ~surfaceTwist();
static void* creator();
};
#define NUM_SPANS 30
#define WIDTH 10.0
#define VERTICAL_SCALING 4.0
surfaceTwist::~surfaceTwist() {}
surfaceTwist::surfaceTwist() {}
void* surfaceTwist::creator()
{
return new surfaceTwist;
}
{
MVector toCenter( -center.
x, 0.0, -center.
y );
double rotFactor = 0.5;
MItSurfaceCV cvIter( objectPath, component,
true, &status );
for ( ; !cvIter.isDone(); cvIter.nextRow() ) {
for ( ; !cvIter.isRowDone(); cvIter.next() ) {
pnt = pnt + toCenter;
double rotation = pnt.
y * rotFactor;
rotMatrix(0,0) = cos( rotation );
rotMatrix(0,2) = sin( rotation );
rotMatrix(2,0) = -sin( rotation );
rotMatrix(2,2) = cos( rotation );
pnt = ( pnt * rotMatrix ) - toCenter;
break;
}
}
cvIter.updateSurface();
} else
}
{
MVector toCenter( -center.
x, 0.0, -center.
y );
double rotFactor = 0.5;
for ( ; !vertIter.isDone(); vertIter.next() ) {
pnt = pnt + toCenter;
double rotation = pnt.
y * rotFactor;
rotMatrix(0,0) = cos( rotation );
rotMatrix(0,2) = sin( rotation );
rotMatrix(2,0) = -sin( rotation );
rotMatrix(2,2) = cos( rotation );
pnt = ( pnt * rotMatrix ) - toCenter;
break;
}
vertIter.updateSurface();
} else
}
{
if (iter.isDone()) {
cerr << "Nothing selected\n";
}
for ( ; !iter.isDone(); iter.next() ) {
status = iter.getDagPath( objectPath, component );
status = twistNurbsSurface(objectPath, component);
status = twistPolygon(objectPath, component);
else {
cerr << "Selected object is not a NURBS surface or a polygon\n";
}
}
return status;
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any");
status = plugin.registerCommand( "surfaceTwist", surfaceTwist::creator );
if (!status) {
status.
perror(
"registerCommand");
return status;
}
return status;
}
{
status = plugin.deregisterCommand( "surfaceTwist" );
if (!status) {
status.
perror(
"deregisterCommand");
return status;
}
return status;
}