MStatus BasicLocator::initialize() { //standard attribute creation for the locator node MStatus status; MFnNumericAttribute nAttr; MFnEnumAttribute eAttr; //output attribute aIsDrawing = nAttr.create("draw", "d", MFnNumericData::kBoolean, 1); nAttr.setWritable(true); nAttr.setStorable(true); addAttribute(aIsDrawing); aIsTransparent = nAttr.create("transparent", "tpart", MFnNumericData::kFloat, 0.5); nAttr.setMin(0.0); nAttr.setMax(1.0); nAttr.setWritable(true); nAttr.setStorable(true); addAttribute(aIsTransparent); aShapeColor = nAttr.createColor("color", "col"); nAttr.setDefault(0.1, 0.1, 0.8); nAttr.setStorable(true); nAttr.setWritable(true); addAttribute(aShapeColor); aShapeType = eAttr.create("shapeType", "styp", 0); eAttr.setStorable(true); eAttr.setKeyable(true); eAttr.addField("arrow", 0); eAttr.addField("disc", 1); addAttribute(aShapeType); return MS::kSuccess; }
// The initialize routine is called after the node has been created. // It sets up the input and output attributes and adds them to the node. // Finally the dependencies are arranged so that when the inputs // change Maya knowns to call compute to recalculate the output values. // The inputs are: input, scale, frames // The outputs are: sineOutput, cosineOutput // MStatus circle::initialize() { MFnNumericAttribute nAttr; MStatus stat; // Setup the input attributes // input = nAttr.create( "input", "in", MFnNumericData::kFloat, 0.0, &stat ); CHECK_MSTATUS( stat ); CHECK_MSTATUS( nAttr.setStorable( true ) ); scale = nAttr.create( "scale", "sc", MFnNumericData::kFloat, 10.0, &stat ); CHECK_MSTATUS( stat ); CHECK_MSTATUS( nAttr.setStorable( true ) ); frames = nAttr.create( "frames", "fr", MFnNumericData::kFloat, 48.0, &stat ); CHECK_MSTATUS( stat ); CHECK_MSTATUS( nAttr.setStorable( true ) ); // Setup the output attributes // sOutput = nAttr.create( "sineOutput", "so", MFnNumericData::kFloat, 0.0, &stat ); CHECK_MSTATUS( stat ); CHECK_MSTATUS( nAttr.setWritable( false ) ); CHECK_MSTATUS( nAttr.setStorable( false ) ); cOutput = nAttr.create( "cosineOutput", "co", MFnNumericData::kFloat, 0.0, &stat ); CHECK_MSTATUS( stat ); CHECK_MSTATUS( nAttr.setWritable( false ) ); CHECK_MSTATUS( nAttr.setStorable( false ) ); // Add the attributes to the node // CHECK_MSTATUS( addAttribute( input ) ); CHECK_MSTATUS( addAttribute( scale ) ); CHECK_MSTATUS( addAttribute( frames ) ); CHECK_MSTATUS( addAttribute( sOutput ) ); CHECK_MSTATUS( addAttribute( cOutput ) ); // Set the attribute dependencies // CHECK_MSTATUS( attributeAffects( input, sOutput ) ); CHECK_MSTATUS( attributeAffects( input, cOutput ) ); CHECK_MSTATUS( attributeAffects( scale, sOutput ) ); CHECK_MSTATUS( attributeAffects( scale, cOutput ) ); CHECK_MSTATUS( attributeAffects( frames, sOutput ) ); CHECK_MSTATUS( attributeAffects( frames, cOutput ) ); return MS::kSuccess; }
MStatus curvedArrows::initialize() { MFnNumericAttribute nAttr; aTheColor = nAttr.createColor( "theColor", "tc" ); nAttr.setDefault( 0.1, 0.1, 0.8 ); nAttr.setKeyable( true ); nAttr.setReadable( true ); nAttr.setWritable( true ); nAttr.setStorable( true ); aTransparency = nAttr.create( "transparency", "t", MFnNumericData::kFloat ); nAttr.setDefault( 0.5 ); nAttr.setKeyable( true ); nAttr.setReadable( true ); nAttr.setWritable( true ); nAttr.setStorable( true ); aEnableTransparencySort = nAttr.create( "transparencySort", "ts", MFnNumericData::kBoolean ); nAttr.setDefault( true ); nAttr.setKeyable( true ); nAttr.setReadable( true ); nAttr.setWritable( true ); nAttr.setStorable( true ); aEnableDrawLast = nAttr.create( "drawLast", "dL", MFnNumericData::kBoolean ); nAttr.setDefault( false ); nAttr.setKeyable( true ); nAttr.setReadable( true ); nAttr.setWritable( true ); nAttr.setStorable( true ); MStatus stat1, stat2, stat3, stat4; stat1 = addAttribute( aTheColor ); stat2 = addAttribute( aEnableTransparencySort ); stat3 = addAttribute( aEnableDrawLast ); stat4 = addAttribute( aTransparency ); if ( !stat1 || !stat2 || !stat3 || !stat4) { stat1.perror("addAttribute"); stat2.perror("addAttribute"); stat3.perror("addAttribute"); stat4.perror("addAttribute"); return MS::kFailure; } return MS::kSuccess; }
// // DESCRIPTION: /////////////////////////////////////////////////////// MStatus DispNode::initialize() { MFnNumericAttribute nAttr; // Inputs aColor = nAttr.createColor( "color", "c" ); CHECK_MSTATUS(nAttr.setKeyable(true)); CHECK_MSTATUS(nAttr.setStorable(true)); CHECK_MSTATUS(nAttr.setDefault(1.0f, 1.0f, 1.0f)); aInputValue = nAttr.create( "factor", "f", MFnNumericData::kFloat); CHECK_MSTATUS(nAttr.setKeyable(true)); CHECK_MSTATUS(nAttr.setStorable(true)); CHECK_MSTATUS(nAttr.setDefault(1.0f)); // Outputs aOutColor = nAttr.createColor( "outColor", "oc" ); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(false)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); aOutTransparency = nAttr.createColor( "outTransparency", "ot" ); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(false)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); aOutDisplacement = nAttr.create( "displacement", "od", MFnNumericData::kFloat); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(false)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); CHECK_MSTATUS(addAttribute(aColor)); CHECK_MSTATUS(addAttribute(aInputValue)); CHECK_MSTATUS(addAttribute(aOutColor)); CHECK_MSTATUS(addAttribute(aOutTransparency)); CHECK_MSTATUS(addAttribute(aOutDisplacement)); CHECK_MSTATUS(attributeAffects (aColor, aOutColor)); CHECK_MSTATUS(attributeAffects (aColor, aOutDisplacement)); return MS::kSuccess; }
MStatus [!output CLASS_NAME]::initialize () { //- This 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. //- This sample creates a single input float attribute and a single output float attribute. MFnNumericAttribute nAttr ; attr1 =nAttr.create (_T("input"), _T("in"), MFnNumericData::kFloat, 0.0) ; nAttr.setStorable (true) ; //- Attribute will be written to files when this type of node is stored nAttr.setKeyable (true) ; //- Attribute is keyable and will show up in the channel box MayaOk (addAttribute (attr1), _T("addAttribute")) ; //- Add the attributes we have created to the node attr2 =nAttr.create (_T("output"), _T("out"), MFnNumericData::kFloat, 0.0) ; nAttr.setWritable (false) ; //- Attribute is read-only because it is an output attribute nAttr.setStorable (false) ; //- Attribute will not be written to files when this type of node is stored MayaOk (addAttribute (attr2), _T("addAttribute")) ; //- Add the attributes we have created to the node //- Set up a dependency between the input and the output. This will cause //- the output to be marked dirty when the input changes. The output will //- then be recomputed the next time the value of the output is requested. MayaOk (attributeAffects (attr1, attr2), _T("attributeAffects")) ; return (MStatus::kSuccess) ; }
MStatus MocapMesh::initialize() { MStatus stat; MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; in_inMesh = tAttr.create("inMesh", "im",MFnData::kMesh); tAttr.setKeyable(true); tAttr.setStorable(true); tAttr.setReadable(true); tAttr.setWritable(true); stat = addAttribute(in_inMesh); if(!stat) { stat.perror("adding inMesh"); return stat; } out_message = nAttr.create("test", "test", MFnNumericData::kDouble, 0.0); nAttr.setKeyable(false); nAttr.setStorable(false); nAttr.setWritable(false); nAttr.setReadable(true); stat = addAttribute(out_message); if(!stat) { stat.perror("adding test"); return stat; } stat = attributeAffects(in_inMesh,out_message); if(!stat) { stat.perror("attributeAffects"); return stat; } 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 BCIViz::initialize() { MFnNumericAttribute numFn; MFnMatrixAttribute matAttr; MStatus stat; ainput = matAttr.create( "input", "in", MFnMatrixAttribute::kDouble ); matAttr.setStorable(false); matAttr.setWritable(true); matAttr.setConnectable(true); addAttribute(ainput); atargets = matAttr.create( "target", "tgt", MFnMatrixAttribute::kDouble ); matAttr.setStorable(false); matAttr.setWritable(true); matAttr.setArray(true); matAttr.setConnectable(true); addAttribute(atargets); outValue = numFn.create( "outValue", "ov", MFnNumericData::kDouble ); numFn.setStorable(false); numFn.setWritable(false); numFn.setReadable(true); numFn.setArray(true); numFn.setUsesArrayDataBuilder( true ); addAttribute(outValue); attributeAffects(ainput, outValue); attributeAffects(atargets, outValue); 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 VolumePushCollider::initialize() { MFnNumericAttribute nAttr; MFnMatrixAttribute mAttr; // inCollider aInCollider = mAttr.create("inCollider", "col"); mAttr.setArray(true); CHECK_MSTATUS(addAttribute(aInCollider)); // inVolume aInVolume = mAttr.create("inVolume", "vol"); mAttr.setArray(true); CHECK_MSTATUS(addAttribute(aInVolume)); // output aOutput = nAttr.create("output", "out", MFnNumericData::kDouble, 0.0); nAttr.setArray(true); nAttr.setReadable(true); nAttr.setWritable(true); nAttr.setHidden(true); CHECK_MSTATUS(addAttribute(aOutput)); attributeAffects(aInCollider, aOutput); attributeAffects(aInVolume, aOutput); return MS::kSuccess; }
MStatus prtAttribNode::initialize() { MFnNumericAttribute numAttr; MStatus stat; askipidir = numAttr.create( "skipIndirect", "skind", MFnNumericData::kBoolean, 0 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( askipidir ); askipepid = numAttr.create( "skipScatter", "skscat", MFnNumericData::kBoolean, 0 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( askipepid ); askipscat = numAttr.create( "skipBackscatter", "skbscat", MFnNumericData::kBoolean, 0 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( askipscat ); aaslight = numAttr.create( "asLightsource", "asl", MFnNumericData::kBoolean, 0 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( aaslight ); aklight = numAttr.create( "lightIntensity", "li", MFnNumericData::kDouble, 2.0 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( aklight ); anoshadow = numAttr.create( "castNoShadow", "cns", MFnNumericData::kBoolean, 0 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( anoshadow ); aasghost = numAttr.create( "asGhost", "asg", MFnNumericData::kBoolean, 0 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( aasghost ); output = numAttr.create( "output", "out", MFnNumericData::kFloat, 0.0 ); numAttr.setWritable(false); numAttr.setStorable(false); stat = addAttribute( output ); if (!stat) { stat.perror("addAttribute"); return stat;} attributeAffects( askipidir, output ); attributeAffects( askipepid, output ); attributeAffects( askipscat, output ); attributeAffects( aaslight, output ); attributeAffects( aklight, output ); attributeAffects( aasghost, output ); attributeAffects( anoshadow, output ); return MS::kSuccess; }
MStatus mpBox::initialize() { MFnNumericAttribute nAttr; MFnEnumAttribute enumAttr; // add the custom attributes for mpBox // _COMMON_ATTR_INIT_; aXsize = nAttr.create( "xsize", "xsz", MFnNumericData::kFloat); nAttr.setDefault(0.5f); nAttr.setKeyable(1); nAttr.setReadable(1); nAttr.setWritable(1); nAttr.setStorable(1); aYsize = nAttr.create( "ysize", "ysz", MFnNumericData::kFloat); nAttr.setDefault(0.5f); nAttr.setKeyable(1); nAttr.setReadable(1); nAttr.setWritable(1); nAttr.setStorable(1); aZsize = nAttr.create( "zsize", "zsz", MFnNumericData::kFloat); nAttr.setDefault(0.5f); nAttr.setKeyable(1); nAttr.setReadable(1); nAttr.setWritable(1); nAttr.setStorable(1); aDrawType = enumAttr.create( "drawType" , "dt"); enumAttr.addField("wireframe", 0); enumAttr.addField("shaded", 1); enumAttr.addField("normal", 2); enumAttr.setHidden(false); enumAttr.setKeyable(true); enumAttr.setDefault(2); addAttribute(aXsize); addAttribute(aYsize); addAttribute(aZsize); addAttribute(aDrawType); return MS::kSuccess; }
MStatus sgIkSmoothStretch::initialize() { MStatus stat; MFnNumericAttribute nAttr; aInputDistance = nAttr.create( "inputDistance", "in", MFnNumericData::kDouble, 0.0 ); nAttr.setArray( true ); nAttr.setUsesArrayDataBuilder( true ); nAttr.setStorable( true ); aInPositionX = nAttr.create( "inPositionX", "ipx", MFnNumericData::kDouble, 0.0 ); nAttr.setStorable( true ); aInPositionY = nAttr.create( "inPositionY", "ipy", MFnNumericData::kDouble, 0.0 ); nAttr.setStorable( true ); aInPositionZ = nAttr.create( "inPositionZ", "ipz", MFnNumericData::kDouble, 0.0 ); nAttr.setStorable( true ); aInPosition = nAttr.create( "inPosition", "ip", aInPositionX, aInPositionY, aInPositionZ ); aOutputDistance = nAttr.create( "outputDistance", "out", MFnNumericData::kDouble, 0,0 ); nAttr.setArray( true ); nAttr.setUsesArrayDataBuilder( true ); nAttr.setStorable( false ); nAttr.setWritable( false ); aSmoothArea = nAttr.create( "smoothArea", "smoothArea", MFnNumericData::kDouble, 0.0 ); nAttr.setStorable( true ); aStretchAble = nAttr.create( "stretchAble", "sa", MFnNumericData::kFloat, 1.0 ); nAttr.setStorable( true ); nAttr.setMin( 0.0 ); nAttr.setMax( 1 ); stat = addAttribute( aInputDistance ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( aInPosition ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( aOutputDistance ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( aStretchAble ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( aSmoothArea ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = attributeAffects( aInputDistance, aOutputDistance ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aInPosition, aOutputDistance ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aStretchAble, aOutputDistance ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( aSmoothArea, aOutputDistance ); if (!stat) { stat.perror("attributeAffects"); return stat;} return MS::kSuccess; }
// INIT ========================================= MStatus gear_uToPercentage::initialize() { MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MStatus stat; // Curve curve = tAttr.create("curve", "crv", MFnData::kNurbsCurve); stat = addAttribute( curve ); if (!stat) {stat.perror("addAttribute"); return stat;} // Sliders normalizedU = nAttr.create("normalizedU", "n", MFnNumericData::kBoolean, false); nAttr.setStorable(true); nAttr.setKeyable(true); stat = addAttribute( normalizedU ); if (!stat) {stat.perror("addAttribute"); return stat;} u = nAttr.create("u", "u", MFnNumericData::kFloat, .5, 0); nAttr.setStorable(true); nAttr.setKeyable(true); stat = addAttribute( u ); if (!stat) {stat.perror("addAttribute"); return stat;} steps = nAttr.create("steps", "s", MFnNumericData::kShort, 40); nAttr.setStorable(true); nAttr.setKeyable(true); stat = addAttribute( steps ); if (!stat) {stat.perror("addAttribute"); return stat;} // Outputs percentage = nAttr.create( "percentage", "p", MFnNumericData::kFloat, 0 ); nAttr.setWritable(false); nAttr.setStorable(false); nAttr.setReadable(true); nAttr.setKeyable(false); stat = addAttribute( percentage ); if (!stat) {stat.perror("addAttribute"); return stat;} // Connections stat = attributeAffects ( curve, percentage ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( steps, percentage ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( u, percentage ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( normalizedU, percentage ); if (!stat) {stat.perror("attributeAffects"); return stat;} return MS::kSuccess; }
MStatus DynamicEnum::initialize() { MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; MFnStringData sData; MStatus status; // Status will be used to hold the MStatus value // returned by each api function call. It is important // to check the status returned by a call to aid in // debugging. Failed API calls can result in subtle // errors that can be difficult to track down, you may // wish to use the CHECK_MSTATUS macro for any API // call where you do not need to provide your own // error handling. // // Attribute Initialization: aFilePath = tAttr.create( "filepath", "file", MFnData::kString, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( tAttr.setKeyable( true ) ); CHECK_MSTATUS( tAttr.setStorable( true ) ); CHECK_MSTATUS( tAttr.setDefault( sData.create("") ) ); aGridName = tAttr.create( "grid", "grd", MFnData::kString, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( tAttr.setKeyable( true ) ); CHECK_MSTATUS( tAttr.setStorable( true ) ); CHECK_MSTATUS( tAttr.setDefault( sData.create("") ) ); aOutColor = nAttr.createColor( "outColor", "oc", &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setHidden( false ) ); CHECK_MSTATUS( nAttr.setReadable( true ) ); CHECK_MSTATUS( nAttr.setWritable( false ) ); // Next we will add the attributes we have defined to the node // CHECK_MSTATUS( addAttribute( aFilePath ) ); CHECK_MSTATUS( addAttribute( aGridName ) ); CHECK_MSTATUS( addAttribute( aOutColor ) ); // The attributeAffects() method is used to indicate when the input // attribute affects the output attribute. This knowledge allows Maya // to optimize dependencies in the graph in more complex nodes where // there may be several inputs and outputs, but not all the inputs // affect all the outputs. // CHECK_MSTATUS( attributeAffects( aFilePath, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aGridName, aOutColor ) ); return( MS::kSuccess ); }
MStatus ModifyArrayNode::initialize() { MStatus status; MFnTypedAttribute T; MFnNumericAttribute N; MFnEnumAttribute E; aInput = T.create("input", "i", MFnData::kDoubleArray); T.setKeyable(false); T.setChannelBox(false); T.setStorable(true); T.setWritable(true); aOperation = E.create("operation", "operation"); E.addField("No Operation", kNO_OP); E.addField("Sort", kSORT); E.addField("Absolute Value", kABS); E.addField("Reflect Left", kREFLECT_LEFT); E.addField("Reflect Right", kREFLECT_RIGHT); E.setDefault(kNO_OP); E.setKeyable(true); E.setStorable(true); E.setWritable(true); aReverse = N.create("reverse", "rev", MFnNumericData::kBoolean); N.setKeyable(true); N.setChannelBox(true); N.setStorable(true); N.setWritable(true); aOutput = T.create("output", "o", MFnData::kDoubleArray); T.setKeyable(false); T.setChannelBox(false); T.setWritable(false); T.setStorable(false); addAttribute(aOperation); addAttribute(aInput); addAttribute(aReverse); addAttribute(aOutput); attributeAffects(aOperation, aOutput); attributeAffects(aInput, aOutput); attributeAffects(aReverse, aOutput); return MS::kSuccess; }
MStatus TestDeformer::initialize() { MFnNumericAttribute numericAttr; MFnTypedAttribute polyMeshAttr; MFnEnumAttribute enumAttr; MStatus status; // Status will be used to hold the MStatus value // vertSnapInput driver_mesh = polyMeshAttr.create( "vertSnapInput", "vsnpin", MFnData::kMesh, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( polyMeshAttr.setStorable( false ) ); CHECK_MSTATUS( polyMeshAttr.setArray(true) ); CHECK_MSTATUS( polyMeshAttr.setConnectable( true ) ); CHECK_MSTATUS( addAttribute(driver_mesh) ); CHECK_MSTATUS( attributeAffects(driver_mesh, outputGeom) ); // initialize is used to mark this node's state initialized_data = enumAttr.create( "initialize", "inl", 0/*default*/, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( enumAttr.addField( "Off", 0) ); CHECK_MSTATUS( enumAttr.addField( "Re-Set Bind", 1) ); CHECK_MSTATUS( enumAttr.addField( "Bound", 2) ); CHECK_MSTATUS( enumAttr.setKeyable(true) ); CHECK_MSTATUS( enumAttr.setStorable(true) ); CHECK_MSTATUS( enumAttr.setReadable(true) ); CHECK_MSTATUS( enumAttr.setWritable(true) ); CHECK_MSTATUS( enumAttr.setDefault(0) ); CHECK_MSTATUS( addAttribute( initialized_data ) ); CHECK_MSTATUS( attributeAffects( initialized_data, outputGeom ) ); // hold the vertex index mapping vert_map = numericAttr.create( "vtxIndexMap", "vtximp", MFnNumericData::kLong, 0/*default*/, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( numericAttr.setKeyable(false) ); CHECK_MSTATUS( numericAttr.setArray(true) ); CHECK_MSTATUS( numericAttr.setStorable(true) ); CHECK_MSTATUS( numericAttr.setReadable(true) ); CHECK_MSTATUS( numericAttr.setWritable(true) ); CHECK_MSTATUS( addAttribute( vert_map ) ); CHECK_MSTATUS( attributeAffects( vert_map, outputGeom ) ); CHECK_MSTATUS( MGlobal::executePythonCommand("import maya.cmds; maya.cmds.makePaintable('"+TestDeformer::cTypeName()+"', 'weights', attrType='multiFloat')") ); return( MS::kSuccess ); }
MStatus arcLen::initialize() { MFnNumericAttribute numericAttr; MFnTypedAttribute typedAttr; MStatus status; inputCurve = typedAttr.create( "inputCurve", "in", MFnData::kNurbsCurve, &status ); if( !status ) { status.perror("ERROR creating arcLen curve attribute"); return status; } output = numericAttr.create( "output", "out", MFnNumericData::kDouble, 0.0, &status ); if( !status ) { status.perror("ERROR creating arcLen output attribute"); return status; } numericAttr.setWritable(false); status = addAttribute( inputCurve ); if( !status ) { status.perror("addAttribute(inputCurve)"); return status; } status = addAttribute( output ); if( !status ) { status.perror("addAttribute(output)"); return status; } status = attributeAffects( inputCurve, output ); if( !status ) { status.perror("attributeAffects(inputCurve, output)"); return status; } return MS::kSuccess; }
MStatus ParameterisedHolder<B>::initialize() { MStatus s; MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; aParameterisedClassName = tAttr.create( "className", "clas", MFnData::kString ); tAttr.setReadable(true); tAttr.setWritable(true); tAttr.setStorable(true); tAttr.setConnectable(false); tAttr.setHidden(true); s = B::addAttribute( aParameterisedClassName ); assert(s); aParameterisedVersion = nAttr.create("version", "ver", MFnNumericData::kInt, 1, &s ); assert(s); nAttr.setReadable(true); nAttr.setWritable(true); nAttr.setStorable(true); nAttr.setConnectable(false); nAttr.setHidden(true); s = B::addAttribute( aParameterisedVersion ); assert(s); aParameterisedSearchPathEnvVar = tAttr.create("searchPathEnvVar", "spev", MFnData::kString ); tAttr.setReadable(true); tAttr.setWritable(true); tAttr.setStorable(true); tAttr.setConnectable(false); tAttr.setHidden(true); s = B::addAttribute( aParameterisedSearchPathEnvVar ); assert(s); MPxManipContainer::addToManipConnectTable( id ); return MS::kSuccess; }
MStatus squash::initialize() { MFnNumericAttribute nAttr; MStatus stat; lengthOriginal = nAttr.create( "lengthOriginal", "lo", MFnNumericData::kDouble, 1.0 ); nAttr.setStorable(true); lengthModify = nAttr.create( "lengthModify", "lm", MFnNumericData::kDouble, 1.0 ); nAttr.setStorable(true); squashRate = nAttr.create( "squashRate", "r", MFnNumericData::kDouble, 1.0 ); nAttr.setStorable(true); forceValue = nAttr.create( "forceValue", "f", MFnNumericData::kDouble, 0.0 ); nAttr.setStorable(true); output = nAttr.create( "output", "o", MFnNumericData::kDouble, 0.0 ); nAttr.setWritable(false); nAttr.setStorable(true); stat = addAttribute( lengthOriginal ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( lengthModify ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( squashRate ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( forceValue ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = addAttribute( output ); if (!stat) { stat.perror("addAttribute"); return stat;} stat = attributeAffects( lengthOriginal, output ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( lengthModify, output ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( squashRate, output ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( forceValue, output ); if (!stat) { stat.perror("attributeAffects"); return stat;} return MS::kSuccess; }
MStatus sine::initialize() { MFnNumericAttribute nAttr; MStatus stat; input = nAttr.create( "input", "in", MFnNumericData::kFloat, 0.0 ); nAttr.setStorable(true); output = nAttr.create( "output", "out", MFnNumericData::kFloat, 0.0 ); nAttr.setWritable(false); nAttr.setStorable(false); stat = addAttribute( input ); 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;} return MS::kSuccess; }
MStatus dynExprField::initialize() // // Descriptions: // Initialize the node, attributes. // { MStatus status; MFnNumericAttribute numAttr; // create the field basic attributes. // mDirection = numAttr.createPoint("direction","dir"); numAttr.setDefault( 0.0, 1.0, 0.0 ); numAttr.setKeyable(true); numAttr.setStorable(true); numAttr.setReadable(true); numAttr.setWritable(true); status = addAttribute( mDirection ); attributeAffects(mDirection, mOutputForce); return( MS::kSuccess ); }
//--------------------------------------------------- // Creates a typed attribute. Used for maya "notes" attributes. MObject DagHelper::createAttribute ( const MObject& node, const char* attributeName, const char* attributeShortName, MFnNumericData::Type type, const char *value ) { // Before creating a new attribute: verify that an old one doesn't already exist MStatus status; MObject attribute; MFnDependencyNode nodeFn ( node ); MPlug plug = nodeFn.findPlug ( attributeShortName, status ); if ( status != MStatus::kSuccess ) { MFnNumericAttribute attr; MStatus status; attribute = attr.create ( attributeName,attributeShortName,type,0,&status ); if ( status != MStatus::kSuccess ) return MObject::kNullObj; attr.setStorable ( true ); attr.setKeyable ( false ); attr.setCached ( true ); attr.setReadable ( true ); attr.setWritable ( true ); status = nodeFn.addAttribute ( attribute, MFnDependencyNode::kLocalDynamicAttr ); if ( status != MStatus::kSuccess ) return MObject::kNullObj; plug = nodeFn.findPlug ( attribute, &status ); if ( status != MStatus::kSuccess ) return MObject::kNullObj; } status = plug.setValue ( value ); if ( status != MStatus::kSuccess ) return MObject::kNullObj; return attribute; }
MStatus asMicrofacet_brdf::initialize() { MFnNumericAttribute nAttr; MFnLightDataAttribute lAttr; MFnTypedAttribute tAttr; MFnGenericAttribute gAttr; MFnEnumAttribute eAttr; MFnMessageAttribute mAttr; MStatus status; // Status will be used to hold the MStatus value // returned by each api function call. It is important // to check the status returned by a call to aid in // debugging. Failed API calls can result in subtle // errors that can be difficult to track down, you may // wish to use the CHECK_MSTATUS macro for any API // call where you do not need to provide your own // error handling. // //---------------------------- automatically created attributes start ------------------------------------ reflectance = nAttr.createColor("reflectance", "reflectance"); nAttr.setDefault(0.5,0.5,0.5); CHECK_MSTATUS(addAttribute( reflectance )); mdf = eAttr.create("mdf", "mdf", 1, &status); status = eAttr.addField( "beckmann", 0 ); status = eAttr.addField( "blinn", 1 ); status = eAttr.addField( "ggx", 2 ); status = eAttr.addField( "ward", 3 ); CHECK_MSTATUS(addAttribute( mdf )); glossiness_multiplier = nAttr.create("glossiness_multiplier", "glossiness_multiplier", MFnNumericData::kFloat, 1.0); CHECK_MSTATUS(addAttribute( glossiness_multiplier )); glossiness = nAttr.create("glossiness", "glossiness", MFnNumericData::kFloat, 0.5); CHECK_MSTATUS(addAttribute( glossiness )); fresnel_multiplier = nAttr.create("fresnel_multiplier", "fresnel_multiplier", MFnNumericData::kFloat, 1.0); CHECK_MSTATUS(addAttribute( fresnel_multiplier )); reflectance_multiplier = nAttr.create("reflectance_multiplier", "reflectance_multiplier", MFnNumericData::kFloat, 1.0); CHECK_MSTATUS(addAttribute( reflectance_multiplier )); //---------------------------- automatically created attributes end ------------------------------------ // Input Attributes // aTranslucenceCoeff = nAttr.create( "translucenceCoeff", "tc", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.0f ) ); aDiffuseReflectivity = nAttr.create( "diffuseReflectivity", "drfl", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.8f ) ); aColor = nAttr.createColor( "color", "c", &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.58824f, 0.644f ) ); aIncandescence = nAttr.createColor( "incandescence", "ic", &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.0f, 0.0f ) ); aInTransparency = nAttr.createColor( "transparency", "it", &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.0f, 0.0f ) ); // Color Output // aOutColor = nAttr.createColor( "outColor", "oc", &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setHidden( false ) ); CHECK_MSTATUS( nAttr.setReadable( true ) ); CHECK_MSTATUS( nAttr.setWritable( false ) ); aOutTransparency = nAttr.createColor( "outTransparency", "ot", &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setHidden( false ) ); CHECK_MSTATUS( nAttr.setReadable( true ) ); CHECK_MSTATUS( nAttr.setWritable( false ) ); // Camera Normals // aNormalCameraX = nAttr.create( "normalCameraX", "nx", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable( false ) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aNormalCameraY = nAttr.create( "normalCameraY", "ny", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable( false ) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aNormalCameraZ = nAttr.create( "normalCameraZ", "nz", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable( false ) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aNormalCamera = nAttr.create( "normalCamera","n", aNormalCameraX, aNormalCameraY, aNormalCameraZ, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable( false ) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) ); CHECK_MSTATUS( nAttr.setHidden( true ) ); // Light Direction // aLightDirectionX = nAttr.create( "lightDirectionX", "ldx", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aLightDirectionY = nAttr.create( "lightDirectionY", "ldy", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aLightDirectionZ = nAttr.create( "lightDirectionZ", "ldz", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aLightDirection = nAttr.create( "lightDirection", "ld", aLightDirectionX, aLightDirectionY, aLightDirectionZ, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) ); // Light Intensity // aLightIntensityR = nAttr.create( "lightIntensityR", "lir", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aLightIntensityG = nAttr.create( "lightIntensityG", "lig", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aLightIntensityB = nAttr.create( "lightIntensityB", "lib", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aLightIntensity = nAttr.create( "lightIntensity", "li", aLightIntensityR, aLightIntensityG, aLightIntensityB, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) ); // Light // aLightAmbient = nAttr.create( "lightAmbient", "la", MFnNumericData::kBoolean, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( true ) ); aLightDiffuse = nAttr.create( "lightDiffuse", "ldf", MFnNumericData::kBoolean, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( true ) ); aLightSpecular = nAttr.create( "lightSpecular", "ls", MFnNumericData::kBoolean, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( false ) ); aLightShadowFraction = nAttr.create( "lightShadowFraction", "lsf", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aPreShadowIntensity = nAttr.create( "preShadowIntensity", "psi", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aLightBlindData = nAttr.createAddr( "lightBlindData", "lbld", &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightData = lAttr.create( "lightDataArray", "ltd", aLightDirection, aLightIntensity, aLightAmbient, aLightDiffuse, aLightSpecular, aLightShadowFraction, aPreShadowIntensity, aLightBlindData, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( lAttr.setArray( true ) ); CHECK_MSTATUS( lAttr.setStorable( false ) ); CHECK_MSTATUS( lAttr.setHidden( true ) ); CHECK_MSTATUS( lAttr.setDefault( 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, true, true, false, 1.0f, 1.0f, NULL ) ); // Next we will add the attributes we have defined to the node // CHECK_MSTATUS( addAttribute( aTranslucenceCoeff ) ); CHECK_MSTATUS( addAttribute( aDiffuseReflectivity ) ); CHECK_MSTATUS( addAttribute( aColor ) ); CHECK_MSTATUS( addAttribute( aIncandescence ) ); CHECK_MSTATUS( addAttribute( aInTransparency ) ); CHECK_MSTATUS( addAttribute( aOutColor ) ); CHECK_MSTATUS( addAttribute( aOutTransparency ) ); CHECK_MSTATUS( addAttribute( aNormalCamera ) ); // Only add the parent of the compound CHECK_MSTATUS( addAttribute( aLightData ) ); // The attributeAffects() method is used to indicate when the input // attribute affects the output attribute. This knowledge allows Maya // to optimize dependencies in the graph in more complex nodes where // there may be several inputs and outputs, but not all the inputs // affect all the outputs. // CHECK_MSTATUS( attributeAffects( aTranslucenceCoeff, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aDiffuseReflectivity, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aColor, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aInTransparency, aOutTransparency ) ); CHECK_MSTATUS( attributeAffects( aInTransparency, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aIncandescence, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightIntensityR, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightIntensityB, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightIntensityG, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightIntensity, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aNormalCameraX, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aNormalCameraY, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aNormalCameraZ, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aNormalCamera, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightDirectionX, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightDirectionY, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightDirectionZ, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightDirection, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightAmbient, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightSpecular, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightDiffuse, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightShadowFraction, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aPreShadowIntensity, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightBlindData, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightData, aOutColor ) ); return( MS::kSuccess ); }
/* static */ MStatus cgfxVector::initialize() { MStatus status; MFnNumericAttribute nAttr; MFnMatrixAttribute mAttr; sVectorX = nAttr.create("vectorX", "vx", MFnNumericData::kDouble, 0.0, &status); if (!status) { status.perror("cgfxVector: create vectorX"); return status; } nAttr.setKeyable(true); sVectorY = nAttr.create("vectorY", "vy", MFnNumericData::kDouble, 0.0, &status); if (!status) { status.perror("cgfxVector: create vectorY"); return status; } nAttr.setKeyable(true); sVectorZ = nAttr.create("vectorZ", "vz", MFnNumericData::kDouble, 0.0, &status); if (!status) { status.perror("cgfxVector: create vectorZ"); return status; } nAttr.setKeyable(true); sVector = nAttr.create("vector", "v", sVectorX, sVectorY, sVectorZ, &status); if (!status) { status.perror("cgfxVector: create vector"); return status; } nAttr.setKeyable(true); sIsDirection = nAttr.create("isDirection", "id", MFnNumericData::kBoolean, 0.0, &status); if (!status) { status.perror("cgfxVector: create isDirection"); return status; } nAttr.setKeyable(true); nAttr.setDefault(false); sMatrix = mAttr.create("matrix", "m", MFnMatrixAttribute::kDouble, &status); if (!status) { status.perror("cgfxVector: create matrix"); return status; } mAttr.setWritable(true); mAttr.setStorable(true); sWorldVectorX = nAttr.create("worldVectorX", "wvx", MFnNumericData::kFloat, 0.0, &status); if (!status) { status.perror("cgfxVector: create worldVectorX"); return status; } nAttr.setWritable(false); nAttr.setStorable(false); sWorldVectorY = nAttr.create("worldVectorY", "wvy", MFnNumericData::kFloat, 0.0, &status); if (!status) { status.perror("cgfxVector: create worldVectorY"); return status; } nAttr.setWritable(false); nAttr.setStorable(false); sWorldVectorZ = nAttr.create("worldVectorZ", "wvz", MFnNumericData::kFloat, 0.0, &status); if (!status) { status.perror("cgfxVector: create worldVectorZ"); return status; } nAttr.setWritable(false); nAttr.setStorable(false); sWorldVectorW = nAttr.create("worldVectorW", "wvw", MFnNumericData::kFloat, 0.0, &status); if (!status) { status.perror("cgfxVector: create worldVectorW"); return status; } nAttr.setWritable(false); nAttr.setStorable(false); sWorldVector = nAttr.create("worldVector", "wv", sWorldVectorX, sWorldVectorY, sWorldVectorZ, &status); if( !status ) { status.perror("cgfxVector: create worldVector"); return status; } nAttr.setWritable(false); nAttr.setStorable(false); status = addAttribute(sVector); if (!status) { status.perror("cgfxVector: addAttribute vector"); return status; } status = addAttribute(sIsDirection); if (!status) { status.perror("cgfxVector: addAttribute isDirection"); return status; } status = addAttribute(sMatrix); if (!status) { status.perror("cgfxVector: addAttribute matrix"); return status; } status = addAttribute(sWorldVector); if (!status) { status.perror("cgfxVector: addAttribute worldVector"); return status; } status = addAttribute(sWorldVectorW); if (!status) { status.perror("cgfxVector: addAttribute worldVectorW"); return status; } status = attributeAffects(sVector, sWorldVector); if (!status) { status.perror("cgfxVector: attributeAffects vector -> worldVector"); return status; } status = attributeAffects(sIsDirection, sWorldVector); if (!status) { status.perror("cgfxVector: attributeAffects isDirection -> worldVector"); return status; } status = attributeAffects(sMatrix, sWorldVector); if (!status) { status.perror("cgfxVector: attributeAffects matrix -> worldVector"); return status; } status = attributeAffects(sVector, sWorldVectorW); if (!status) { status.perror("cgfxVector: attributeAffects vector -> worldVectorW"); return status; } status = attributeAffects(sIsDirection, sWorldVectorW); if (!status) { status.perror("cgfxVector: attributeAffects isDirection -> worldVectorW"); return status; } status = attributeAffects(sMatrix, sWorldVectorW); if (!status) { status.perror("cgfxVector: attributeAffects matrix -> worldVectorW"); return status; } return MS::kSuccess; }
MStatus lambert::initialize() { MFnNumericAttribute nAttr; MFnLightDataAttribute lAttr; MStatus status; // Status will be used to hold the MStatus value // returned by each api function call. It is important // to check the status returned by a call to aid in // debugging. Failed API calls can result in subtle // errors that can be difficult to track down, you may // wish to use the CHECK_MSTATUS macro for any API // call where you do not need to provide your own // error handling. // // Attribute Initialization: // // create - The create function creates a new attribute for the // node, it takes a long name for the attribute, a short // name for the attribute, the type of the attribute, // and a status object to determine if the api call was // successful. // // setKeyable - Sets whether this attribute should accept keyframe // data, Attributes are not keyable by default. // // setStorable - Sets whether this attribute should be storable. If an // attribute is storable, then it will be writen out // when the node is stored to a file. Attributes are // storable by default. // // setDefault - Sets the default value for this attribute. // // setUsedAsColor - Sets whether this attribute should be presented as // a color in the UI. // // setHidden - Sets whether this attribute should be hidden from the // UI. This is useful if the attribute is being used for // blind data, or if it is being used as scratch space // for a geometry calculation (should also be marked // non-connectable in that case). Attributes are not // hidden by default. // // setReadable - Sets whether this attribute should be readable. If an // attribute is readable, then it can be used as the // source in a dependency graph connection. Attributes // are readable by default. // // setWritable - Sets whether this attribute should be readable. If an // attribute is writable, then it can be used as the // destination in a dependency graph connection. If an // attribute is not writable then setAttr commands will // fail to change the attribute. If both keyable and // writable for an attribute are set to true it will be // displayed in the channel box when the node is // selected. Attributes are writable by default. // // setArray - Sets whether this attribute should have an array of // data. This should be set to true if the attribute // needs to accept multiple incoming connections. // Attributes are single elements by default. // // Input Attributes // aTranslucenceCoeff = nAttr.create( "translucenceCoeff", "tc", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.0f ) ); aDiffuseReflectivity = nAttr.create( "diffuseReflectivity", "drfl", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.8f ) ); aColorR = nAttr.create( "colorR", "cr",MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.0f ) ); aColorG = nAttr.create( "colorG", "cg", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.58824f ) ); aColorB = nAttr.create( "colorB", "cb",MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.644f ) ); aColor = nAttr.create( "color", "c", aColorR, aColorG, aColorB, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.58824f, 0.644f ) ); CHECK_MSTATUS( nAttr.setUsedAsColor( true ) ); aIncandescenceR = nAttr.create( "incandescenceR", "ir", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.0f ) ); aIncandescenceG = nAttr.create( "incandescenceG", "ig", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.0f ) ); aIncandescenceB = nAttr.create( "incandescenceB", "ib", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.0f ) ); aIncandescence = nAttr.create( "incandescence", "ic", aIncandescenceR, aIncandescenceG, aIncandescenceB, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.0f, 0.0f ) ); CHECK_MSTATUS( nAttr.setUsedAsColor( true ) ); aInTransR = nAttr.create( "transparencyR", "itr", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); aInTransG = nAttr.create( "transparencyG", "itg", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); aInTransB = nAttr.create( "transparencyB", "itb", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); aInTransparency = nAttr.create( "transparency", "it", aInTransR, aInTransG, aInTransB, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setKeyable( true ) ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 0.0f, 0.0f, 0.0f ) ); CHECK_MSTATUS( nAttr.setUsedAsColor( true ) ); // Output Attributes // // Color Output // aOutColorR = nAttr.create( "outColorR", "ocr", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); aOutColorG = nAttr.create( "outColorG", "ocg", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); aOutColorB = nAttr.create( "outColorB", "ocb", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); aOutColor = nAttr.create( "outColor", "oc", aOutColorR, aOutColorG, aOutColorB, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setHidden( false ) ); CHECK_MSTATUS( nAttr.setReadable( true ) ); CHECK_MSTATUS( nAttr.setWritable( false ) ); // Transparency Output // aOutTransR = nAttr.create( "outTransparencyR", "otr", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); aOutTransG = nAttr.create( "outTransparencyG", "otg", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); aOutTransB = nAttr.create( "outTransparencyB", "otb", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); aOutTransparency = nAttr.create( "outTransparency", "ot", aOutTransR,aOutTransG,aOutTransB, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setHidden( false ) ); CHECK_MSTATUS( nAttr.setReadable( true ) ); CHECK_MSTATUS( nAttr.setWritable( false ) ); // Camera Normals // aNormalCameraX = nAttr.create( "normalCameraX", "nx", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable( false ) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aNormalCameraY = nAttr.create( "normalCameraY", "ny", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable( false ) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aNormalCameraZ = nAttr.create( "normalCameraZ", "nz", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable( false ) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aNormalCamera = nAttr.create( "normalCamera","n", aNormalCameraX, aNormalCameraY, aNormalCameraZ, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable( false ) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) ); CHECK_MSTATUS( nAttr.setHidden( true ) ); // Light Direction // aLightDirectionX = nAttr.create( "lightDirectionX", "ldx", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aLightDirectionY = nAttr.create( "lightDirectionY", "ldy", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aLightDirectionZ = nAttr.create( "lightDirectionZ", "ldz", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aLightDirection = nAttr.create( "lightDirection", "ld", aLightDirectionX, aLightDirectionY, aLightDirectionZ, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) ); // Light Intensity // aLightIntensityR = nAttr.create( "lightIntensityR", "lir", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aLightIntensityG = nAttr.create( "lightIntensityG", "lig", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aLightIntensityB = nAttr.create( "lightIntensityB", "lib", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aLightIntensity = nAttr.create( "lightIntensity", "li", aLightIntensityR, aLightIntensityG, aLightIntensityB, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f, 1.0f, 1.0f ) ); // Light // aLightAmbient = nAttr.create( "lightAmbient", "la", MFnNumericData::kBoolean, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( true ) ); aLightDiffuse = nAttr.create( "lightDiffuse", "ldf", MFnNumericData::kBoolean, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( true ) ); aLightSpecular = nAttr.create( "lightSpecular", "ls", MFnNumericData::kBoolean, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( false ) ); aLightShadowFraction = nAttr.create( "lightShadowFraction", "lsf", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aPreShadowIntensity = nAttr.create( "preShadowIntensity", "psi", MFnNumericData::kFloat, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); aLightBlindData = nAttr.createAddr( "lightBlindData", "lbld", &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightData = lAttr.create( "lightDataArray", "ltd", aLightDirection, aLightIntensity, aLightAmbient, aLightDiffuse, aLightSpecular, aLightShadowFraction, aPreShadowIntensity, aLightBlindData, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( lAttr.setArray( true ) ); CHECK_MSTATUS( lAttr.setStorable( false ) ); CHECK_MSTATUS( lAttr.setHidden( true ) ); CHECK_MSTATUS( lAttr.setDefault( 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, true, true, false, 1.0f, 1.0f, NULL ) ); // Next we will add the attributes we have defined to the node // CHECK_MSTATUS( addAttribute( aTranslucenceCoeff ) ); CHECK_MSTATUS( addAttribute( aDiffuseReflectivity ) ); CHECK_MSTATUS( addAttribute( aColor ) ); CHECK_MSTATUS( addAttribute( aIncandescence ) ); CHECK_MSTATUS( addAttribute( aInTransparency ) ); CHECK_MSTATUS( addAttribute( aOutColor ) ); CHECK_MSTATUS( addAttribute( aOutTransparency ) ); CHECK_MSTATUS( addAttribute( aNormalCamera ) ); // Only add the parent of the compound CHECK_MSTATUS( addAttribute( aLightData ) ); // The attributeAffects() method is used to indicate when the input // attribute affects the output attribute. This knowledge allows Maya // to optimize dependencies in the graph in more complex nodes where // there may be several inputs and outputs, but not all the inputs // affect all the outputs. // CHECK_MSTATUS( attributeAffects( aTranslucenceCoeff, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aDiffuseReflectivity, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aColorR, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aColorG, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aColorB, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aColor, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aInTransR, aOutTransparency ) ); CHECK_MSTATUS( attributeAffects( aInTransG, aOutTransparency ) ); CHECK_MSTATUS( attributeAffects( aInTransB, aOutTransparency ) ); CHECK_MSTATUS( attributeAffects( aInTransparency, aOutTransparency ) ); CHECK_MSTATUS( attributeAffects( aInTransparency, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aIncandescenceR, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aIncandescenceG, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aIncandescenceB, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aIncandescence, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightIntensityR, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightIntensityB, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightIntensityG, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightIntensity, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aNormalCameraX, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aNormalCameraY, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aNormalCameraZ, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aNormalCamera, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightDirectionX, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightDirectionY, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightDirectionZ, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightDirection, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightAmbient, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightSpecular, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightDiffuse, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightShadowFraction, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aPreShadowIntensity, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightBlindData, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aLightData, aOutColor ) ); return( MS::kSuccess ); }
MStatus MG_softIk::initialize() { //This is the nurbs input attribute MFnTypedAttribute typedFn; MFnCompoundAttribute compund; MFnNumericAttribute numFn; MFnMatrixAttribute matrixFn; startMatrix =matrixFn.create("startMatrix","stm"); addAttribute(startMatrix); endMatrix =matrixFn.create("endMatrix","enm"); addAttribute(endMatrix); upInitLength = numFn.create("upInitLength","uil",MFnNumericData::kDouble,0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(upInitLength); downInitLength = numFn.create("downInitLength","dil",MFnNumericData::kDouble,0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(downInitLength); globalScale = numFn.create("globalScale","gb",MFnNumericData::kDouble,0); numFn.setStorable(true); numFn.setKeyable(true); numFn.setMin(0.001); addAttribute(globalScale); softDistance = numFn.create("softDistance","sd",MFnNumericData::kDouble,0); numFn.setMin(0.001); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(softDistance); stretch = numFn.create("stretch","str",MFnNumericData::kDouble,0); numFn.setMin(0.0); numFn.setMax(1.0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(stretch); slide = numFn.create("slide","sld",MFnNumericData::kDouble,0.5); numFn.setMin(0.0); numFn.setMax(1.0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(slide); upScale = numFn.create("upScale","ups",MFnNumericData::kDouble,1); numFn.setStorable(false); numFn.setKeyable(false); numFn.setWritable(false); addAttribute(upScale); downScale = numFn.create("downScale","dws",MFnNumericData::kDouble,1); numFn.setStorable(false); numFn.setKeyable(false); numFn.setWritable(false); addAttribute(downScale); outputTranslateX = numFn.create("outputTranslateX","otx",MFnNumericData::kDouble,0); numFn.setStorable(false); numFn.setKeyable(false); numFn.setWritable(false); addAttribute(outputTranslateX); outputTranslateY = numFn.create("outputTranslateY","oty",MFnNumericData::kDouble,0); numFn.setStorable(false); numFn.setWritable(false); numFn.setKeyable(false); addAttribute(outputTranslateY); outputTranslateZ = numFn.create("outputTranslateZ","otz",MFnNumericData::kDouble,0); numFn.setStorable(false); numFn.setKeyable(false); numFn.setWritable(false); addAttribute(outputTranslateZ); outputTranslate= compund.create("outputTranslate","ot"); compund.addChild(outputTranslateX); compund.addChild(outputTranslateY); compund.addChild(outputTranslateZ); compund.setStorable(false); compund.setKeyable(false); compund.setWritable(false); addAttribute(outputTranslate); attributeAffects( startMatrix ,outputTranslate) ; attributeAffects( endMatrix ,outputTranslate) ; attributeAffects( softDistance ,outputTranslate) ; attributeAffects( stretch ,outputTranslate) ; attributeAffects( slide ,outputTranslate) ; attributeAffects( globalScale ,outputTranslate) ; attributeAffects( startMatrix ,upScale) ; attributeAffects( endMatrix ,upScale) ; attributeAffects( stretch ,upScale) ; attributeAffects( softDistance ,upScale) ; attributeAffects( slide ,upScale) ; attributeAffects( globalScale ,upScale) ; attributeAffects( startMatrix ,downScale) ; attributeAffects( endMatrix ,downScale) ; attributeAffects( softDistance ,downScale) ; attributeAffects( stretch ,downScale) ; attributeAffects( slide ,downScale) ; attributeAffects( globalScale ,downScale) ; 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; }
// // DESCRIPTION: /////////////////////////////////////////////////////// MStatus clearcoat::initialize() { MFnNumericAttribute nAttr; MFnCompoundAttribute cAttr; aIndex = nAttr.create( "index", "ix", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(true) ); CHECK_MSTATUS ( nAttr.setDefault(1.8f) ); CHECK_MSTATUS ( nAttr.setSoftMin(1.0f) ); CHECK_MSTATUS ( nAttr.setSoftMax(5.0f) ); aScale = nAttr.create( "scale", "s", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(true) ); CHECK_MSTATUS ( nAttr.setDefault(1.55f) ); CHECK_MSTATUS ( nAttr.setSoftMin(0.0f) ); CHECK_MSTATUS ( nAttr.setSoftMax(5.0f) ); aBias = nAttr.create( "bias", "b", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(true) ); CHECK_MSTATUS ( nAttr.setDefault(-0.1f) ); CHECK_MSTATUS ( nAttr.setSoftMin(-1.0f) ); CHECK_MSTATUS ( nAttr.setSoftMax( 1.0f) ); aNormalCameraX = nAttr.create( "normalCameraX", "nx", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setDefault(1.0f) ); aNormalCameraY = nAttr.create( "normalCameraY", "ny", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false)); CHECK_MSTATUS ( nAttr.setDefault(1.0f) ); aNormalCameraZ = nAttr.create( "normalCameraZ", "nz", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setDefault(1.0f) ); aNormalCamera = nAttr.create( "normalCamera","n", aNormalCameraX, aNormalCameraY, aNormalCameraZ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f)); CHECK_MSTATUS ( nAttr.setHidden(true) ); aRayDirectionX = nAttr.create( "rayDirectionX", "rx", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setDefault(1.0f) ); aRayDirectionY = nAttr.create( "rayDirectionY", "ry", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false)); CHECK_MSTATUS ( nAttr.setDefault(1.0f)); aRayDirectionZ = nAttr.create( "rayDirectionZ", "rz", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setDefault(1.0f) ); aRayDirection = nAttr.create( "rayDirection","r", aRayDirectionX, aRayDirectionY, aRayDirectionZ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); // Outputs aOutValue = nAttr.create( "outValue", "ov", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setHidden(false) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS ( addAttribute(aIndex)); CHECK_MSTATUS ( addAttribute(aScale) ); CHECK_MSTATUS ( addAttribute(aBias) ); // compound attribute - only need to add parent CHECK_MSTATUS ( addAttribute(aNormalCamera) ); // compound attribute - only need to add parent CHECK_MSTATUS ( addAttribute(aRayDirection) ); CHECK_MSTATUS ( addAttribute(aOutValue) ); CHECK_MSTATUS ( attributeAffects (aIndex, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aScale, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aBias, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aNormalCameraX, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aNormalCameraY, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aNormalCameraZ, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aNormalCamera, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aRayDirectionX, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aRayDirectionY, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aRayDirectionZ, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aRayDirection, aOutValue) ); return MS::kSuccess; }
MStatus wingVizNode::initialize() { MStatus stat; MFnNumericAttribute numAttr; MFnTypedAttribute meshAttr; awidth0 = numAttr.create( "width0", "w0", MFnNumericData::kFloat, 0.5 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( awidth0 ); awidth1 = numAttr.create( "width1", "w1", MFnNumericData::kFloat, 0.2 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( awidth1 ); aedge0 = numAttr.create( "edge0", "e0", MFnNumericData::kFloat, 0.9 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( aedge0 ); aedge1 = numAttr.create( "edge1", "e1", MFnNumericData::kFloat, 0.2 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( aedge1 ); atwist0 = numAttr.create( "twist0", "tw0", MFnNumericData::kFloat, 0.0 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( atwist0 ); atwist1 = numAttr.create( "twist1", "tw1", MFnNumericData::kFloat, 60.0 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( atwist1 ); areverse = numAttr.create( "reverse", "re", MFnNumericData::kInt, 0 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( areverse ); astep = numAttr.create( "step", "st", MFnNumericData::kInt, 4 ); numAttr.setStorable(true); numAttr.setKeyable(true); numAttr.setMin(1); addAttribute( astep ); ashaft0 = numAttr.create( "shaftWidth0", "shw0", MFnNumericData::kFloat, 0.25 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( ashaft0 ); ashaft1 = numAttr.create( "shaftWidth1", "shw1", MFnNumericData::kFloat, 0.20 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( ashaft1 ); aminframe = numAttr.create( "startFrame", "sf", MFnNumericData::kInt, 1 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( aminframe ); amaxframe = numAttr.create( "saveCache", "saveCache", MFnNumericData::kInt, 0 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( amaxframe ); aratio = numAttr.create( "scale", "sc", MFnNumericData::kFloat, 1.0 ); numAttr.setStorable(true); numAttr.setKeyable(true); numAttr.setMin(0.01f); numAttr.setInternal(true); addAttribute( aratio ); awind = numAttr.create( "wind", "wnd", MFnNumericData::kFloat, 1.0 ); numAttr.setStorable(true); numAttr.setKeyable(true); numAttr.setMin(0.01f); numAttr.setInternal(true); addAttribute( awind ); aoutval = numAttr.create( "outval", "ov", MFnNumericData::kInt, 1 ); numAttr.setStorable(false); numAttr.setWritable(false); numAttr.setKeyable(false); addAttribute( aoutval ); MFnTypedAttribute stringAttr; acachename = stringAttr.create( "cachePath", "cp", MFnData::kString ); stringAttr.setStorable(true); stringAttr.setInternal(true); addAttribute( acachename ); zCheckStatus(zWorks::createTypedAttr(agrowth, MString("growMesh"), MString("gm"), MFnData::kNurbsSurface ), "ERROR creating grow mesh"); zCheckStatus(addAttribute(agrowth), "ERROR adding ing base"); zCheckStatus(zWorks::createTypedAttr(acollision, MString("collideMesh"), MString("cm"), MFnData::kMesh), "ERROR creating collide mesh"); zCheckStatus(addAttribute(acollision), "ERROR adding collide mesh"); zCheckStatus(zWorks::createTimeAttr(atime, MString("currentTime"), MString("ct"), 1.0), "ERROR creating time"); zCheckStatus(addAttribute(atime), "ERROR adding time"); zCheckStatus(zWorks::createTypedAttr(outMesh, MString("outMesh"), MString("om"), MFnData::kMesh), "ERROR creating out mesh"); zCheckStatus(addAttribute(outMesh), "ERROR adding out mesh"); aouttexcoordoffsetpp = meshAttr.create( "outTexcoordOffset", "oto", MFnData::kDoubleArray ); meshAttr.setStorable(false); meshAttr.setWritable(false); addAttribute( aouttexcoordoffsetpp ); anoisize = numAttr.create( "noiseSize", "nsz", MFnNumericData::kFloat, 1.0 ); numAttr.setStorable(true); numAttr.setKeyable(true); addAttribute( anoisize ); anoifreq = numAttr.create( "noiseFrequency", "nfq", MFnNumericData::kFloat, 8.0 ); numAttr.setStorable(true); numAttr.setMin(0.01); numAttr.setKeyable(true); addAttribute( anoifreq ); anoiseed = numAttr.create( "noiseSeed", "nsd", MFnNumericData::kInt, 19 ); numAttr.setStorable(true); numAttr.setKeyable(true); numAttr.setMin(10); addAttribute( anoiseed ); attributeAffects( areverse, aoutval ); attributeAffects( awidth0, aoutval ); attributeAffects( awidth1, aoutval ); attributeAffects( aedge0, aoutval ); attributeAffects( aedge1, aoutval ); attributeAffects( atwist0, aoutval ); attributeAffects( atwist1, aoutval ); attributeAffects( ashaft0, aoutval ); attributeAffects( ashaft1, aoutval ); attributeAffects( atime, aoutval ); attributeAffects( aratio, aoutval ); attributeAffects( agrowth, aoutval ); attributeAffects( acollision, aoutval ); attributeAffects( astep, aoutval ); attributeAffects( areverse, outMesh ); attributeAffects( awidth0, outMesh ); attributeAffects( awidth1, outMesh ); attributeAffects( aedge0, outMesh ); attributeAffects( aedge1, outMesh ); attributeAffects( atwist0, outMesh ); attributeAffects( atwist1, outMesh ); attributeAffects( ashaft0, outMesh ); attributeAffects( ashaft1, outMesh ); attributeAffects( atime, outMesh ); attributeAffects( aratio, outMesh ); attributeAffects( agrowth, outMesh ); attributeAffects( acollision, outMesh ); attributeAffects( astep, outMesh ); attributeAffects( anoisize, outMesh ); attributeAffects( anoifreq, outMesh ); attributeAffects( anoiseed, outMesh ); attributeAffects( areverse, aouttexcoordoffsetpp ); attributeAffects( agrowth, aouttexcoordoffsetpp ); attributeAffects( astep, aouttexcoordoffsetpp ); return MS::kSuccess; }