MStatus SwirlDeformer::initialize() { MFnMatrixAttribute mAttr; deformSpace = mAttr.create( "deformSpace", "dSp" ); mAttr.setStorable( false ); MFnUnitAttribute unitFn; startDist = unitFn.create( "startDist", "sd", MFnUnitAttribute::kDistance ); unitFn.setDefault( MDistance( 0.0, MDistance::uiUnit() ) ); unitFn.setMin( MDistance( 0.0, MDistance::uiUnit() ) ); unitFn.setKeyable( true ); endDist = unitFn.create( "endDist", "ed", MFnUnitAttribute::kDistance ); unitFn.setDefault( MDistance( 3.0, MDistance::uiUnit() ) ); unitFn.setMin( MDistance( 0.0, MDistance::uiUnit() ) ); unitFn.setKeyable( true ); addAttribute( deformSpace ); addAttribute( startDist ); addAttribute( endDist ); attributeAffects( deformSpace, outputGeom ); attributeAffects( startDist, outputGeom ); attributeAffects( endDist, outputGeom ); return MS::kSuccess; }
MStatus timeControl::initialize() { MStatus status; MFnNumericAttribute nAttr; MFnUnitAttribute uAttr; aOutTime = uAttr.create( "outTime", "outTime", MFnUnitAttribute::kTime, 0.0 ); uAttr.setStorable( true ); CHECK_MSTATUS( addAttribute( aOutTime ) ); aOutWeight = nAttr.create( "outWeight", "outWeight", MFnNumericData::kDouble, 0.0 ); nAttr.setStorable( true ); CHECK_MSTATUS( addAttribute( aOutWeight ) ); aInTime = uAttr.create( "inTime", "inTime", MFnUnitAttribute::kTime, 0.0 ); uAttr.setStorable( true ); CHECK_MSTATUS( addAttribute( aInTime ) ); CHECK_MSTATUS( attributeAffects( aInTime, aOutTime ) ); aWeight = nAttr.create( "weight", "weight", MFnNumericData::kDouble, 10.0 ); nAttr.setStorable( true ); nAttr.setKeyable( true ); CHECK_MSTATUS( addAttribute( aWeight ) ); CHECK_MSTATUS( attributeAffects( aWeight, aOutWeight ) ); aOffset = nAttr.create( "offset", "offset", MFnNumericData::kDouble, 0.0 ); nAttr.setStorable( true ); nAttr.setKeyable( true ); CHECK_MSTATUS( addAttribute( aOffset ) ); CHECK_MSTATUS( attributeAffects( aOffset, aOutTime ) ); aMult = nAttr.create( "mult", "mult", MFnNumericData::kDouble, 1.0 ); nAttr.setStorable( true ); nAttr.setKeyable( true ); CHECK_MSTATUS( addAttribute( aMult ) ); CHECK_MSTATUS( attributeAffects( aMult, aOutTime ) ); aLimitAble = nAttr.create( "limitAble", "limitAble", MFnNumericData::kBoolean, false ); nAttr.setStorable( true ); nAttr.setKeyable( true ); CHECK_MSTATUS( addAttribute( aLimitAble ) ); CHECK_MSTATUS( attributeAffects( aLimitAble, aOutTime ) ); aMinTime = uAttr.create( "minTime", "minTime", MFnUnitAttribute::kTime, 1.0 ); uAttr.setStorable( true ); uAttr.setKeyable( true ); CHECK_MSTATUS( addAttribute( aMinTime ) ); CHECK_MSTATUS( attributeAffects( aMinTime, aOutTime ) ); aMaxTime = uAttr.create( "maxTime", "maxTime", MFnUnitAttribute::kTime, 20.0 ); uAttr.setStorable( true ); uAttr.setKeyable( true ); CHECK_MSTATUS( addAttribute( aMaxTime ) ); CHECK_MSTATUS( attributeAffects( aMaxTime, aOutTime ) ); return MS::kSuccess; }
MPlug TransformationMatrixParameterHandler<T>::doCreate( IECore::ConstParameterPtr parameter, const MString &plugName, MObject &node ) const { typename IECore::TypedParameter<IECore::TransformationMatrix<T> >::ConstPtr p = IECore::runTimeCast<const IECore::TypedParameter<IECore::TransformationMatrix<T> > >( parameter ); if( !p ) { return MPlug(); } MFnCompoundAttribute fnCAttr; MObject attribute = fnCAttr.create( plugName, plugName ); MFnNumericAttribute fnNAttr; MFnUnitAttribute fnUAttr; // As TransformationMatrix embodies a fairly comprehensive rotation model, were going to be a little // more basic here, and just supply a V3f rotation and pretend that the Quartonean isn't there. ///\todo Expose rotation order and rotationOrientation. // These use the '0', '1' and '2' child suffixes instead of 'X' 'Y' and 'Z' to match those created by fnNAttr.create() @ L188. MObject p1 = fnUAttr.create( plugName + g_attributeNames[ TRANSLATE_INDEX ] + "0", plugName + g_attributeNames[ TRANSLATE_INDEX ] + "0", MFnUnitAttribute::kDistance ); MObject p2 = fnUAttr.create( plugName + g_attributeNames[ TRANSLATE_INDEX ] + "1", plugName + g_attributeNames[ TRANSLATE_INDEX ] + "1", MFnUnitAttribute::kDistance ); MObject p3 = fnUAttr.create( plugName + g_attributeNames[ TRANSLATE_INDEX ] + "2", plugName + g_attributeNames[ TRANSLATE_INDEX ] + "2", MFnUnitAttribute::kDistance ); fnCAttr.addChild( fnNAttr.create( plugName + g_attributeNames[ TRANSLATE_INDEX ], plugName + g_attributeNames[ TRANSLATE_INDEX ], p1, p2, p3 ) ); p1 = fnUAttr.create( plugName + g_attributeNames[ ROTATE_INDEX ] + "0", plugName + g_attributeNames[ ROTATE_INDEX ] + "0", MFnUnitAttribute::kAngle ); p2 = fnUAttr.create( plugName + g_attributeNames[ ROTATE_INDEX ] + "1", plugName + g_attributeNames[ ROTATE_INDEX ] + "1", MFnUnitAttribute::kAngle ); p3 = fnUAttr.create( plugName + g_attributeNames[ ROTATE_INDEX ] + "2", plugName + g_attributeNames[ ROTATE_INDEX ] + "2", MFnUnitAttribute::kAngle ); fnCAttr.addChild( fnNAttr.create( plugName + g_attributeNames[ ROTATE_INDEX ], plugName + g_attributeNames[ ROTATE_INDEX ], p1, p2, p3 ) ); for( unsigned int i=2; i<8; i++ ) { fnCAttr.addChild( fnNAttr.create( plugName + g_attributeNames[i], plugName + g_attributeNames[i], NumericTraits<Imath::Vec3<T> >::dataType() ) ); } MPlug result = finishCreating( parameter, attribute, node ); if( !doUpdate( parameter, result ) ) { return MPlug(); // failure } if( !finishUpdating( parameter, result ) ) { return MPlug(); // failure } return result; }
MStatus testNpassiveNode::initialize() { MStatus stat; MFnTypedAttribute tAttr; inputGeom = tAttr.create("inputGeom", "ing", MFnData::kMesh, MObject::kNullObj, &stat ); //statCheck(stat, "failed to create inputGeom"); tAttr.setWritable(true); tAttr.setStorable(true); tAttr.setHidden(true); currentState = tAttr.create("currentState", "cus", MFnData::kNObject, MObject::kNullObj, &stat ); // statCheck(stat, "failed to create currentState"); tAttr.setWritable(true); tAttr.setStorable(false); tAttr.setHidden(true); startState = tAttr.create( "startState", "sts", MFnData::kNObject, MObject::kNullObj, &stat ); //statCheck(stat, "failed to create startState"); tAttr.setWritable(true); tAttr.setStorable(false); tAttr.setHidden(true); MFnUnitAttribute uniAttr; currentTime = uniAttr.create( "currentTime", "ctm" , MFnUnitAttribute::kTime, 0.0, &stat ); addAttribute(inputGeom); addAttribute(currentTime); addAttribute(startState); addAttribute(currentState); attributeAffects(inputGeom, startState); attributeAffects(inputGeom, currentState); attributeAffects(currentTime, currentState); attributeAffects(currentTime, startState); return MStatus::kSuccess; }
MStatus ClothSimMayaPlugin::initialize() { MFnUnitAttribute unitAttr; MFnTypedAttribute typedAttr; MStatus returnStatus; g_aTime = unitAttr.create("time", "tm", MFnUnitAttribute::kTime, 0.0, &returnStatus); McheckErr(returnStatus, "ERROR creating time attribute\n"); g_aOutputMesh = typedAttr.create("outputMesh", "out", MFnData::kMesh, &returnStatus); McheckErr(returnStatus, "ERROR creating output attribute\n"); typedAttr.setStorable(false); returnStatus = addAttribute(g_aTime); McheckErr(returnStatus, "ERROR adding time attribute\n"); returnStatus = addAttribute(g_aOutputMesh); McheckErr(returnStatus, "ERROR adding outputMesh attribute\n"); returnStatus = attributeAffects(g_aTime, g_aOutputMesh); McheckErr(returnStatus, "ERROR in attributeAffects\n"); return MS::kSuccess; }
MStatus arrowLocator::initialize() { //Here we create a new attribute type that handles units: angle, distance or time MFnUnitAttribute uAttr; windDirection = uAttr.create("windDirection", "wd", MFnUnitAttribute::kAngle, 0.0); uAttr.setStorable(true); uAttr.setWritable(true); uAttr.setReadable(true); uAttr.setKeyable(true); uAttr.setDefault(MAngle(0.0, MAngle::kDegrees)); addAttribute(windDirection); //- TODO: To make connection between your custom node and your custom //- TODO: manipulator node, you need to name your custom manipulator //- TODO: after your custom node type name, also in your custom node's initialize() //- TODO: function, you need to call MPxManipContainer::addToManipConnectTable(). //- TODO: This method adds the user defined node as an entry in the manipConnectTable //- TODO: so that when this node is selected the user can use the show manip tool to //- TODO: get the user defined manipulator associated with this node. //... return MS::kSuccess; }
MStatus animCube::initialize() { MFnUnitAttribute unitAttr; MFnTypedAttribute typedAttr; MStatus returnStatus; animCube::time = unitAttr.create( "time", "tm", MFnUnitAttribute::kTime, 0.0, &returnStatus ); McheckErr(returnStatus, "ERROR creating animCube time attribute\n"); animCube::outputMesh = typedAttr.create( "outputMesh", "out", MFnData::kMesh, &returnStatus ); McheckErr(returnStatus, "ERROR creating animCube output attribute\n"); typedAttr.setStorable(false); returnStatus = addAttribute(animCube::time); McheckErr(returnStatus, "ERROR adding time attribute\n"); returnStatus = addAttribute(animCube::outputMesh); McheckErr(returnStatus, "ERROR adding outputMesh attribute\n"); returnStatus = attributeAffects(animCube::time, animCube::outputMesh); McheckErr(returnStatus, "ERROR in attributeAffects\n"); return MS::kSuccess; }
MStatus simpleEvaluationNode::initialize() { MFnNumericAttribute nAttr; MFnUnitAttribute uAttr; MStatus status; input = nAttr.create( "input", "in", MFnNumericData::kFloat, 2.0 ); nAttr.setStorable(true); aTimeInput = uAttr.create( "inputTime", "itm", MFnUnitAttribute::kTime, 0.0 ); uAttr.setWritable(true); uAttr.setStorable(true); uAttr.setReadable(true); uAttr.setKeyable(true); output = nAttr.create( "output", "out", MFnNumericData::kFloat, 0.0 ); nAttr.setWritable(false); nAttr.setStorable(false); status = addAttribute( input ); if (!status) { status.perror("addAttribute"); return status;} status = addAttribute( aTimeInput ); if (!status) { status.perror("addAttribute"); return status;} status = addAttribute( output ); if (!status) { status.perror("addAttribute"); return status;} status = attributeAffects( input, output ); if (!status) { status.perror("attributeAffects"); return status;} status = attributeAffects( aTimeInput, output ); if (!status) { status.perror("attributeAffects"); return status;} return MS::kSuccess; }
MStatus ArrayAngleConstructorNode::initialize() { MStatus status; MFnNumericAttribute N; MFnTypedAttribute T; MFnUnitAttribute U; aSize = N.create("size", "size", MFnNumericData::kInt, 8.0, &status); N.setKeyable(true); N.setStorable(true); N.setWritable(true); N.setDefault(8); aInput = U.create("input", "i", MFnUnitAttribute::kAngle, 0.0, &status); U.setKeyable(false); U.setStorable(true); U.setWritable(true); U.setArray(true); aOutput = T.create("output", "o", MFnData::kDoubleArray, &status); T.setKeyable(false); T.setChannelBox(false); T.setWritable(false); T.setStorable(false); addAttribute(aSize); addAttribute(aInput); addAttribute(aOutput); attributeAffects(aSize, aOutput); attributeAffects(aInput, aOutput); return MS::kSuccess; }
MStatus BasicLocator::initialize() { MFnUnitAttribute unitFn; MFnNumericAttribute numFn; MStatus stat; xWidth = unitFn.create( "xWidth", "xw", MFnUnitAttribute::kDistance ); unitFn.setDefault( MDistance(1.0, MDistance::uiUnit()) ); unitFn.setMin( MDistance(0.0, MDistance::uiUnit()) ); unitFn.setKeyable( true ); stat = addAttribute( xWidth ); if (!stat) { stat.perror( "Unable to add \"xWidth\" attribute" ); return stat; } zWidth = unitFn.create( "zWidth", "zw", MFnUnitAttribute::kDistance ); unitFn.setDefault( MDistance(1.0, MDistance::uiUnit()) ); unitFn.setMin( MDistance(0.0, MDistance::uiUnit()) ); unitFn.setKeyable( true ); stat = addAttribute( zWidth ); if (!stat) { stat.perror( "Unable to add \"zWidth\" attribute" ); return stat; } dispType = numFn.create( "dispType", "att", MFnNumericData::kShort ); numFn.setDefault( 0); numFn.setMin( 0 ); numFn.setMax( 2 ); numFn.setKeyable( true ); stat = addAttribute( dispType ); if (!stat) { stat.perror( "Unable to add \"dispType\" attribute" ); return stat; } // Notify Maya that there is an associated manipulator for this particular type of node MPxManipContainer::addToManipConnectTable( const_cast<MTypeId &>( typeId ) ); return MS::kSuccess; }
MStatus AlembicCurvesDeformNode::initialize() { MStatus status; MFnUnitAttribute uAttr; MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MFnGenericAttribute gAttr; MFnStringData emptyStringData; MObject emptyStringObject = emptyStringData.create(""); // input time mTimeAttr = uAttr.create("inTime", "tm", MFnUnitAttribute::kTime, 0.0); status = uAttr.setStorable(true); status = uAttr.setKeyable(true); status = addAttribute(mTimeAttr); // input file name mFileNameAttr = tAttr.create("fileName", "fn", MFnData::kString, emptyStringObject); status = tAttr.setStorable(true); status = tAttr.setUsedAsFilename(true); status = tAttr.setKeyable(false); status = addAttribute(mFileNameAttr); // input identifier mIdentifierAttr = tAttr.create("identifier", "if", MFnData::kString, emptyStringObject); status = tAttr.setStorable(true); status = tAttr.setKeyable(false); status = addAttribute(mIdentifierAttr); // output for list of ArbGeomParams mGeomParamsList = tAttr.create("ExocortexAlembic_GeomParams", "exo_gp", MFnData::kString, emptyStringObject); status = tAttr.setStorable(true); status = tAttr.setKeyable(false); status = tAttr.setHidden(false); status = tAttr.setInternal(true); status = addAttribute(mGeomParamsList); // output for list of UserAttributes mUserAttrsList = tAttr.create("ExocortexAlembic_UserAttributes", "exo_ua", MFnData::kString, emptyStringObject); status = tAttr.setStorable(true); status = tAttr.setKeyable(false); status = tAttr.setHidden(false); status = tAttr.setInternal(true); status = addAttribute(mUserAttrsList); // create a mapping status = attributeAffects(mTimeAttr, outputGeom); status = attributeAffects(mFileNameAttr, outputGeom); status = attributeAffects(mIdentifierAttr, outputGeom); return status; }
MStatus LSystemNode::initialize() { MFnUnitAttribute unitAttr; MFnTypedAttribute typedAttr; MFnNumericAttribute numericAttr; MStatus returnStatus; //(i)angle LSystemNode::angle = numericAttr.create("angle","ag",MFnNumericData::kDouble,90.0,&returnStatus); McheckErr(returnStatus, "ERROR creating LSystemNode angle attribute\n"); //(ii)size step = numericAttr.create("step","st",MFnNumericData::kDouble,1.0, &returnStatus); McheckErr(returnStatus, "ERROR creating LSystemNode step attribute\n");//(iv)time //(iii)grammar LSystemNode::grammar = typedAttr.create( "grammar", "grm", MFnData::kString, &returnStatus ); McheckErr(returnStatus, "ERROR creating LSystemNode grammar attribute\n"); //(iv)time LSystemNode::time = unitAttr.create( "time", "tm", MFnUnitAttribute::kTime, 0.0, &returnStatus ); McheckErr(returnStatus, "ERROR creating LSystemNode time attribute\n"); //(v)output LSystemNode::outputMesh = typedAttr.create( "outputMesh", "out", MFnData::kMesh, &returnStatus ); McheckErr(returnStatus, "ERROR creating LSystemNode output attribute\n"); typedAttr.setStorable(false); //(i)angle returnStatus = addAttribute(LSystemNode::angle); McheckErr(returnStatus, "ERROR adding angle attribute\n"); //(ii)step returnStatus = addAttribute(LSystemNode::step); McheckErr(returnStatus, "ERROR adding step attribute\n"); //(iii)grammar returnStatus = addAttribute(LSystemNode::grammar); McheckErr(returnStatus, "ERROR adding grammar attribute\n"); //(iv)time returnStatus = addAttribute(LSystemNode::time); McheckErr(returnStatus, "ERROR adding time attribute\n"); //(v)output returnStatus = addAttribute(LSystemNode::outputMesh); McheckErr(returnStatus, "ERROR adding outputMesh attribute\n"); returnStatus = attributeAffects(LSystemNode::angle,LSystemNode::outputMesh); McheckErr(returnStatus, "ERROR in attributeAffects\n"); returnStatus = attributeAffects(LSystemNode::step,LSystemNode::outputMesh); McheckErr(returnStatus, "ERROR in attributeAffects\n"); returnStatus = attributeAffects(LSystemNode::grammar,LSystemNode::outputMesh); McheckErr(returnStatus, "ERROR in attributeAffects\n"); returnStatus = attributeAffects(LSystemNode::time,LSystemNode::outputMesh); McheckErr(returnStatus, "ERROR in attributeAffects\n"); return MS::kSuccess; }
//- The initialize method is called to create and initialize all of the //- attributes and attribute dependencies for this node type. This is //- only called once when the node type is registered with Maya. //- Return Values: MS::kSuccess / MS::kFailure //- /*static*/ MStatus arrowLocator::initialize() { //- Here we create a new attribute type that handles units: angle, distance or time MFnUnitAttribute uAttr; windDirection = uAttr.create("windDirection", "wd", MFnUnitAttribute::kAngle, 0.0); uAttr.setStorable(true); uAttr.setWritable(true); uAttr.setReadable(true); uAttr.setKeyable(true); uAttr.setMin(0.0); uAttr.setMax(2*PI); uAttr.setDefault(MAngle(0.0, MAngle::kRadians)); addAttribute(windDirection); return MS::kSuccess; }
MStatus footPrint::initialize() { MFnUnitAttribute unitFn; MStatus stat; size = unitFn.create( "size", "sz", MFnUnitAttribute::kDistance ); unitFn.setDefault( 1.0 ); stat = addAttribute( size ); if (!stat) { stat.perror("addAttribute"); return stat; } return MS::kSuccess; }
MStatus testNucleusNode::initialize() { MStatus stat; MFnTypedAttribute tAttr; startState = tAttr.create("startState", "sst", MFnData::kNObject, MObject::kNullObj, &stat ); statCheck(stat, "failed to create startState"); tAttr.setWritable(true); tAttr.setStorable(true); tAttr.setHidden(true); tAttr.setArray(true); currentState = tAttr.create("currentState", "cst", MFnData::kNObject, MObject::kNullObj, &stat ); statCheck(stat, "failed to create currentState"); tAttr.setWritable(true); tAttr.setStorable(true); tAttr.setHidden(true); tAttr.setArray(true); nextState = tAttr.create("nextState", "nst", MFnData::kNObject, MObject::kNullObj, &stat ); statCheck(stat, "failed to create nextState"); tAttr.setWritable(true); tAttr.setStorable(true); tAttr.setHidden(true); tAttr.setArray(true); MFnUnitAttribute uniAttr; currentTime = uniAttr.create( "currentTime", "ctm" , MFnUnitAttribute::kTime, 0.0, &stat ); addAttribute(startState); addAttribute(currentState); addAttribute(nextState); addAttribute(currentTime); attributeAffects(startState, nextState); attributeAffects(currentState, nextState); attributeAffects(currentTime, nextState); return MStatus::kSuccess; }
MStatus AlembicCurvesLocatorNode::initialize() { MStatus status; MFnUnitAttribute uAttr; MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MFnGenericAttribute gAttr; MFnStringData emptyStringData; MObject emptyStringObject = emptyStringData.create(""); // input time mTimeAttr = uAttr.create("inTime", "tm", MFnUnitAttribute::kTime, 0.0); status = uAttr.setStorable(true); status = uAttr.setKeyable(true); status = addAttribute(mTimeAttr); // input file name mFileNameAttr = tAttr.create("fileName", "fn", MFnData::kString, emptyStringObject); status = tAttr.setStorable(true); status = tAttr.setUsedAsFilename(true); status = tAttr.setKeyable(false); status = addAttribute(mFileNameAttr); // input identifier mIdentifierAttr = tAttr.create("identifier", "if", MFnData::kString, emptyStringObject); status = tAttr.setStorable(true); status = tAttr.setKeyable(false); status = addAttribute(mIdentifierAttr); // sentinel attr mSentinelAttr = nAttr.create("sentinel", "sent", MFnNumericData::kInt, 0); nAttr.setHidden(true); status = addAttribute(mSentinelAttr); // create a mapping status = attributeAffects(mTimeAttr, mSentinelAttr); status = attributeAffects(mFileNameAttr, mSentinelAttr); status = attributeAffects(mIdentifierAttr, mSentinelAttr); return status; }
MStatus vixo_visImport::initialize() { MFnNumericAttribute nAttr; vis=nAttr.create("visibility","vis",MFnNumericData::kBoolean,1); nAttr.setArray(true); MFnUnitAttribute uAttr; time=uAttr.create("time","t",MFnUnitAttribute::Type::kTime,1); MFnTypedAttribute tAttr; file=tAttr.create("file","f",MFnData::kString); tAttr.setStorable(true); addAttribute(time); addAttribute(file); addAttribute(vis); attributeAffects(time,vis); attributeAffects(file,vis); return MS::kSuccess; }
MStatus kgLocator::initialize() { MFnUnitAttribute unitFn; MStatus stat; //Let us inherit the attributes, //in case we need it MString parentClass("MPxLocatorNode"); stat = inheritAttributesFrom( parentClass ); //Create the height attribute height = unitFn.create( "height", "h", MFnUnitAttribute::kDistance ); unitFn.setDefault( MDistance( 2.0, MDistance::uiUnit() ) ); unitFn.setMin( MDistance( 0.0, MDistance::uiUnit() ) ); stat = addAttribute( height ); if (!stat ) { stat.perror( "Unable to add \"height\" attribute"); return stat; } //generates points for drwing the locator getPoints( pts ); // Notify Maya that there is an associated manipulator for this particular type of node MPxManipContainer::addToManipConnectTable( const_cast<MTypeId &>( id ) ); return MS::kSuccess; }
MStatus blendTwoMatrixDecompose::initialize() { MStatus stat; MFnMatrixAttribute mAttr; MFnNumericAttribute nAttr; MFnUnitAttribute uAttr; aMatrix1 = mAttr.create( "inMatrix1", "i1" ); mAttr.setStorable( true ); aMatrix2 = mAttr.create( "inMatrix2", "i2" ); mAttr.setStorable( true ); aBlender = nAttr.create( "attributeBlender", "ab", MFnNumericData::kFloat, 0.5 ); nAttr.setMin(0); nAttr.setMax(1); nAttr.setStorable( true ); aOutputTranslateX = nAttr.create( "outputTranslateX", "otx", MFnNumericData::kDouble, 0.0 ); aOutputTranslateY = nAttr.create( "outputTranslateY", "oty", MFnNumericData::kDouble, 0.0 ); aOutputTranslateZ = nAttr.create( "outputTranslateZ", "otz", MFnNumericData::kDouble, 0.0 ); aOutputTranslate = nAttr.create( "outputTranslate", "ot", aOutputTranslateX, aOutputTranslateY, aOutputTranslateZ ); nAttr.setStorable( false ); nAttr.setWritable( false ); aOutputRotateX = uAttr.create( "outputRotateX", "orx", MFnUnitAttribute::kAngle, 0.0 ); aOutputRotateY = uAttr.create( "outputRotateY", "ory", MFnUnitAttribute::kAngle, 0.0 ); aOutputRotateZ = uAttr.create( "outputRotateZ", "orz", MFnUnitAttribute::kAngle, 0.0 ); aOutputRotate = nAttr.create( "outputRotate", "or", aOutputRotateX, aOutputRotateY, aOutputRotateZ ); nAttr.setStorable( false ); nAttr.setWritable( false ); aOutputScaleX = nAttr.create( "outputScaleX", "osx", MFnNumericData::kDouble, 0.0 ); aOutputScaleY = nAttr.create( "outputScaleY", "osy", MFnNumericData::kDouble, 0.0 ); aOutputScaleZ = nAttr.create( "outputScaleZ", "osz", MFnNumericData::kDouble, 0.0 ); aOutputScale = nAttr.create( "outputScale", "os", aOutputScaleX, aOutputScaleY, aOutputScaleZ ); nAttr.setStorable( false ); nAttr.setWritable( false ); aOutputShearX = nAttr.create( "outputShearX", "oshx", MFnNumericData::kDouble, 0.0 ); aOutputShearY = nAttr.create( "outputShearY", "oshy", MFnNumericData::kDouble, 0.0 ); aOutputShearZ = nAttr.create( "outputShearZ", "oshz", MFnNumericData::kDouble, 0.0 ); aOutputShear = nAttr.create( "outputShear", "osh", aOutputShearX, aOutputShearY, aOutputShearZ ); nAttr.setStorable( false ); nAttr.setWritable( false ); stat = addAttribute( aMatrix1 ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( aMatrix2 ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( aBlender ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( aOutputTranslate ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( aOutputRotate ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( aOutputScale ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( aOutputShear ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = attributeAffects( aMatrix1, aOutputTranslate ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aMatrix1, aOutputRotate ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aMatrix1, aOutputScale ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aMatrix1, aOutputShear ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aMatrix2, aOutputTranslate ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aMatrix2, aOutputRotate ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aMatrix2, aOutputScale ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aMatrix2, aOutputShear ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aBlender, aOutputTranslate ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aBlender, aOutputRotate ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aBlender, aOutputScale ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aBlender, aOutputShear ); if (!stat) { stat.perror("attributeAffects"); return stat;} return MS::kSuccess; }
MStatus retargetLocator::initialize() { MFnNumericAttribute nAttr; MFnMatrixAttribute mAttr; MFnEnumAttribute eAttr; MFnUnitAttribute uAttr; MFnCompoundAttribute cAttr; MFnTypedAttribute tAttr; aOutput = nAttr.create( "output", "output", MFnNumericData::kDouble ); nAttr.setStorable( false ); CHECK_MSTATUS( addAttribute( aOutput ) ); aDiscMatrix = mAttr.create( "discMatrix", "discMatrix" ); mAttr.setStorable( true ); CHECK_MSTATUS( addAttribute( aDiscMatrix ) ); CHECK_MSTATUS( attributeAffects( aDiscMatrix, aOutput ) ); aDiscAxis = eAttr.create( "discAxis", "discAxis", 0 ); eAttr.addField( "X", 0 ); eAttr.addField( "Y", 1 ); eAttr.addField( "Z", 2 ); eAttr.setStorable( true ); eAttr.setChannelBox( true ); eAttr.setReadable( true ); CHECK_MSTATUS( addAttribute( aDiscAxis ) ); CHECK_MSTATUS( attributeAffects( aDiscAxis, aOutput ) ); aDiscDivision = nAttr.create( "discDivision", "discDivision", MFnNumericData::kInt, 32 ); nAttr.setMin( 1 ); nAttr.setMax( 32 ); nAttr.setStorable( true ); nAttr.setChannelBox( true ); CHECK_MSTATUS( addAttribute( aDiscDivision ) ); CHECK_MSTATUS( attributeAffects( aDiscDivision, aOutput ) ); aDiscAngle = uAttr.create( "discAngle", "discAngle", MFnUnitAttribute::kAngle, 0.0 ); uAttr.setStorable( true ); uAttr.setChannelBox( true ); CHECK_MSTATUS( addAttribute( aDiscAngle ) ); CHECK_MSTATUS( attributeAffects( aDiscAngle, aOutput ) ); aDiscOffsetX = nAttr.create( "discOffsetX", "discOffsetX", MFnNumericData::kDouble, 0.0 ); aDiscOffsetY = nAttr.create( "discOffsetY", "discOffsetY", MFnNumericData::kDouble, 0.0 ); aDiscOffsetZ = nAttr.create( "discOffsetZ", "discOffsetZ", MFnNumericData::kDouble, 0.0 ); aDiscOffset = nAttr.create( "discOffset", "discOffset", aDiscOffsetX, aDiscOffsetY, aDiscOffsetZ ); uAttr.setStorable( true ); uAttr.setChannelBox( true ); CHECK_MSTATUS( addAttribute( aDiscOffset ) ); CHECK_MSTATUS( attributeAffects( aDiscOffset, aOutput ) ); aDiscSizeX = nAttr.create( "discSizeX", "discSizeX", MFnNumericData::kDouble, 1.0 ); aDiscSizeY = nAttr.create( "discSizeY", "discSizeY", MFnNumericData::kDouble, 1.0 ); aDiscSizeZ = nAttr.create( "discSizeZ", "discSizeZ", MFnNumericData::kDouble, 1.0 ); aDiscSize = nAttr.create( "discSize", "discSize", aDiscSizeX, aDiscSizeY, aDiscSizeZ ); uAttr.setStorable( true ); uAttr.setChannelBox( true ); CHECK_MSTATUS( addAttribute( aDiscSize ) ); CHECK_MSTATUS( attributeAffects( aDiscSize, aOutput ) ); aDiscActiveColor = nAttr.createColor( "discActiveColor", "discActiveColor" ); nAttr.setStorable( true ); nAttr.setUsedAsColor(true); nAttr.setDefault(1.0f, 1.0f, 1.0f); CHECK_MSTATUS( addAttribute( aDiscActiveColor ) ); CHECK_MSTATUS( attributeAffects( aDiscActiveColor, aOutput ) ); aDiscLeadColor = nAttr.createColor( "discLeadColor", "discLeadColor" ); nAttr.setStorable( true ); nAttr.setUsedAsColor(true); nAttr.setDefault(.263f, 1.0f, .639f); CHECK_MSTATUS( addAttribute( aDiscLeadColor ) ); CHECK_MSTATUS( attributeAffects( aDiscLeadColor, aOutput ) ); aDiscDefaultColor = nAttr.createColor( "discDefaultColor", "discDefaultColor" ); nAttr.setStorable( true ); nAttr.setUsedAsColor(true); nAttr.setDefault(.0f, .016f, .376f); CHECK_MSTATUS( addAttribute( aDiscDefaultColor ) ); CHECK_MSTATUS( attributeAffects( aDiscDefaultColor, aOutput ) ); aDiscFillAlpha = nAttr.create( "discFillAlpha", "discFillAlpha", MFnNumericData::kFloat, 0.1f ); nAttr.setStorable( true ); nAttr.setMin( 0.0f ); nAttr.setMax( 1.0f ); CHECK_MSTATUS( addAttribute( aDiscFillAlpha ) ); CHECK_MSTATUS( attributeAffects( aDiscFillAlpha, aOutput ) ); aDiscLineAlpha = nAttr.create( "discLineAlpha", "discLineAlpha", MFnNumericData::kFloat, 1.0f ); nAttr.setStorable( true ); nAttr.setMin( 0.0f ); nAttr.setMax( 1.0f ); CHECK_MSTATUS( addAttribute( aDiscLineAlpha ) ); CHECK_MSTATUS( attributeAffects( aDiscLineAlpha, aOutput ) ); aArrow = cAttr.create( "arrow", "arrow" ); aInheritMatrix = nAttr.create( "inheritMatrix", "inheritMatrix", MFnNumericData::kBoolean, false ); aInputMesh = tAttr.create( "inputMesh", "inputMesh", MFnData::kMesh ); aAimMatrix = mAttr.create( "aimMatrix", "aimMatrix" ); aStartSize = nAttr.create( "startSize", "startSize", MFnNumericData::kFloat, 0.5f ); aSize = nAttr.create( "size", "size", MFnNumericData::kFloat, 1.0f ); aActiveColor = nAttr.createColor( "activeColor", "activeColor" ); nAttr.setUsedAsColor(true); nAttr.setDefault(1.0f, 1.0f, 1.0f); aLeadColor = nAttr.createColor( "leadColor", "leadColor" ); nAttr.setUsedAsColor(true); nAttr.setDefault(.263f, 1.0f, .639f); aDefaultColor = nAttr.createColor( "defaultColor", "defaultColor" ); nAttr.setUsedAsColor(true); nAttr.setDefault(.0f, .016f, .376f); aFillAlpha = nAttr.create( "fillAlpha", "fillAlpha", MFnNumericData::kFloat, 0.1f ); aLineAlpha = nAttr.create( "lineAlpha", "lineAlpha", MFnNumericData::kFloat, 1.0f ); aOffsetX = nAttr.create( "offsetX", "offsetX", MFnNumericData::kDouble, 0.0 ); aOffsetY = nAttr.create( "offsetY", "offsetY", MFnNumericData::kDouble, 0.0 ); aOffsetZ = nAttr.create( "offsetZ", "offsetZ", MFnNumericData::kDouble, 0.0 ); aOffset = nAttr.create( "offset", "offset", aOffsetX, aOffsetY, aOffsetZ ); cAttr.addChild( aInheritMatrix ); cAttr.addChild( aAimMatrix ); cAttr.addChild( aInputMesh ); cAttr.addChild( aStartSize ); cAttr.addChild( aSize ); cAttr.addChild( aActiveColor ); cAttr.addChild( aLeadColor ); cAttr.addChild( aDefaultColor ); cAttr.addChild( aFillAlpha ); cAttr.addChild( aLineAlpha ); cAttr.addChild( aOffset ); cAttr.setArray( true ); cAttr.setStorable( true ); CHECK_MSTATUS( addAttribute( aArrow ) ); CHECK_MSTATUS( attributeAffects( aArrow, aOutput ) ); return MS::kSuccess; }
MStatus n_tentacle::initialize() { MFnNumericAttribute numericAttr; MFnMatrixAttribute matrixAttr; MFnTypedAttribute typedAttr; MFnUnitAttribute unitAttribute; MFnEnumAttribute enumAttr; MStatus stat; stretch = numericAttr.create("stretch", "st", MFnNumericData::kDouble, 0.0); numericAttr.setMin(0.0); numericAttr.setMax(1.0); globalScale = numericAttr.create("globalScale", "gs", MFnNumericData::kDouble, 1.0); numericAttr.setMin(0.00001); numericAttr.setMax(10.0); iniLength = numericAttr.create("iniLength", "iln", MFnNumericData::kDouble, 0.01); parameter = numericAttr.create("parameter", "prm", MFnNumericData::kDouble, 0.0); numericAttr.setArray(true); blendRot = numericAttr.create("blendRot", "blr", MFnNumericData::kDouble, 0.0); numericAttr.setArray(true); interval = numericAttr.create("interval", "itv", MFnNumericData::kInt, 0); numericAttr.setArray(true); matrix = matrixAttr.create("matrix", "mtx"); matrixAttr.setArray(true); matrixAttr.setHidden(true); curve = typedAttr.create("curve", "crv", MFnData::kNurbsCurve); outTranslate = numericAttr.create("outTranslate", "ot", MFnNumericData::k3Double); numericAttr.setArray(true); numericAttr.setHidden(true); numericAttr.setUsesArrayDataBuilder(true); numericAttr.setHidden(true); outRotateX = unitAttribute.create("outRotateX", "orx", MFnUnitAttribute::kAngle); outRotateY = unitAttribute.create("outRotateY", "ory", MFnUnitAttribute::kAngle); outRotateZ = unitAttribute.create("outRotateZ", "orz", MFnUnitAttribute::kAngle); outRotate = numericAttr.create("outRotate", "or",outRotateX, outRotateY, outRotateZ); numericAttr.setArray(true); numericAttr.setHidden(true); numericAttr.setUsesArrayDataBuilder(true); numericAttr.setHidden(true); tangentAxis = enumAttr.create("tangentAxis", "tga", 1); enumAttr.addField("X", 0); enumAttr.addField("Y", 1); enumAttr.addField("Z", 2); enumAttr.addField("negativeX", 3); enumAttr.addField("negativeY", 4); enumAttr.addField("negativeZ", 5); // Add the attributes we have created to the node // stat = addAttribute( parameter ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( blendRot ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( interval ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( stretch ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( globalScale ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( iniLength ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( matrix ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( curve ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( outTranslate ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( outRotate ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( tangentAxis ); if (!stat) { stat.perror("addAttribute"); return stat;} attributeAffects( parameter, outTranslate ); attributeAffects( blendRot, outTranslate ); attributeAffects( interval, outTranslate ); attributeAffects( stretch, outTranslate ); attributeAffects( globalScale, outTranslate ); attributeAffects( iniLength, outTranslate ); attributeAffects( matrix, outTranslate ); attributeAffects( curve, outTranslate ); attributeAffects( tangentAxis, outTranslate ); attributeAffects( parameter, outRotate ); attributeAffects( blendRot, outRotate ); attributeAffects( interval, outRotate ); attributeAffects( stretch, outRotate ); attributeAffects( globalScale, outRotate ); attributeAffects( iniLength, outRotate ); attributeAffects( matrix, outRotate ); attributeAffects( curve, outRotate ); attributeAffects( tangentAxis, outRotate ); attributeAffects( parameter, outRotateX ); attributeAffects( blendRot, outRotateX ); attributeAffects( interval, outRotateX ); attributeAffects( stretch, outRotateX ); attributeAffects( globalScale, outRotateX ); attributeAffects( iniLength, outRotateX ); attributeAffects( matrix, outRotateX ); attributeAffects( curve, outRotateX ); attributeAffects( tangentAxis, outRotateX ); attributeAffects( parameter, outRotateY ); attributeAffects( blendRot, outRotateY ); attributeAffects( interval, outRotateY ); attributeAffects( stretch, outRotateY ); attributeAffects( globalScale, outRotateY ); attributeAffects( iniLength, outRotateY ); attributeAffects( matrix, outRotateY ); attributeAffects( curve, outRotateY ); attributeAffects( tangentAxis, outRotateY ); attributeAffects( parameter, outRotateZ ); attributeAffects( blendRot, outRotateZ ); attributeAffects( interval, outRotateZ ); attributeAffects( stretch, outRotateZ ); attributeAffects( globalScale, outRotateZ ); attributeAffects( iniLength, outRotateZ ); attributeAffects( matrix, outRotateZ ); attributeAffects( curve, outRotateZ ); attributeAffects( tangentAxis, outRotateZ ); return MS::kSuccess; }
MStatus AlembicNode::initialize() { MStatus status; MFnUnitAttribute uAttr; MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MFnGenericAttribute gAttr; MFnEnumAttribute eAttr; // add the input attributes: time, file, sequence time mTimeAttr = uAttr.create("time", "tm", MFnUnitAttribute::kTime, 0.0); status = uAttr.setStorable(true); status = addAttribute(mTimeAttr); // input file name MFnStringData fileFnStringData; MObject fileNameDefaultObject = fileFnStringData.create(""); mAbcFileNameAttr = tAttr.create("abc_File", "fn", MFnData::kString, fileNameDefaultObject); status = tAttr.setStorable(true); status = tAttr.setUsedAsFilename(true); status = addAttribute(mAbcFileNameAttr); // playback speed mSpeedAttr = nAttr.create("speed", "sp", MFnNumericData::kDouble, 1.0, &status); status = nAttr.setWritable(true); status = nAttr.setStorable(true); status = nAttr.setKeyable(true); status = addAttribute(mSpeedAttr); // frame offset mOffsetAttr = nAttr.create("offset", "of", MFnNumericData::kDouble, 0, &status); status = nAttr.setWritable(true); status = nAttr.setStorable(true); status = nAttr.setKeyable(true); status = addAttribute(mOffsetAttr); // cycle type mCycleTypeAttr = eAttr.create("cycleType", "ct", 0, &status ); status = eAttr.addField("Hold", PLAYTYPE_HOLD); status = eAttr.addField("Loop", PLAYTYPE_LOOP); status = eAttr.addField("Reverse", PLAYTYPE_REVERSE); status = eAttr.addField("Bounce", PLAYTYPE_BOUNCE); status = eAttr.setWritable(true); status = eAttr.setStorable(true); status = eAttr.setKeyable(true); status = addAttribute(mCycleTypeAttr); // Regex Filter // This is a hidden variable to preserve a regexIncludefilter string // into a .ma file. mIncludeFilterAttr = tAttr.create("regexIncludeFilter", "ift", MFnData::kString); status = tAttr.setStorable(true); status = tAttr.setHidden(true); status = addAttribute(mIncludeFilterAttr); // Regex Filter // This is a hidden variable to preserve a regexExcludefilter string // into a .ma file. mExcludeFilterAttr = tAttr.create("regexExcludeFilter", "eft", MFnData::kString); status = tAttr.setStorable(true); status = tAttr.setHidden(true); status = addAttribute(mExcludeFilterAttr); // sequence min and max in frames mStartFrameAttr = nAttr.create("startFrame", "sf", MFnNumericData::kDouble, 0, &status); status = nAttr.setWritable(false); status = nAttr.setStorable(true); status = addAttribute(mStartFrameAttr); mEndFrameAttr = nAttr.create("endFrame", "ef", MFnNumericData::kDouble, 0, &status); status = nAttr.setWritable(false); status = nAttr.setStorable(true); status = addAttribute(mEndFrameAttr); // add the output attributes // sampled subD mesh MFnMeshData fnMeshData; MObject meshDefaultObject = fnMeshData.create(&status); mOutSubDArrayAttr = tAttr.create("outSubDMesh", "osubd", MFnData::kMesh, meshDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutSubDArrayAttr); // sampled poly mesh mOutPolyArrayAttr = tAttr.create("outPolyMesh", "opoly", MFnData::kMesh, meshDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutPolyArrayAttr); // sampled nurbs surface MFnNurbsSurfaceData fnNSData; MObject nsDefaultObject = fnNSData.create(&status); mOutNurbsSurfaceArrayAttr = tAttr.create("outNSurface", "ons", MFnData::kNurbsSurface, nsDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutNurbsSurfaceArrayAttr); // sampled nurbs curve group MFnNurbsCurveData fnNCData; MObject ncDefaultObject = fnNCData.create(&status); mOutNurbsCurveGrpArrayAttr = tAttr.create("outNCurveGrp", "onc", MFnData::kNurbsCurve, ncDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutNurbsCurveGrpArrayAttr); // sampled locator mOutLocatorPosScaleArrayAttr = nAttr.create("outLoc", "olo", MFnNumericData::kDouble, 0.0, &status); status = nAttr.setStorable(false); status = nAttr.setWritable(false); status = nAttr.setArray(true); status = nAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutLocatorPosScaleArrayAttr); // sampled transform operations mOutTransOpArrayAttr = nAttr.create("transOp", "to", MFnNumericData::kDouble, 0.0, &status); status = nAttr.setStorable(false); status = nAttr.setWritable(false); status = nAttr.setArray(true); status = nAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutTransOpArrayAttr); // sampled camera // assume the boolean variables cannot be keyed mOutCameraArrayAttr = nAttr.create("outCamera", "ocam", MFnNumericData::kDouble, 0.0, &status); status = nAttr.setStorable(false); status = nAttr.setWritable(false); status = nAttr.setArray(true); status = nAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutCameraArrayAttr); // sampled custom-attributes mOutPropArrayAttr = gAttr.create("prop", "pr", &status); status = gAttr.addNumericDataAccept(MFnNumericData::kBoolean); status = gAttr.addNumericDataAccept(MFnNumericData::kByte); status = gAttr.addNumericDataAccept(MFnNumericData::kShort); status = gAttr.addNumericDataAccept(MFnNumericData::k2Short); status = gAttr.addNumericDataAccept(MFnNumericData::k3Short); status = gAttr.addNumericDataAccept(MFnNumericData::kInt); status = gAttr.addNumericDataAccept(MFnNumericData::k2Int); status = gAttr.addNumericDataAccept(MFnNumericData::k3Int); status = gAttr.addNumericDataAccept(MFnNumericData::kFloat); status = gAttr.addNumericDataAccept(MFnNumericData::k2Float); status = gAttr.addNumericDataAccept(MFnNumericData::k3Float); status = gAttr.addNumericDataAccept(MFnNumericData::kDouble); status = gAttr.addNumericDataAccept(MFnNumericData::k2Double); status = gAttr.addNumericDataAccept(MFnNumericData::k3Double); status = gAttr.addNumericDataAccept(MFnNumericData::k4Double); status = gAttr.addDataAccept(MFnData::kString); status = gAttr.addDataAccept(MFnData::kIntArray); status = gAttr.addDataAccept(MFnData::kDoubleArray); status = gAttr.addDataAccept(MFnData::kVectorArray); status = gAttr.addDataAccept(MFnData::kPointArray); status = gAttr.setWritable(false); status = gAttr.setKeyable(false); status = gAttr.setArray(true); status = gAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutPropArrayAttr); // set up affection relationships status = attributeAffects(mTimeAttr, mOutSubDArrayAttr); status = attributeAffects(mTimeAttr, mOutPolyArrayAttr); status = attributeAffects(mTimeAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mTimeAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mTimeAttr, mOutTransOpArrayAttr); status = attributeAffects(mTimeAttr, mOutCameraArrayAttr); status = attributeAffects(mTimeAttr, mOutPropArrayAttr); status = attributeAffects(mTimeAttr, mOutLocatorPosScaleArrayAttr); status = attributeAffects(mSpeedAttr, mOutSubDArrayAttr); status = attributeAffects(mSpeedAttr, mOutPolyArrayAttr); status = attributeAffects(mSpeedAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mSpeedAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mSpeedAttr, mOutTransOpArrayAttr); status = attributeAffects(mSpeedAttr, mOutCameraArrayAttr); status = attributeAffects(mSpeedAttr, mOutPropArrayAttr); status = attributeAffects(mSpeedAttr, mOutLocatorPosScaleArrayAttr); status = attributeAffects(mOffsetAttr, mOutSubDArrayAttr); status = attributeAffects(mOffsetAttr, mOutPolyArrayAttr); status = attributeAffects(mOffsetAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mOffsetAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mOffsetAttr, mOutTransOpArrayAttr); status = attributeAffects(mOffsetAttr, mOutCameraArrayAttr); status = attributeAffects(mOffsetAttr, mOutPropArrayAttr); status = attributeAffects(mOffsetAttr, mOutLocatorPosScaleArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutSubDArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutPolyArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutTransOpArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutCameraArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutPropArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutLocatorPosScaleArrayAttr); MGlobal::executeCommand( UITemplateMELScriptStr ); return status; }
MStatus latticeNoiseNode::initialize() { MFnUnitAttribute unitAttr; MFnTypedAttribute typedAttr; MFnNumericAttribute numAttr; MStatus stat; input = typedAttr.create( "input", "in", MFnData::kLattice, &stat ); if ( !stat ) { stat.perror("ERROR creating latticeNoiseNode input lattice attribute"); return stat; } amplitude = numAttr.create( "amplitude", "amp", MFnNumericData::kFloat, DEF_AMPLITUDE, &stat ); if ( !stat ) { stat.perror("ERROR creating latticeNoiseNode amplitude attribute"); return stat; } frequency = numAttr.create( "frequency", "fq", MFnNumericData::kFloat, DEF_FREQ, &stat ); if ( !stat ) { stat.perror("ERROR creating latticeNoiseNode frequency attribute"); return stat; } time = unitAttr.create( "time", "tm", MFnUnitAttribute::kTime, 0.0, &stat ); if ( !stat ) { stat.perror("ERROR creating latticeNoiseNode time attribute"); return stat; } output = typedAttr.create( "output", "out", MFnData::kLattice, &stat ); if ( !stat ) { stat.perror("ERROR creating latticeNoiseNode output attribute"); return stat; } typedAttr.setWritable(false); stat = addAttribute( input ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( amplitude ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( frequency ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( time ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( output ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = attributeAffects( input, output ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( amplitude, output ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( frequency, output ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( time, output ); if (!stat) { stat.perror("attributeAffects"); return stat;} return MS::kSuccess; }
MStatus dgTransform::initialize() { MStatus status; MFnNumericAttribute nAttr; MFnMatrixAttribute mAttr; MFnUnitAttribute uAttr; aTranslateX = nAttr.create( "translateX", "tx", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true ); aTranslateY = nAttr.create( "translateY", "ty", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true ); aTranslateZ = nAttr.create( "translateZ", "tz", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true ); aTranslate = nAttr.create( "translate", "t", aTranslateX, aTranslateY, aTranslateZ ); nAttr.setStorable( true ); status = addAttribute( aTranslate ); CHECK_MSTATUS_AND_RETURN_IT( status ); aRotateX = uAttr.create( "rotateX", "rx", MFnUnitAttribute::kAngle, 0.0 ); uAttr.setKeyable( true ); aRotateY = uAttr.create( "rotateY", "ry", MFnUnitAttribute::kAngle, 0.0 ); uAttr.setKeyable( true ); aRotateZ = uAttr.create( "rotateZ", "rz", MFnUnitAttribute::kAngle, 0.0 ); uAttr.setKeyable( true ); aRotate = nAttr.create( "rotate", "r", aRotateX, aRotateY, aRotateZ ); nAttr.setStorable( true ); status = addAttribute( aRotate ); CHECK_MSTATUS_AND_RETURN_IT( status ); aScaleX = nAttr.create( "scaleX", "sx", MFnNumericData::kDouble, 0.0 ); nAttr.setKeyable( true ); aScaleY = nAttr.create( "scaleY", "sy", MFnNumericData::kDouble, 0.0 ); nAttr.setKeyable( true ); aScaleZ = nAttr.create( "scaleZ", "sz", MFnNumericData::kDouble, 0.0 ); nAttr.setKeyable( true ); aScale = nAttr.create( "scale", "s", aScaleX, aScaleY, aScaleZ ); nAttr.setStorable( true ); status = addAttribute( aScale ); CHECK_MSTATUS_AND_RETURN_IT( status ); aShearX = nAttr.create( "shearX", "shx", MFnNumericData::kDouble, 0.0 ); aShearY = nAttr.create( "shearY", "shy", MFnNumericData::kDouble, 0.0 ); aShearZ = nAttr.create( "shearZ", "shz", MFnNumericData::kDouble, 0.0 ); aShear = nAttr.create( "shear", "sh", aShearX, aShearY, aShearZ ); nAttr.setStorable( true ); status = addAttribute( aShear ); CHECK_MSTATUS_AND_RETURN_IT( status ); aJointOrientX = uAttr.create( "jointOrientX", "jox", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true ); aJointOrientY = uAttr.create( "jointOrientY", "joy", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true ); aJointOrientZ = uAttr.create( "jointOrientZ", "joz", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true ); aJointOrient = nAttr.create( "jointOrient", "jo", aJointOrientX, aJointOrientY, aJointOrientZ ); nAttr.setStorable( true ); status = addAttribute( aJointOrient ); CHECK_MSTATUS_AND_RETURN_IT( status ); aInputTranslateX = nAttr.create( "inputTranslateX", "itx", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true ); aInputTranslateY = nAttr.create( "inputTranslateY", "ity", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true ); aInputTranslateZ = nAttr.create( "inputTranslateZ", "itz", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true ); aInputTranslate = nAttr.create( "inputTranslate", "it", aInputTranslateX, aInputTranslateY, aInputTranslateZ ); nAttr.setStorable( true ); status = addAttribute( aInputTranslate ); CHECK_MSTATUS_AND_RETURN_IT( status ); aInputRotateX = uAttr.create( "inputRotateX", "irx", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true ); aInputRotateY = uAttr.create( "inputRotateY", "iry", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true ); aInputRotateZ = uAttr.create( "inputRotateZ", "irz", MFnUnitAttribute::kAngle, 0.0 );uAttr.setKeyable( true ); aInputRotate = nAttr.create( "inputRotate", "ir", aInputRotateX, aInputRotateY, aInputRotateZ ); nAttr.setStorable( true ); status = addAttribute( aInputRotate ); CHECK_MSTATUS_AND_RETURN_IT( status ); aInputScaleX = nAttr.create( "inputScaleX", "isx", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true ); aInputScaleY = nAttr.create( "inputScaleY", "isy", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true ); aInputScaleZ = nAttr.create( "inputScaleZ", "isz", MFnNumericData::kDouble, 0.0 );nAttr.setKeyable( true ); aInputScale = nAttr.create( "inputScale", "is", aInputScaleX, aInputScaleY, aInputScaleZ ); nAttr.setStorable( true ); status = addAttribute( aInputScale ); CHECK_MSTATUS_AND_RETURN_IT( status ); aInputShearX = nAttr.create( "inputShearX", "ishx", MFnNumericData::kDouble, 0.0 ); aInputShearY = nAttr.create( "inputShearY", "ishy", MFnNumericData::kDouble, 0.0 ); aInputShearZ = nAttr.create( "inputShearZ", "ishz", MFnNumericData::kDouble, 0.0 ); aInputShear = nAttr.create( "inputShear", "ish", aInputShearX, aInputShearY, aInputShearZ ); nAttr.setStorable( true ); status = addAttribute( aInputShear ); CHECK_MSTATUS_AND_RETURN_IT( status ); MObject* affectedAttrs[6]; aMatrix = mAttr.create( "matrix", "m" ); nAttr.setStorable( false ); status = addAttribute( aMatrix ); CHECK_MSTATUS_AND_RETURN_IT( status ); affectedAttrs[0] = &aMatrix; aInverseMatrix = mAttr.create( "inverseMatrix", "im" ); nAttr.setStorable( false ); status = addAttribute( aInverseMatrix ); CHECK_MSTATUS_AND_RETURN_IT( status ); affectedAttrs[1] = &aInverseMatrix; aWorldMatrix = mAttr.create( "worldMatrix", "wm" ); nAttr.setStorable( false ); status = addAttribute( aWorldMatrix ); CHECK_MSTATUS_AND_RETURN_IT( status ); affectedAttrs[2] = &aWorldMatrix; aWorldInverseMatrix = mAttr.create( "worldInverseMatrix", "wim" ); nAttr.setStorable( false ); status = addAttribute( aWorldInverseMatrix ); CHECK_MSTATUS_AND_RETURN_IT( status ); affectedAttrs[3] = &aWorldInverseMatrix; aParentMatrix = mAttr.create( "parentMatrix", "pm" ); nAttr.setStorable( false ); status = addAttribute( aParentMatrix ); CHECK_MSTATUS_AND_RETURN_IT( status ); affectedAttrs[4] = &aParentMatrix; aParentInverseMatrix = mAttr.create( "parentInverseMatrix", "pim" ); nAttr.setStorable( false ); status = addAttribute( aParentInverseMatrix ); CHECK_MSTATUS_AND_RETURN_IT( status ); affectedAttrs[5] = &aParentInverseMatrix; status = attributeAffectsArray( aTranslate, affectedAttrs ); CHECK_MSTATUS_AND_RETURN_IT( status ); status = attributeAffectsArray( aRotate, affectedAttrs ); CHECK_MSTATUS_AND_RETURN_IT( status ); status = attributeAffectsArray( aScale, affectedAttrs ); CHECK_MSTATUS_AND_RETURN_IT( status ); status = attributeAffectsArray( aShear, affectedAttrs ); CHECK_MSTATUS_AND_RETURN_IT( status ); status = attributeAffectsArray( aJointOrient, affectedAttrs ); CHECK_MSTATUS_AND_RETURN_IT( status ); status = attributeAffectsArray( aInputTranslate, affectedAttrs ); CHECK_MSTATUS_AND_RETURN_IT( status ); status = attributeAffectsArray( aInputRotate, affectedAttrs ); CHECK_MSTATUS_AND_RETURN_IT( status ); status = attributeAffectsArray( aInputScale, affectedAttrs ); CHECK_MSTATUS_AND_RETURN_IT( status ); status = attributeAffectsArray( aInputShear, affectedAttrs ); CHECK_MSTATUS_AND_RETURN_IT( status ); return MS::kSuccess; }
MStatus SurfaceAttach::initialize() { MFnTypedAttribute fnTypeAttr; MFnNumericAttribute fnNumAttr; MFnUnitAttribute fnUnitAttr; MFnCompoundAttribute fnCompoundAttr; MFnEnumAttribute fnEnumAttr; MFnMatrixAttribute fnMatAttr; MStatus stat; // Input Attributes direction = fnEnumAttr.create("direction", "dire", 0); fnEnumAttr.addField("U", 0); fnEnumAttr.addField("V", 1); surface = fnTypeAttr.create("surface", "surface", MFnData::kNurbsSurface); parentInverse = fnMatAttr.create("parentInverse", "ps", MFnMatrixAttribute::kDouble); fnMatAttr.setKeyable(true); samples = fnNumAttr.create("samples", "samples", MFnNumericData::kInt, 1000); fnNumAttr.setKeyable(true); fnNumAttr.setMin(1.0); staticLength = fnNumAttr.create("staticLength", "staticLength", MFnNumericData::kDouble, 0.0001); fnNumAttr.setKeyable(true); fnNumAttr.setMin(0.0001); offset = fnNumAttr.create("offset", "offset", MFnNumericData::kDouble, 0.0); fnNumAttr.setKeyable(true); genus = fnEnumAttr.create("type", "type", 0); fnEnumAttr.addField("Parametric", 0); fnEnumAttr.addField("Percentage", 1); fnEnumAttr.addField("FixedLength", 2); fnEnumAttr.setKeyable(true); reverse = fnNumAttr.create("reverse", "reverse", MFnNumericData::kBoolean, false); fnNumAttr.setKeyable(true); inU = fnNumAttr.create("inU", "U", MFnNumericData::kDouble, 0.5); fnNumAttr.setKeyable(true); inV = fnNumAttr.create("inV", "V", MFnNumericData::kDouble, 0.5); fnNumAttr.setKeyable(true); inUV = fnCompoundAttr.create("inUV", "inUV"); fnCompoundAttr.setKeyable(true); fnCompoundAttr.setArray(true); fnCompoundAttr.addChild(inU); fnCompoundAttr.addChild(inV); fnCompoundAttr.setUsesArrayDataBuilder(true); // Output Attributes translateX = fnNumAttr.create("translateX", "translateX", MFnNumericData::kDouble); fnNumAttr.setWritable(false); fnNumAttr.setStorable(false); translateY = fnNumAttr.create("translateY", "translateY", MFnNumericData::kDouble); fnNumAttr.setWritable(false); fnNumAttr.setStorable(false); translateZ = fnNumAttr.create("translateZ", "translateZ", MFnNumericData::kDouble); fnNumAttr.setWritable(false); fnNumAttr.setStorable(false); translate = fnNumAttr.create("translate", "translate", translateX, translateY, translateZ); fnNumAttr.setWritable(false); fnNumAttr.setStorable(false); rotateX = fnUnitAttr.create("rotateX", "rotateX", MFnUnitAttribute::kAngle); fnUnitAttr.setWritable(false); fnUnitAttr.setStorable(false); rotateY = fnUnitAttr.create("rotateY", "rotateY", MFnUnitAttribute::kAngle); fnUnitAttr.setWritable(false); fnUnitAttr.setStorable(false); rotateZ = fnUnitAttr.create("rotateZ", "rotateZ", MFnUnitAttribute::kAngle); fnUnitAttr.setWritable(false); fnUnitAttr.setStorable(false); rotate = fnNumAttr.create("rotate", "rotate", rotateX, rotateY, rotateZ); fnNumAttr.setWritable(false); out = fnCompoundAttr.create("out", "out"); fnCompoundAttr.setWritable(false); fnCompoundAttr.setArray(true); fnCompoundAttr.addChild(translate); fnCompoundAttr.addChild(rotate); fnCompoundAttr.setUsesArrayDataBuilder(true); // These aren't going to fail, give me a break :) // Add Attributes SurfaceAttach::addAttribute(direction); SurfaceAttach::addAttribute(surface); SurfaceAttach::addAttribute(parentInverse); SurfaceAttach::addAttribute(samples); SurfaceAttach::addAttribute(staticLength); SurfaceAttach::addAttribute(offset); SurfaceAttach::addAttribute(genus); SurfaceAttach::addAttribute(reverse); SurfaceAttach::addAttribute(inUV); SurfaceAttach::addAttribute(out); // Attribute Affects SurfaceAttach::attributeAffects(direction, translate); SurfaceAttach::attributeAffects(surface, translate); SurfaceAttach::attributeAffects(parentInverse, translate); SurfaceAttach::attributeAffects(staticLength, translate); SurfaceAttach::attributeAffects(samples, translate); SurfaceAttach::attributeAffects(offset, translate); SurfaceAttach::attributeAffects(genus, translate); SurfaceAttach::attributeAffects(reverse, translate); SurfaceAttach::attributeAffects(inU, translate); SurfaceAttach::attributeAffects(inV, translate); SurfaceAttach::attributeAffects(direction, rotate); SurfaceAttach::attributeAffects(surface, rotate); SurfaceAttach::attributeAffects(parentInverse, rotate); SurfaceAttach::attributeAffects(staticLength, rotate); SurfaceAttach::attributeAffects(samples, rotate); SurfaceAttach::attributeAffects(offset, rotate); SurfaceAttach::attributeAffects(genus, rotate); SurfaceAttach::attributeAffects(reverse, rotate); SurfaceAttach::attributeAffects(inU, rotate); SurfaceAttach::attributeAffects(inV, rotate); return MS::kSuccess; }
MStatus sgHair_controlJoint::initialize() { MStatus status; MFnTypedAttribute tAttr; MFnMatrixAttribute mAttr; MFnMessageAttribute msgAttr; MFnNumericAttribute nAttr; MFnUnitAttribute uAttr; MFnCompoundAttribute cAttr; aInputBaseCurve = tAttr.create( "inputBaseCurve", "inputBaseCurve", MFnData::kNurbsCurve ); tAttr.setStorable( true ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aInputBaseCurve ) ); aInputBaseCurveMatrix = mAttr.create( "inputBaseCurveMatrix", "inputBaseCurveMatrix" ); mAttr.setStorable( true ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aInputBaseCurveMatrix ) ); aJointParentBaseMatrix = mAttr.create( "jointParentBaseMatrix", "jointParentBaseMatrix" ); mAttr.setStorable( true ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aJointParentBaseMatrix ) ); aGravityParam = nAttr.create( "gravityParam", "gravityParam", MFnNumericData::kDouble, 0.0 ); nAttr.setMin( 0.0 ); nAttr.setStorable( true ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aGravityParam ) ); aGravityRange = nAttr.create( "gravityRange", "gravityRange", MFnNumericData::kDouble, 0.0 ); nAttr.setMin( 0.0 ); nAttr.setStorable( true ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aGravityRange ) ); aGravityWeight = nAttr.create( "gravityWeight", "gravityWeight", MFnNumericData::kDouble, 0.0 ); nAttr.setMin( 0.0 ); nAttr.setMax( 1.0 ); nAttr.setStorable( true ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aGravityWeight ) ); aGravityOffsetMatrix = mAttr.create( "gravityOffsetMatrix", "gravityOffsetMatrix" ); mAttr.setStorable( true ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aGravityOffsetMatrix ) ); aStaticRotation = nAttr.create( "staticRotation", "staticRotation", MFnNumericData::kBoolean, false ); nAttr.setStorable( true ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aStaticRotation ) ); aOutput = cAttr.create( "output", "output" ); aOutTransX = nAttr.create( "outTransX", "otx", MFnNumericData::kDouble ); aOutTransY = nAttr.create( "outTransY", "oty", MFnNumericData::kDouble ); aOutTransZ = nAttr.create( "outTransZ", "otz", MFnNumericData::kDouble ); aOutTrans = nAttr.create( "outTrans", "ot", aOutTransX, aOutTransY, aOutTransZ ); aOutOrientX = uAttr.create( "outRotateX", "orx", MFnUnitAttribute::kAngle, 0.0 ); aOutOrientY = uAttr.create( "outRotateY", "ory", MFnUnitAttribute::kAngle, 0.0 ); aOutOrientZ = uAttr.create( "outRotateZ", "orz", MFnUnitAttribute::kAngle, 0.0 ); aOutOrient = nAttr.create( "outRotate", "outRotate", aOutOrientX, aOutOrientY, aOutOrientZ ); cAttr.addChild( aOutTrans ); cAttr.addChild( aOutOrient ); cAttr.setStorable( false ); cAttr.setArray( true ); cAttr.setUsesArrayDataBuilder( true ); CHECK_MSTATUS_AND_RETURN_IT( addAttribute( aOutput ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aGravityParam, aOutput ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aGravityRange, aOutput ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aGravityWeight, aOutput ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aJointParentBaseMatrix, aOutput ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aGravityOffsetMatrix, aOutput ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aInputBaseCurve, aOutput ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aInputBaseCurveMatrix, aOutput ) ); CHECK_MSTATUS_AND_RETURN_IT( attributeAffects( aStaticRotation, aOutput ) ); return MS::kSuccess; }
// // Initialize the node // MStatus jhMeshBlur::initialize() { // attribute types MFnUnitAttribute unitAttr; MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; aOldMeshData = tAttr.create("oldMesh","om",MFnData::kPointArray); tAttr.setArray(true); tAttr.setHidden(true); tAttr.setIndexMatters(true); // create the attributes aStrength = nAttr.create( "Strength", "str", MFnNumericData::kFloat,1.0); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setMax(1.0); nAttr.setMin(0.0); aTreshhold = nAttr.create( "Treshold", "tres", MFnNumericData::kFloat,0.0); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setMin(0.0); aShapeFactor = nAttr.create( "ShapeFactor", "shapef", MFnNumericData::kFloat,0.5); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setMax(1.0); nAttr.setMin(0.0); aTweakBlur = nAttr.create( "TweakBlur", "tweak", MFnNumericData::kBoolean,false); nAttr.setKeyable(false); nAttr.setChannelBox(true); aQuadInterp = nAttr.create( "QuadInterpolation", "qi", MFnNumericData::kBoolean,true); nAttr.setKeyable(false); nAttr.setChannelBox(true); aInterpPower = nAttr.create( "InterpolationPower", "interp", MFnNumericData::kDouble, 0.75); nAttr.setKeyable(true); nAttr.setMax(1.0); nAttr.setMin(0.0); aTime = unitAttr.create( "time", "tm", MFnUnitAttribute::kTime, 1.0 ); unitAttr.setStorable(true); unitAttr.setCached(true); unitAttr.setReadable(true); unitAttr.setWritable(true); unitAttr.setAffectsAppearance(true); unitAttr.setAffectsWorldSpace(true); // Make the attributes visible to the user addAttribute( aStrength); addAttribute( aTreshhold); addAttribute( aTime); addAttribute( aTweakBlur); addAttribute( aQuadInterp); addAttribute( aInterpPower); addAttribute( aOldMeshData); // Make sure when an attribute changes, the node updates attributeAffects( aTime, outputGeom ); attributeAffects( aStrength, outputGeom ); attributeAffects( aTreshhold, outputGeom ); attributeAffects( aQuadInterp, outputGeom ); attributeAffects( aInterpPower, outputGeom ); // Not implented yet, but make the weights paintable :) MGlobal::executeCommand("makePaintable -attrType multiFloat -sm deformer jhMeshBlur weights;"); return MStatus::kSuccess; }
MStatus LSSolverNode::initialize() { MFnNumericAttribute nAttr; MFnUnitAttribute uAttr; MFnTypedAttribute tAttr; MFnEnumAttribute eAttr; MFnMatrixAttribute mAttr; tetWorldMatrix = mAttr.create("tet_world_matrix","twm",MFnMatrixAttribute::kDouble,&returnStatus); McheckErr(returnStatus, "ERROR creating LSTetgenNode worldMatrix attribute\n"); MAKE_INPUT(mAttr); mAttr.setHidden(true); restShape = tAttr.create("restShape", "rs", MFnMeshData::kMesh, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode restShape attribute\n"); MAKE_INPUT(tAttr); restElements = tAttr.create("restElements", "re", MFnData::kIntArray, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode restShape attribute\n"); MAKE_INPUT(tAttr); restVertices = tAttr.create("restVertices", "rv", MFnData::kDoubleArray, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode restShape attribute\n"); MAKE_INPUT(tAttr); selectedConstraintVerts = tAttr.create("selectedConstraintVerts", "scv", MFnData::kIntArray, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode selectedConstraintVerts attribute\n"); MAKE_INPUT(tAttr); selectedForceVerts = tAttr.create("selectedForceVerts", "sfv", MFnData::kIntArray, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode selectedForceVerts attribute\n"); MAKE_INPUT(tAttr); time = uAttr.create("time", "t", MFnUnitAttribute::kTime,0.0, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode time attribute\n"); MAKE_INPUT(uAttr); deformed = tAttr.create("deformed", "d", MFnMeshData::kMesh, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode deformed attribute\n"); MAKE_OUTPUT(tAttr); poissonRatio = nAttr.create("poissonRatio", "pr", MFnNumericData::kDouble, 0.45, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode poisson ratio\n"); MAKE_INPUT(nAttr); nAttr.setMax(0.45); nAttr.setMin(0); youngsModulus = nAttr.create("youngsModulus", "ym", MFnNumericData::kDouble, 90000000000, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode youngsModulus\n"); MAKE_INPUT(nAttr); //nAttr.setMax(50000); //nAttr.setMin(1); objectDensity = nAttr.create("density", "objd", MFnNumericData::kDouble, 1000, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode objectDensity\n"); MAKE_INPUT(nAttr); nAttr.setMax(10000); nAttr.setMin(1); friction = nAttr.create("friction", "f", MFnNumericData::kDouble, 0.98, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode friction\n"); MAKE_INPUT(nAttr); nAttr.setMax(1); nAttr.setMin(0); restitution = nAttr.create("restitution", "r", MFnNumericData::kDouble, 0.4, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode restitution\n"); MAKE_INPUT(nAttr); nAttr.setMax(1); nAttr.setMin(0); damping = nAttr.create("damping", "dmp", MFnNumericData::kDouble, 0.0, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode damping\n"); MAKE_INPUT(nAttr); nAttr.setMax(1); nAttr.setMin(0); userSuppliedDt = nAttr.create("timeStep","ts",MFnNumericData::kDouble,0.01, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode userSuppliedDt\n"); MAKE_INPUT(nAttr); nAttr.setMax(1); nAttr.setMin(0.00001); forceApplicationTime = nAttr.create("forceApplicationTime", "fat", MFnNumericData::kInt, 50, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode forceApplicationTime ratio\n"); MAKE_INPUT(nAttr); forceReleasedTime = nAttr.create("forceReleasedTime", "frt", MFnNumericData::kInt, 100, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode forceReleasedTime ratio\n"); MAKE_INPUT(nAttr); forceIncrementTime = nAttr.create("forceIncrementTime", "fit", MFnNumericData::kInt, 10, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode forceIncrementTime ratio\n"); MAKE_INPUT(nAttr); forceStartTime = nAttr.create("forceStartTime", "fst", MFnNumericData::kInt,100, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode forceStartTime\n"); MAKE_INPUT(nAttr); forceStopTime = nAttr.create("forceStopTime", "fet", MFnNumericData::kInt, 200, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode forceStopTime\n"); MAKE_INPUT(nAttr); forceMagnitude = nAttr.create("forceMagnitude", "fm", MFnNumericData::kDouble, 10.0, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode forceIdleTime ratio\n"); MAKE_INPUT(nAttr); forceDirection = nAttr.create("forceDirection", "fd", MFnNumericData::k3Double, 0.0 , &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode forceIdleTime ratio\n"); MAKE_INPUT(nAttr); useSuppliedConstraints = nAttr.create("useSuppliedConstraints", "usc", MFnNumericData::kBoolean,1, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode useSuppliedConstraints ratio\n"); MAKE_INPUT(nAttr); useSuppliedForce = nAttr.create("useSuppliedForce", "usf", MFnNumericData::kBoolean, 0, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode useSuppliedForces ratio\n"); MAKE_INPUT(nAttr); integrationType = eAttr.create("timeIntegrationMethod","it",0,&returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode integrationType\n"); eAttr.addField("Implicit Backward Euler",0); eAttr.addField("Implicit Newmark",1); eAttr.addField("Central Differences",2); eAttr.addField("Symplectic Euler",3); MAKE_INPUT(eAttr); forceModelType = eAttr.create("system","ft",0,&returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode forceModelType\n"); eAttr.addField("Corotational Linear FEM",0); eAttr.addField("Mass Spring System",1); MAKE_INPUT(eAttr); contactKs = nAttr.create("contactSpringForce", "cKs", MFnNumericData::kDouble, 1000.0, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode contactSpringForces\n"); MAKE_INPUT(nAttr); contactKd = nAttr.create("contactDampForce", "cKd", MFnNumericData::kDouble, 50.0, &returnStatus); McheckErr(returnStatus, "ERROR creating LSSolverNode contactDampForces\n"); MAKE_INPUT(nAttr); returnStatus = addAttribute(tetWorldMatrix); McheckErr(returnStatus, "ERROR adding LSSolverNode world matrix attribute\n"); returnStatus = addAttribute(restShape); McheckErr(returnStatus, "ERROR adding LSSolverNode step attribute\n"); returnStatus = addAttribute(restElements); McheckErr(returnStatus, "ERROR adding LSSolverNode restElements attribute\n"); returnStatus = addAttribute(restVertices); McheckErr(returnStatus, "ERROR adding LSSolverNode restVertices attribute\n"); returnStatus = addAttribute(selectedConstraintVerts); McheckErr(returnStatus, "ERROR adding LSSolverNode selectedConstraintVerts attribute\n"); returnStatus = addAttribute(selectedForceVerts); McheckErr(returnStatus, "ERROR adding LSSolverNode selectedForceVerts attribute\n"); returnStatus = addAttribute(time); McheckErr(returnStatus, "ERROR adding LSSolverNode time attribute\n"); returnStatus = addAttribute(deformed); McheckErr(returnStatus, "ERROR adding LSSolverNode deformed attribute\n"); returnStatus = addAttribute(youngsModulus); McheckErr(returnStatus, "ERROR adding LSSolverNode youngsModulus\n"); returnStatus = addAttribute(poissonRatio); McheckErr(returnStatus, "ERROR adding LSSolverNode poissonRation\n"); returnStatus = addAttribute(objectDensity); McheckErr(returnStatus, "ERROR adding LSSolverNode objectDensity\n"); returnStatus = addAttribute(friction); McheckErr(returnStatus, "ERROR adding LSSolverNode friction\n"); returnStatus = addAttribute(restitution); McheckErr(returnStatus, "ERROR adding LSSolverNode resitution\n"); returnStatus = addAttribute(damping); McheckErr(returnStatus, "ERROR adding LSSolverNode damping\n"); returnStatus = addAttribute(userSuppliedDt); McheckErr(returnStatus, "ERROR adding LSSolverNode userSuppliedDt\n"); returnStatus = addAttribute(useSuppliedConstraints); McheckErr(returnStatus, "ERROR adding LSSolverNode useSuppliedConstraints\n"); returnStatus = addAttribute(useSuppliedForce); McheckErr(returnStatus, "ERROR adding LSSolverNode useSuppliedForce\n"); returnStatus = addAttribute(forceMagnitude); McheckErr(returnStatus, "ERROR adding LSSolverNode forceMagnitude\n"); returnStatus = addAttribute(forceDirection); McheckErr(returnStatus, "ERROR adding LSSolverNode forceDirection\n"); returnStatus = addAttribute(forceApplicationTime); McheckErr(returnStatus, "ERROR adding LSSolverNode forceApplicationTime\n"); returnStatus = addAttribute(forceReleasedTime); McheckErr(returnStatus, "ERROR adding LSSolverNode forceReleasedTime\n"); returnStatus = addAttribute(forceIncrementTime); McheckErr(returnStatus, "ERROR adding LSSolverNode forceIncrementTime\n"); returnStatus = addAttribute(forceStartTime); McheckErr(returnStatus, "ERROR adding LSSolverNode forceIdleTime\n"); returnStatus = addAttribute(forceStopTime); McheckErr(returnStatus, "ERROR adding LSSolverNode forceIdleTime\n"); // returnStatus = addAttribute(inputFilePath); // McheckErr(returnStatus, "ERROR adding LSSolverNode inputFilePath\n"); returnStatus = addAttribute(integrationType); McheckErr(returnStatus, "ERROR adding LSSolverNode integrationType\n"); returnStatus = addAttribute(forceModelType); McheckErr(returnStatus, "ERROR adding LSSolverNode forceModelType\n"); returnStatus = addAttribute(contactKd); McheckErr(returnStatus, "ERROR adding LSSolverNode contactKd\n"); returnStatus = addAttribute(contactKs); McheckErr(returnStatus, "ERROR adding LSSolverNode contactKs\n"); returnStatus = attributeAffects(restShape, deformed); McheckErr(returnStatus, "ERROR in attributeAffects: restShape - deformed\n"); returnStatus = attributeAffects(time, deformed); McheckErr(returnStatus, "ERROR in attributeAffects: time - deformed\n"); return MS::kSuccess; }
MStatus NBuddyEMPSaverNode::initialize() { MStatus status; MFnTypedAttribute typedAttr; //Typed attributes MFnUnitAttribute unitAttr; MFnStringData stringData; //String Attributes MFnNumericAttribute numFn; //Numerics MFnPluginData dataFn; //Create the body input array attribute _inBodies = typedAttr.create("inBodies","inb" , naiadBodyData::id , MObject::kNullObj , &status); NM_CheckMStatus(status, "ERROR creating inBodies attribute.\n"); typedAttr.setStorable( false ); typedAttr.setKeyable( false ); typedAttr.setWritable(true); typedAttr.setReadable(false); typedAttr.setArray( true ); status = addAttribute( _inBodies ); NM_CheckMStatus(status, "ERROR adding inBodies attribute.\n"); //Attribute for the folder in which to put the emp files _empOutputPath = typedAttr.create( "empOutputPath", "ef", MFnData::kString ,stringData.create(MString("/home/jimmi/dev/naiad/emopen/maya/naiadForMaya/test.#.emp")), &status); NM_CheckMStatus( status, "Failed to create empOutputPath attribute"); typedAttr.setStorable( true ); status = addAttribute( _empOutputPath ); NM_CheckMStatus( status, "Failed to add empOutputPath plug"); //Time input _time = unitAttr.create( "time", "tm", MFnUnitAttribute::kTime, 0.0, &status ); NM_CheckMStatus( status, "Failed to create time attribute"); unitAttr.setStorable(true); unitAttr.setWritable(true); status = addAttribute( _time ); NM_CheckMStatus( status, "Failed to add time plug"); _framePadding = numFn.create( "framePadding", "fp", MFnNumericData::kInt, 4 , &status ); NM_CheckMStatus( status, "Failed to create framePadding attribute"); numFn.setStorable(true); numFn.setWritable(true); status = addAttribute( _framePadding ); NM_CheckMStatus( status, "Failed to add framePadding plug"); _timeStep = numFn.create( "timeStep", "ts", MFnNumericData::kInt, 0 , &status ); NM_CheckMStatus( status, "Failed to create timeStep attribute"); numFn.setStorable(true); numFn.setWritable(true); status = addAttribute( _timeStep ); NM_CheckMStatus( status, "Failed to add timeStep plug"); // an dummy output trigger to force evaluation of the node _outTrigger = numFn.create("outTrigger", "ot", MFnNumericData::kBoolean); NM_CheckMStatus( status, "Failed to create outTrigger attribute"); numFn.setStorable(false); numFn.setWritable(false); status = addAttribute( _outTrigger ); NM_CheckMStatus( status, "Failed to add outTrigger plug"); //Attribute Affects attributeAffects( _inBodies, _outTrigger ); attributeAffects( _time, _outTrigger ); attributeAffects( _framePadding, _outTrigger ); attributeAffects( _timeStep, _outTrigger ); attributeAffects( _empOutputPath, _outTrigger ); return MS::kSuccess; }
MStatus LSystemNode::initialize() { MFnUnitAttribute unitAttr; MFnTypedAttribute typedAttr; MFnNumericAttribute angleNumAttr; MFnNumericAttribute stepNumAttr; MFnTypedAttribute grammarTypedAttr; MStatus returnStatus; LSystemNode::time = unitAttr.create( "time", "tm", MFnUnitAttribute::kTime, 0.0, &returnStatus ); McheckErr(returnStatus, "ERROR creating LSystemNode time attribute\n"); LSystemNode::outputMesh = typedAttr.create( "outputMesh", "out", MFnData::kMesh, &returnStatus ); McheckErr(returnStatus, "ERROR creating LSystemNode output attribute\n"); typedAttr.setStorable(false); LSystemNode::angle = angleNumAttr.create( "angle", "a", MFnNumericData::kDouble, 90.0 ); McheckErr(returnStatus, "ERROR creating LSystemNode angle attribute\n"); LSystemNode::steps = stepNumAttr.create( "steps", "s", MFnNumericData::kDouble, 1.0 ); McheckErr(returnStatus, "ERROR creating LSystemNode step size attribute\n"); LSystemNode::grammar = grammarTypedAttr.create( "grammar", "g", MFnData::kString, &returnStatus ); McheckErr(returnStatus, "ERROR creating LSystemNode grammar attribute\n"); grammarTypedAttr.setStorable(false); returnStatus = addAttribute(LSystemNode::time); McheckErr(returnStatus, "ERROR adding time attribute\n"); returnStatus = addAttribute(LSystemNode::outputMesh); McheckErr(returnStatus, "ERROR adding outputMesh attribute\n"); returnStatus = addAttribute(LSystemNode::angle); McheckErr(returnStatus, "ERROR adding angle attribute\n"); returnStatus = addAttribute(LSystemNode::steps); McheckErr(returnStatus, "ERROR adding steps attribute\n"); returnStatus = addAttribute(LSystemNode::grammar); McheckErr(returnStatus, "ERROR adding grammar attribute\n"); returnStatus = attributeAffects(LSystemNode::time, LSystemNode::outputMesh); returnStatus = attributeAffects(LSystemNode::angle, LSystemNode::outputMesh); returnStatus = attributeAffects(LSystemNode::grammar, LSystemNode::outputMesh); returnStatus = attributeAffects(LSystemNode::steps, LSystemNode::outputMesh); McheckErr(returnStatus, "ERROR in attributeAffects\n"); return MS::kSuccess; }