#include "pointOnSubdNode.h"
#include <maya/MFnNumericAttribute.h>
#include <maya/MFnTypedAttribute.h>
#include <maya/MFnSubdNames.h>
#include <maya/MFnSubdData.h>
#include <maya/MDataHandle.h>
#include <maya/MDataBlock.h>
#include <maya/MFnPlugin.h>
#include <maya/MFnSubd.h>
#include <maya/MGlobal.h>
#include <maya/MVector.h>
#include <maya/MPoint.h>
#include <maya/MPlug.h>
MTypeId pointOnSubd::id( 0x80019 );
#include <maya/MIOStream.h>
#define McheckErr(status,message) \
if( MStatus::kSuccess != stat ) { \
cerr << message << "\n"; \
return stat; \
}
pointOnSubd::pointOnSubd() {}
pointOnSubd::~pointOnSubd() {}
{
if( (plug == aPoint) || (plug == aNormal) ||
(plug == aPointX) || (plug == aNormalX) ||
(plug == aPointY) || (plug == aNormalY) ||
(plug == aPointZ) || (plug == aNormalZ) ) {
do {
if( returnStatus != MS::kSuccess ) {
break;
}
if( returnStatus != MS::kSuccess ) {
break;
}
if( returnStatus != MS::kSuccess ) {
break;
}
if( returnStatus != MS::kSuccess ) {
break;
}
if( returnStatus != MS::kSuccess ) {
break;
}
if( returnStatus != MS::kSuccess ) {
break;
}
MFnSubd subdFn( subdValue, &stat );
McheckErr(stat,"ERROR creating subd function set");
int faceFirstValue = faceFirstHandle.
asLong();
int faceSecondValue = faceSecondHandle.
asLong();
bool relUV = relHandle.
asBool();
MUint64 polyId;
faceSecondValue );
McheckErr(stat,"ERROR converting indices");
stat = subdFn.evaluatePositionAndNormal( polyId, uValue, vValue,
relUV, point, normal );
McheckErr(stat,"ERROR evaluating the position and the normal");
pointHandle.
set( point.
x, point.
y, point.
z );
normalHandle.
set( normal.
x, normal.
y, normal.
z );
} while( false );
}
else {
return MS::kUnknownParameter;
}
return MS::kSuccess;
}
void* pointOnSubd::creator()
{
return new pointOnSubd;
}
{
McheckErr( stat, "cannot create pointOnSubd::aSubd" );
stat = addAttribute( pointOnSubd::aSubd );
McheckErr( stat, "cannot add pointOnSubd::aSubd" );
aFaceFirst = faceFirstAttr.
create(
"faceFirst",
"ff",
McheckErr( stat, "cannot create pointOnSubd::aFaceFirst" );
stat = addAttribute( pointOnSubd::aFaceFirst );
McheckErr( stat, "cannot add pointOnSubd::aFaceFirst" );
aFaceSecond = faceSecondAttr.
create(
"faceSecond",
"fs",
McheckErr( stat, "cannot create pointOnSubd::aFaceSecond" );
stat = addAttribute( pointOnSubd::aFaceSecond );
McheckErr( stat, "cannot add pointOnSubd::aFaceSecond" );
0, &stat );
McheckErr( stat, "cannot create pointOnSubd::aU" );
stat = addAttribute( aU );
McheckErr( stat, "cannot add pointOnSubd::aU" );
0, &stat );
McheckErr( stat, "cannot create pointOnSubd::aV" );
stat = addAttribute( aV );
McheckErr( stat, "cannot add pointOnSubd::aV" );
0, &stat );
McheckErr( stat, "cannot create pointOnSubd::aRelativeUV" );
stat = addAttribute( pointOnSubd::aRelativeUV );
McheckErr( stat, "cannot add pointOnSubd::aRelativeUV" );
0.0, &stat );
McheckErr( stat, "cannot create pointOnSubd::aPointX" );
stat = addAttribute( aPointX );
McheckErr( stat, "cannot add pointOnSubd::aPointX" );
0.0, &stat );
McheckErr( stat, "cannot create pointOnSubd::aPointY" );
stat = addAttribute( aPointY );
McheckErr( stat, "cannot add pointOnSubd::aPointY" );
0.0, &stat );
McheckErr( stat, "cannot create pointOnSubd::aPointZ" );
stat = addAttribute( aPointZ );
McheckErr( stat, "cannot add pointOnSubd::aPointZ" );
aPoint = pointAttr.
create(
"point",
"p", aPointX, aPointY, aPointZ, &stat);
McheckErr( stat, "cannot create pointOnSubd::aPoint" );
stat = addAttribute( aPoint );
McheckErr( stat, "cannot add pointOnSubd::aPoint" );
0.0, &stat );
McheckErr( stat, "cannot create pointOnSubd::aNormal" );
stat = addAttribute( aNormalX );
McheckErr( stat, "cannot add pointOnSubd::aNormalX" );
0.0, &stat );
McheckErr( stat, "cannot create pointOnSubd::aNormal" );
stat = addAttribute( aNormalY );
McheckErr( stat, "cannot add pointOnSubd::aNormalY" );
0.0, &stat );
McheckErr( stat, "cannot create pointOnSubd::aNormal" );
stat = addAttribute( aNormalZ );
McheckErr( stat, "cannot add pointOnSubd::aNormalZ" );
aNormal = normalAttr.
create(
"normal",
"n",aNormalX,aNormalY,aNormalZ,&stat);
McheckErr( stat, "cannot create pointOnSubd::aNormal" );
stat = addAttribute( aNormal );
McheckErr( stat, "cannot add pointOnSubd::aNormal" );
stat = attributeAffects( aSubd, aPoint );
stat = attributeAffects( aSubd, aPointX );
stat = attributeAffects( aSubd, aPointY );
stat = attributeAffects( aSubd, aPointZ );
stat = attributeAffects( aSubd, aNormal );
stat = attributeAffects( aSubd, aNormalX );
stat = attributeAffects( aSubd, aNormalY );
stat = attributeAffects( aSubd, aNormalZ );
stat = attributeAffects( aFaceFirst, aPoint );
stat = attributeAffects( aFaceFirst, aPointX );
stat = attributeAffects( aFaceFirst, aPointY );
stat = attributeAffects( aFaceFirst, aPointZ );
stat = attributeAffects( aFaceFirst, aNormal );
stat = attributeAffects( aFaceFirst, aNormalX );
stat = attributeAffects( aFaceFirst, aNormalY );
stat = attributeAffects( aFaceFirst, aNormalZ );
stat = attributeAffects( aFaceSecond, aPoint );
stat = attributeAffects( aFaceSecond, aPointX );
stat = attributeAffects( aFaceSecond, aPointY );
stat = attributeAffects( aFaceSecond, aPointZ );
stat = attributeAffects( aFaceSecond, aNormal );
stat = attributeAffects( aFaceSecond, aNormalX );
stat = attributeAffects( aFaceSecond, aNormalY );
stat = attributeAffects( aFaceSecond, aNormalZ );
stat = attributeAffects( aU, aPoint );
stat = attributeAffects( aU, aPointX );
stat = attributeAffects( aU, aPointY );
stat = attributeAffects( aU, aPointZ );
stat = attributeAffects( aU, aNormal );
stat = attributeAffects( aU, aNormalX );
stat = attributeAffects( aU, aNormalY );
stat = attributeAffects( aU, aNormalZ );
stat = attributeAffects( aV, aPoint );
stat = attributeAffects( aV, aPointX );
stat = attributeAffects( aV, aPointY );
stat = attributeAffects( aV, aPointZ );
stat = attributeAffects( aV, aNormal );
stat = attributeAffects( aV, aNormalX );
stat = attributeAffects( aV, aNormalY );
stat = attributeAffects( aV, aNormalZ );
stat = attributeAffects( aRelativeUV, aPoint );
stat = attributeAffects( aRelativeUV, aPointX );
stat = attributeAffects( aRelativeUV, aPointY );
stat = attributeAffects( aRelativeUV, aPointZ );
stat = attributeAffects( aRelativeUV, aNormal );
stat = attributeAffects( aRelativeUV, aNormalX );
stat = attributeAffects( aRelativeUV, aNormalY );
stat = attributeAffects( aRelativeUV, aNormalZ );
return MS::kSuccess;
}
{
MFnPlugin plugin( obj, PLUGIN_COMPANY,
"3.0",
"Any");
status = plugin.registerNode( "pointOnSubd",
pointOnSubd::id,
pointOnSubd::creator,
pointOnSubd::initialize );
if (!status) {
status.
perror(
"registerNode");
return status;
}
return status;
}
{
status = plugin.deregisterNode( pointOnSubd::id );
if (!status) {
status.
perror(
"deregisterNode");
return status;
}
return status;
}