#include <maya/MStatus.h>
#include <maya/MObject.h>
#include <maya/MFnPlugin.h>
#include <maya/MDoubleArray.h>
#include <maya/MPointArray.h>
#include <maya/MPoint.h>
#include <maya/MFnNurbsSurface.h>
#include <maya/MString.h>
#include <maya/MPxCommand.h>
#include <maya/MIOStream.h>
#include <math.h>
public:
surfaceCreate();
~surfaceCreate() override;
static void* creator();
};
#define NUM_SPANS 30
#define WIDTH 10.0
#define VERTICAL_SCALING 4.0
surfaceCreate::~surfaceCreate() {}
surfaceCreate::surfaceCreate() {}
void* surfaceCreate::creator()
{
return new surfaceCreate();
}
{
int i;
for ( i = 0; i <= NUM_SPANS; i++ ) {
knotArray.
append( (
double)i );
}
knotArray.
append( (
double)i );
knotArray.
append( (
double)i );
int last = NUM_SPANS + 3;
for ( i = 0; i < last; i++ ) {
for ( int j = 0; j < last; j++ ) {
cv.
x = (((double)(j))/((
double)(NUM_SPANS + 3)) * WIDTH)
- (WIDTH/2.0);
cv.
z = (((double)(i))/((
double)(NUM_SPANS + 3)) * WIDTH)
- (WIDTH/2.0);
double dist = sqrt( cv.
x*cv.
x + cv.
z*cv.
z );
cv.
y = cos( dist ) * VERTICAL_SCALING;
}
}
mfnNurbsSurf.
create( cvArray, knotArray, knotArray, 3, 3,
if ( MS::kSuccess != stat )
cerr << "surfaceCreate failed: status " << stat << endl;
return stat;
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any");
status = plugin.registerCommand( "surfaceCreate", surfaceCreate::creator );
if (!status) {
status.
perror(
"registerCommand");
return status;
}
return status;
}
{
status = plugin.deregisterCommand( "surfaceCreate" );
if (!status) {
status.
perror(
"registerCommand");
return status;
}
return status;
}