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 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 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; }
//- 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; }
//- 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; //- TODO: Create a angle attribute with long name "windDirection" and short name "wd" windDirection = //... uAttr.setStorable(true); uAttr.setWritable(true); uAttr.setReadable(true); uAttr.setKeyable(true); //- TODO: Set the min and max value this attribute can have 0, 2PI //... //... uAttr.setDefault(MAngle(0.0, MAngle::kRadians)); addAttribute(windDirection); 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 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 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 swissArmyLocator::initialize() { MFnUnitAttribute unitFn; MFnNumericAttribute numericFn; MStatus stat; MString method("swissArmyLocator::initialize"); MStatus s; int counter = 0; // aSize aSize = unitFn.create("size", "sz", MFnUnitAttribute::kDistance, 0.0, &s); e; unitFn.setDefault(10.0); unitFn.setStorable(true); unitFn.setWritable(true); // aPoint aPointX = numericFn.create("pointX", "ptx", MFnNumericData::kDouble, 0.0, &s); e; aPointY = numericFn.create("pointY", "pty", MFnNumericData::kDouble, 0.0, &s); e; aPointZ = numericFn.create("pointZ", "ptz", MFnNumericData::kDouble, 0.0, &s); e; aPoint = numericFn.create("point", "pt", aPointX, aPointY, aPointZ, &s); e; // aArrow1Angle aArrow1Angle = unitFn.create("arrow1Angle", "a1a", MFnUnitAttribute::kAngle, 0.0, &s); e; // aArrow2Direction aArrow2DirectionX = numericFn.create("arrow2DirectionX", "a2x", MFnNumericData::kDouble, 1.0, &s); e; aArrow2DirectionY = numericFn.create("arrow2DirectionY", "a2y", MFnNumericData::kDouble, 0.0, &s); e; aArrow2DirectionZ = numericFn.create("arrow2DirectionZ", "a2z", MFnNumericData::kDouble, 0.0, &s); e; aArrow2Direction = numericFn.create("arrow2Direction", "dir", aArrow2DirectionX, aArrow2DirectionY, aArrow2DirectionZ, &s); e; // aArrow3Angle aArrow3Angle = unitFn.create("arrow3Angle", "a3a", MFnUnitAttribute::kAngle, 0.0, &s); e; // aArrow4Distance aArrow4Distance = unitFn.create("arrow2Distance", "dis", MFnUnitAttribute::kDistance, 0.0, &s); e; // aState; aState = numericFn.create("state", "s", MFnNumericData::kLong, 0, &s); e; // aToggle; aToggle = numericFn.create("toggle", "t", MFnNumericData::kBoolean, false, &s); e; s = addAttribute(aPoint); e; s = addAttribute(aArrow1Angle); e; s = addAttribute(aArrow2Direction); e; s = addAttribute(aArrow3Angle); e; s = addAttribute(aArrow4Distance); e; s = addAttribute(aState); e; s = addAttribute(aToggle); e; stat = addAttribute(aSize); if (!stat) { stat.perror("addAttribute"); return stat; } MPxManipContainer::addToManipConnectTable(id); return MS::kSuccess; }