MStatus pointOnSubd::initialize() // // Description: // 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. // // Return Values: // MS::kSuccess // MS::kFailure // { MStatus stat; MFnTypedAttribute subdAttr; aSubd = subdAttr.create( "subd", "s", MFnSubdData::kSubdSurface, &stat ); McheckErr( stat, "cannot create pointOnSubd::aSubd" ); subdAttr.setStorable(true); subdAttr.setKeyable(false); subdAttr.setReadable( true ); subdAttr.setWritable( true ); subdAttr.setCached( false ); stat = addAttribute( pointOnSubd::aSubd ); McheckErr( stat, "cannot add pointOnSubd::aSubd" ); MFnNumericAttribute faceFirstAttr; aFaceFirst = faceFirstAttr.create( "faceFirst", "ff", MFnNumericData::kLong, 0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aFaceFirst" ); faceFirstAttr.setStorable(true); faceFirstAttr.setKeyable(true); faceFirstAttr.setSoftMin( 0.0 ); faceFirstAttr.setReadable( true ); faceFirstAttr.setWritable( true ); faceFirstAttr.setCached( false ); stat = addAttribute( pointOnSubd::aFaceFirst ); McheckErr( stat, "cannot add pointOnSubd::aFaceFirst" ); MFnNumericAttribute faceSecondAttr; aFaceSecond = faceSecondAttr.create( "faceSecond", "fs", MFnNumericData::kLong, 0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aFaceSecond" ); faceSecondAttr.setStorable(true); faceSecondAttr.setKeyable(true); faceSecondAttr.setSoftMin( 0.0 ); faceSecondAttr.setReadable( true ); faceSecondAttr.setWritable( true ); faceSecondAttr.setCached( false ); stat = addAttribute( pointOnSubd::aFaceSecond ); McheckErr( stat, "cannot add pointOnSubd::aFaceSecond" ); MFnNumericAttribute uAttr; aU = uAttr.create( "uValue", "u", MFnNumericData::kDouble, 0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aU" ); uAttr.setStorable(true); uAttr.setKeyable(true); uAttr.setSoftMin( 0.0 ); uAttr.setSoftMax( 1.0 ); uAttr.setReadable( true ); uAttr.setWritable( true ); uAttr.setCached( false ); stat = addAttribute( aU ); McheckErr( stat, "cannot add pointOnSubd::aU" ); MFnNumericAttribute vAttr; aV = vAttr.create( "vValue", "v", MFnNumericData::kDouble, 0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aV" ); vAttr.setStorable(true); vAttr.setKeyable(true); vAttr.setSoftMin( 0.0 ); vAttr.setSoftMax( 1.0 ); vAttr.setReadable( true ); vAttr.setWritable( true ); vAttr.setCached( false ); stat = addAttribute( aV ); McheckErr( stat, "cannot add pointOnSubd::aV" ); MFnNumericAttribute relAttr; aRelativeUV = relAttr.create( "relative", "rel", MFnNumericData::kBoolean, 0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aRelativeUV" ); relAttr.setStorable(true); relAttr.setKeyable(true); relAttr.setSoftMin( 0.0 ); relAttr.setSoftMax( 1.0 ); relAttr.setReadable( true ); relAttr.setWritable( true ); relAttr.setCached( false ); stat = addAttribute( pointOnSubd::aRelativeUV ); McheckErr( stat, "cannot add pointOnSubd::aRelativeUV" ); MFnNumericAttribute pointXAttr; aPointX = pointXAttr.create( "pointX", "px", MFnNumericData::kDouble, 0.0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aPointX" ); pointXAttr.setWritable(false); pointXAttr.setStorable(false); pointXAttr.setReadable( true ); pointXAttr.setCached( true ); stat = addAttribute( aPointX ); McheckErr( stat, "cannot add pointOnSubd::aPointX" ); MFnNumericAttribute pointYAttr; aPointY = pointYAttr.create( "pointY", "py", MFnNumericData::kDouble, 0.0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aPointY" ); pointYAttr.setWritable(false); pointYAttr.setStorable(false); pointYAttr.setReadable( true ); pointYAttr.setCached( true ); stat = addAttribute( aPointY ); McheckErr( stat, "cannot add pointOnSubd::aPointY" ); MFnNumericAttribute pointZAttr; aPointZ = pointZAttr.create( "pointZ", "pz", MFnNumericData::kDouble, 0.0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aPointZ" ); pointZAttr.setWritable(false); pointZAttr.setStorable(false); pointZAttr.setReadable( true ); pointZAttr.setCached( true ); stat = addAttribute( aPointZ ); McheckErr( stat, "cannot add pointOnSubd::aPointZ" ); MFnNumericAttribute pointAttr; aPoint = pointAttr.create( "point", "p", aPointX, aPointY, aPointZ, &stat); McheckErr( stat, "cannot create pointOnSubd::aPoint" ); pointAttr.setWritable(false); pointAttr.setStorable(false); pointAttr.setReadable( true ); pointAttr.setCached( true ); stat = addAttribute( aPoint ); McheckErr( stat, "cannot add pointOnSubd::aPoint" ); MFnNumericAttribute normalXAttr; aNormalX = normalXAttr.create( "normalX", "nx", MFnNumericData::kDouble, 0.0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aNormal" ); normalXAttr.setWritable(false); normalXAttr.setStorable(false); normalXAttr.setReadable( true ); normalXAttr.setCached( true ); stat = addAttribute( aNormalX ); McheckErr( stat, "cannot add pointOnSubd::aNormalX" ); MFnNumericAttribute normalYAttr; aNormalY = normalYAttr.create( "normalY", "ny", MFnNumericData::kDouble, 0.0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aNormal" ); normalYAttr.setWritable(false); normalYAttr.setStorable(false); normalYAttr.setReadable( true ); normalYAttr.setCached( true ); stat = addAttribute( aNormalY ); McheckErr( stat, "cannot add pointOnSubd::aNormalY" ); MFnNumericAttribute normalZAttr; aNormalZ = normalZAttr.create( "normalZ", "nz", MFnNumericData::kDouble, 0.0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aNormal" ); normalZAttr.setWritable(false); normalZAttr.setStorable(false); normalZAttr.setReadable( true ); normalZAttr.setCached( true ); stat = addAttribute( aNormalZ ); McheckErr( stat, "cannot add pointOnSubd::aNormalZ" ); MFnNumericAttribute normalAttr; aNormal = normalAttr.create("normal","n",aNormalX,aNormalY,aNormalZ,&stat); McheckErr( stat, "cannot create pointOnSubd::aNormal" ); normalAttr.setWritable(false); normalAttr.setStorable(false); normalAttr.setReadable( true ); normalAttr.setCached( true ); stat = addAttribute( aNormal ); McheckErr( stat, "cannot add pointOnSubd::aNormal" ); // 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. // stat = attributeAffects( aSubd, aPoint ); stat = attributeAffects( aSubd, aPointX ); stat = attributeAffects( aSubd, aPointY ); stat = attributeAffects( aSubd, aPointZ ); stat = attributeAffects( aSubd, aNormal ); stat = attributeAffects( aSubd, aNormalX ); stat = attributeAffects( aSubd, aNormalY ); stat = attributeAffects( aSubd, aNormalZ ); stat = attributeAffects( aFaceFirst, aPoint ); stat = attributeAffects( aFaceFirst, aPointX ); stat = attributeAffects( aFaceFirst, aPointY ); stat = attributeAffects( aFaceFirst, aPointZ ); stat = attributeAffects( aFaceFirst, aNormal ); stat = attributeAffects( aFaceFirst, aNormalX ); stat = attributeAffects( aFaceFirst, aNormalY ); stat = attributeAffects( aFaceFirst, aNormalZ ); stat = attributeAffects( aFaceSecond, aPoint ); stat = attributeAffects( aFaceSecond, aPointX ); stat = attributeAffects( aFaceSecond, aPointY ); stat = attributeAffects( aFaceSecond, aPointZ ); stat = attributeAffects( aFaceSecond, aNormal ); stat = attributeAffects( aFaceSecond, aNormalX ); stat = attributeAffects( aFaceSecond, aNormalY ); stat = attributeAffects( aFaceSecond, aNormalZ ); stat = attributeAffects( aU, aPoint ); stat = attributeAffects( aU, aPointX ); stat = attributeAffects( aU, aPointY ); stat = attributeAffects( aU, aPointZ ); stat = attributeAffects( aU, aNormal ); stat = attributeAffects( aU, aNormalX ); stat = attributeAffects( aU, aNormalY ); stat = attributeAffects( aU, aNormalZ ); stat = attributeAffects( aV, aPoint ); stat = attributeAffects( aV, aPointX ); stat = attributeAffects( aV, aPointY ); stat = attributeAffects( aV, aPointZ ); stat = attributeAffects( aV, aNormal ); stat = attributeAffects( aV, aNormalX ); stat = attributeAffects( aV, aNormalY ); stat = attributeAffects( aV, aNormalZ ); stat = attributeAffects( aRelativeUV, aPoint ); stat = attributeAffects( aRelativeUV, aPointX ); stat = attributeAffects( aRelativeUV, aPointY ); stat = attributeAffects( aRelativeUV, aPointZ ); stat = attributeAffects( aRelativeUV, aNormal ); stat = attributeAffects( aRelativeUV, aNormalX ); stat = attributeAffects( aRelativeUV, aNormalY ); stat = attributeAffects( aRelativeUV, aNormalZ ); return MS::kSuccess; }
// // 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; }
// 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. // MStatus hwColorPerVertexShader::initialize() { MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; MStatus status; // Create input attributes. // All attributes are cached internal // aColorGain = nAttr.createColor( "colorGain", "cg", &status); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable(true)); CHECK_MSTATUS( nAttr.setKeyable(true)); CHECK_MSTATUS( nAttr.setDefault(1.f, 1.f, 1.f)); nAttr.setCached( true ); nAttr.setInternal( true ); aTranspGain = nAttr.create("transparencyGain", "tg", MFnNumericData::kFloat, 1.f, &status); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable(true)); CHECK_MSTATUS( nAttr.setKeyable(true)); CHECK_MSTATUS( nAttr.setDefault(1.f)); CHECK_MSTATUS( nAttr.setSoftMin(0.f)); CHECK_MSTATUS( nAttr.setSoftMax(2.f)); nAttr.setCached( true ); nAttr.setInternal( true ); aColorBias = nAttr.createColor( "colorBias", "cb", &status); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable(true)); CHECK_MSTATUS( nAttr.setKeyable(true)); CHECK_MSTATUS( nAttr.setDefault(0.f, 0.f, 0.f)); nAttr.setCached( true ); nAttr.setInternal( true ); aTranspBias = nAttr.create( "transparencyBias", "tb", MFnNumericData::kFloat, 0.f, &status); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable(true)); CHECK_MSTATUS( nAttr.setKeyable(true)); CHECK_MSTATUS( nAttr.setDefault(0.f)); CHECK_MSTATUS( nAttr.setSoftMin(-1.f)); CHECK_MSTATUS( nAttr.setSoftMax(1.f)); nAttr.setCached( true ); nAttr.setInternal( true ); aNormalsPerVertex = nAttr.create("normalsPerVertex", "nv", MFnNumericData::kInt, 0, &status); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable(true)); CHECK_MSTATUS( nAttr.setKeyable(false)); CHECK_MSTATUS( nAttr.setDefault(0)); CHECK_MSTATUS( nAttr.setSoftMin(0)); CHECK_MSTATUS( nAttr.setSoftMax(3)); nAttr.setCached( true ); nAttr.setInternal( true ); aColorsPerVertex = nAttr.create("colorsPerVertex", "cv", MFnNumericData::kInt, 0, &status); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable(true)); CHECK_MSTATUS( nAttr.setKeyable(false)); CHECK_MSTATUS( nAttr.setDefault(0)); CHECK_MSTATUS( nAttr.setSoftMin(0)); CHECK_MSTATUS( nAttr.setSoftMax(5)); nAttr.setCached( true ); nAttr.setInternal( true ); aColorSetName = tAttr.create("colorSetName", "cs", MFnData::kString, MObject::kNullObj, &status); CHECK_MSTATUS( status ); CHECK_MSTATUS( tAttr.setStorable(true)); CHECK_MSTATUS( tAttr.setKeyable(false)); tAttr.setCached( true ); tAttr.setInternal( true ); aTexRotateX = nAttr.create( "texRotateX", "tx", MFnNumericData::kFloat, 0.f, &status); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable(true)); CHECK_MSTATUS( nAttr.setKeyable(true)); CHECK_MSTATUS( nAttr.setDefault(0.f)); nAttr.setCached( true ); nAttr.setInternal( true ); aTexRotateY = nAttr.create( "texRotateY", "ty", MFnNumericData::kFloat, 0.f, &status); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable(true)); CHECK_MSTATUS( nAttr.setKeyable(true)); CHECK_MSTATUS( nAttr.setDefault(0.f)); nAttr.setCached( true ); nAttr.setInternal( true ); aTexRotateZ = nAttr.create( "texRotateZ", "tz", MFnNumericData::kFloat, 0.f, &status); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable(true)); CHECK_MSTATUS( nAttr.setKeyable(true)); CHECK_MSTATUS( nAttr.setDefault(0.f)); nAttr.setCached( true ); nAttr.setInternal( true ); // create output attributes here // outColor is the only output attribute and it is inherited // so we do not need to create or add it. // // Add the attributes here CHECK_MSTATUS( addAttribute(aColorGain)); CHECK_MSTATUS( addAttribute(aTranspGain)); CHECK_MSTATUS( addAttribute(aColorBias)); CHECK_MSTATUS( addAttribute(aTranspBias)); CHECK_MSTATUS( addAttribute(aNormalsPerVertex)); CHECK_MSTATUS( addAttribute(aColorsPerVertex)); CHECK_MSTATUS( addAttribute(aColorSetName)); CHECK_MSTATUS( addAttribute(aTexRotateX)); CHECK_MSTATUS( addAttribute(aTexRotateY)); CHECK_MSTATUS( addAttribute(aTexRotateZ)); CHECK_MSTATUS( attributeAffects (aColorGain, outColor)); CHECK_MSTATUS( attributeAffects (aTranspGain, outColor)); CHECK_MSTATUS( attributeAffects (aColorBias, outColor)); CHECK_MSTATUS( attributeAffects (aTranspBias, outColor)); CHECK_MSTATUS( attributeAffects (aNormalsPerVertex, outColor)); CHECK_MSTATUS( attributeAffects (aColorsPerVertex, outColor)); CHECK_MSTATUS( attributeAffects (aColorSetName, outColor)); CHECK_MSTATUS( attributeAffects (aTexRotateX, outColor)); CHECK_MSTATUS( attributeAffects (aTexRotateY, outColor)); CHECK_MSTATUS( attributeAffects (aTexRotateZ, outColor)); return MS::kSuccess; }
MStatus uiDrawManager::initialize() { MStatus status; MFnNumericAttribute nAttr; MFnEnumAttribute eAttr; MFnTypedAttribute typedAttr; // Add ui type attribute aUIType = eAttr.create("uiType", "ut", uiDrawManager::kText); eAttr.addField("text", uiDrawManager::kText); eAttr.addField("line", uiDrawManager::kLine); eAttr.addField("point", uiDrawManager::kPoint); eAttr.addField("rect", uiDrawManager::kRect); eAttr.addField("quad", uiDrawManager::kQuad); eAttr.addField("sphere", uiDrawManager::kSphere); eAttr.addField("circle", uiDrawManager::kCircle); eAttr.addField("arc", uiDrawManager::kArc); eAttr.addField("line list", uiDrawManager::kLineList); eAttr.addField("line strip", uiDrawManager::kLineStrip); eAttr.addField("point list", uiDrawManager::kPointList); eAttr.addField("icon", uiDrawManager::kIcon); eAttr.addField("cone", uiDrawManager::kCone); eAttr.addField("box", uiDrawManager::kBox); MPxNode::addAttribute(aUIType); // Add color attribute aPrimitiveColor = nAttr.create("primitiveColor", "pc", MFnNumericData::k3Float); nAttr.setDefault(1.0f, 0.0f, 0.0f); nAttr.setUsedAsColor(true); MPxNode::addAttribute(aPrimitiveColor); // Add transparency attribute aPrimitiveTransparency = nAttr.create("primitiveTransparency", "pt", MFnNumericData::kFloat, 0.0); nAttr.setSoftMin(0.0); nAttr.setSoftMax(1.0); MPxNode::addAttribute(aPrimitiveTransparency); // add line width and line style attributes aLineWidth = nAttr.create("lineWidth", "lw", MFnNumericData::kFloat, 2.0); MPxNode::addAttribute(aLineWidth); aLineStyle = eAttr.create("lineStyle", "ls", MUIDrawManager::kSolid); eAttr.addField("solid", MUIDrawManager::kSolid); eAttr.addField("shortdotted", MUIDrawManager::kShortDotted); eAttr.addField("shortdashed", MUIDrawManager::kShortDashed); eAttr.addField("dashed", MUIDrawManager::kDashed); eAttr.addField("dotted", MUIDrawManager::kDotted); MPxNode::addAttribute(aLineStyle); // Add filled attribute aIsFilled = nAttr.create("isFilled", "if", MFnNumericData::kBoolean, 0); MPxNode::addAttribute(aIsFilled); // Add shaded attribute aShaded = nAttr.create("shaded", "sd", MFnNumericData::kBoolean, 0); MPxNode::addAttribute(aShaded); // Add radius attribute aRadius = nAttr.create("radius", "ra", MFnNumericData::kDouble, 1.0); MPxNode::addAttribute(aRadius); // add 2D attributes aDraw2D = nAttr.create("draw2D", "d2", MFnNumericData::kBoolean, 0); MPxNode::addAttribute(aDraw2D); aPosition = nAttr.create("position", "pos", MFnNumericData::k3Double); nAttr.setDefault(0.0, 0.0, 0.001); MPxNode::addAttribute(aPosition); // Add text attributes. MFnStringData stringFn; MObject defaultText = stringFn.create("uiDrawManager-Text"); aText = typedAttr.create("text", "t", MFnData::kString, defaultText); MPxNode::addAttribute(aText); aTextFontSize = nAttr.create("textFontSize", "tfs", MFnNumericData::kInt, MUIDrawManager::kDefaultFontSize); nAttr.setMin(-1); nAttr.setMax(99); MPxNode::addAttribute(aTextFontSize); unsigned int nFont = MUIDrawManager::getFontList(uiDrawManagerData::fFontList); if (nFont == 0) { perror("No font available!"); } aFontFaceName = eAttr.create("fontFaceName", "ffn", 0); for (unsigned int i = 0; i < nFont; i++) { MString str = uiDrawManagerData::fFontList[i]; eAttr.addField(str, (short)i); } MPxNode::addAttribute(aFontFaceName); aTextAlignment = eAttr.create("textAlignment", "ta", MUIDrawManager::kLeft); eAttr.addField("left", MUIDrawManager::kLeft); eAttr.addField("center", MUIDrawManager::kCenter); eAttr.addField("right", MUIDrawManager::kRight); MPxNode::addAttribute(aTextAlignment); eTextIncline = eAttr.create("textIncline", "tic", MUIDrawManager::kInclineNormal); eAttr.addField("normal", MUIDrawManager::kInclineNormal); eAttr.addField("italic", MUIDrawManager::kInclineItalic); MPxNode::addAttribute(eTextIncline); aTextWeight = eAttr.create("textWeight", "tw", MUIDrawManager::kWeightBold); eAttr.addField("light", MUIDrawManager::kWeightLight); eAttr.addField("normal", MUIDrawManager::kWeightNormal); eAttr.addField("demiBold", MUIDrawManager::kWeightDemiBold); eAttr.addField("bold", MUIDrawManager::kWeightBold); eAttr.addField("black", MUIDrawManager::kWeightBlack); MPxNode::addAttribute(aTextWeight); aTextStretch = nAttr.create("textStretch", "ts", MFnNumericData::kInt, MUIDrawManager::kStretchUnstretched); nAttr.setMin(50); nAttr.setMax(200); MPxNode::addAttribute(aTextStretch); aTextLine = eAttr.create("textLine", "tl", 0); eAttr.addField("none", 0); eAttr.addField("overline", MUIDrawManager::kLineOverline); eAttr.addField("underline", MUIDrawManager::kLineUnderline); eAttr.addField("strikeout", MUIDrawManager::kLineStrikeoutLine); MPxNode::addAttribute(aTextLine); aTextBoxSize = nAttr.create("textBoxSize", "tbs", MFnNumericData::k2Int); nAttr.setDefault(0, 0); MPxNode::addAttribute(aTextBoxSize); aTextBoxColor = nAttr.create("textBoxColor", "tbc", MFnNumericData::k3Float); nAttr.setDefault(0.0f, 1.0f, 1.0f); nAttr.setUsedAsColor(true); MPxNode::addAttribute(aTextBoxColor); aTextBoxTransparency = nAttr.create("textBoxTransparency", "tbt", MFnNumericData::kFloat, 0.0); nAttr.setSoftMin(0.0); nAttr.setSoftMax(1.0); MPxNode::addAttribute(aTextBoxTransparency); // add point attributes aPointSize = nAttr.create("pointSize", "ps", MFnNumericData::kFloat, 2.0); MPxNode::addAttribute(aPointSize); // add line attributes aLineStartPoint = nAttr.create("lineStartPoint", "lsp", MFnNumericData::k3Double); nAttr.setDefault(0.0, 0.0, 0.0); MPxNode::addAttribute(aLineStartPoint); aLineEndPoint = nAttr.create("lineEndPoint", "lep", MFnNumericData::k3Double); nAttr.setDefault(1.0, 1.0, 1.0); MPxNode::addAttribute(aLineEndPoint); // add rect attributes aRectUp = nAttr.create("rectUp", "ru", MFnNumericData::k3Double); nAttr.setDefault(0.0, 1.0, 0.0); MPxNode::addAttribute(aRectUp); aRectNormal = nAttr.create("rectNormal", "rn", MFnNumericData::k3Double); nAttr.setDefault(0.0, 0.0, 1.0); MPxNode::addAttribute(aRectNormal); aRectScale = nAttr.create("rectScale", "rs", MFnNumericData::k2Double); nAttr.setDefault(1.0, 1.0); MPxNode::addAttribute(aRectScale); // add quad attributes double defaultPosition[4][3] = { {0.0, 0.0, 0.0}, {1.0, 0.0, 0.0}, {1.0, 1.0, 0.0}, {0.0, 1.0, 0.0} }; for (int i = 0; i < 4; ++i) { MString fullName = "quadVertex"; MString shortName = "qv"; aQuadVertex[i] = nAttr.create(fullName + i, shortName + i, MFnNumericData::k3Double); nAttr.setDefault(defaultPosition[i][0], defaultPosition[i][1], defaultPosition[i][2]); MPxNode::addAttribute(aQuadVertex[i]); } // add circle attributes aCircleNormal = nAttr.create("circleNormal", "cn", MFnNumericData::k3Double); nAttr.setDefault(0.0, 0.0, 1.0); MPxNode::addAttribute(aCircleNormal); // add arc attributes aArcStart = nAttr.create("arcStartVector", "asv", MFnNumericData::k3Double); nAttr.setDefault(1.0, 0.0, 0.0); MPxNode::addAttribute(aArcStart); aArcEnd = nAttr.create("arcEndVector", "aev", MFnNumericData::k3Double); nAttr.setDefault(0.0, 1.0, 0.0); MPxNode::addAttribute(aArcEnd); aArcNormal = nAttr.create("arcNormal", "an", MFnNumericData::k3Double); nAttr.setDefault(0.0, 0.0, 1.0); MPxNode::addAttribute(aArcNormal); // icon attributes aIconName = eAttr.create("icon", "i", 0 ); unsigned int iconCount = MUIDrawManager::getIconNames(uiDrawManagerData::fIconList); for (unsigned int i=0; i<iconCount; i++) { MString str = uiDrawManagerData::fIconList[i]; eAttr.addField(str, (short)i); } MPxNode::addAttribute(aIconName); aIconScale = nAttr.create("iconScale", "cs", MFnNumericData::kFloat, 1.0); MPxNode::addAttribute(aIconScale); // cone attributes aConeDirection = nAttr.create("coneDirection", "cd", MFnNumericData::k3Double); nAttr.setDefault(0.0, 0.0, 1.0); MPxNode::addAttribute(aConeDirection); aConeHeight = nAttr.create("coneHeight", "ch", MFnNumericData::kDouble); nAttr.setDefault(1.0); MPxNode::addAttribute(aConeHeight); // box attributes aBoxUp = nAttr.create("boxUp", "bu", MFnNumericData::k3Double); nAttr.setDefault(0.0, 0.0, 1.0); MPxNode::addAttribute(aBoxUp); aBoxRight = nAttr.create("boxRight", "br", MFnNumericData::k3Double); nAttr.setDefault(0.0, 1.0, 0.0); MPxNode::addAttribute(aBoxRight); aBoxScale = nAttr.create("boxScale", "bs", MFnNumericData::k3Double); nAttr.setDefault(1.0, 1.0, 1.0); MPxNode::addAttribute(aBoxScale); return MS::kSuccess; }
MStatus proWater::initialize() { // local attribute initialization //time parameter MFnNumericAttribute nAttr; time = nAttr.create("time", "t", MFnNumericData::kDouble); nAttr.setDefault(0.0); nAttr.setKeyable(true); nAttr.setSoftMin(0.0); nAttr.setSoftMax(1000); nAttr.setMin(0.0); nAttr.setMax(1000); addAttribute(time); attributeAffects(proWater::time, proWater::outputGeom); // //direction parameter MFnNumericAttribute dirAttr; dir = dirAttr.create("direction", "dirDeg", MFnNumericData::kDouble); dirAttr.setDefault(45); dirAttr.setKeyable(true); dirAttr.setSoftMin(0.0); dirAttr.setSoftMax(360); dirAttr.setMin(0.0); dirAttr.setMax(360); addAttribute(dir); attributeAffects(proWater::dir, proWater::outputGeom); // //bigAmp1 parameter MFnNumericAttribute bigAttr; bigFreq = bigAttr.create("largeWaveAmplitude", "bigAmp", MFnNumericData::kDouble); bigAttr.setDefault(3); bigAttr.setKeyable(true); bigAttr.setSoftMin(0.0); bigAttr.setSoftMax(100); bigAttr.setMin(0.0); bigAttr.setMax(100); addAttribute(bigFreq); attributeAffects(proWater::bigFreq, proWater::outputGeom); // //amplitude1 parameter MFnNumericAttribute ampAttr1; amplitude1 = ampAttr1.create("firstOctaveAmplitude", "amp1", MFnNumericData::kDouble); ampAttr1.setDefault(0.5); ampAttr1.setKeyable(true); ampAttr1.setSoftMin(0.0); ampAttr1.setSoftMax(100); ampAttr1.setMin(0.0); ampAttr1.setMax(100); addAttribute(amplitude1); attributeAffects(proWater::amplitude1, proWater::outputGeom); // //frequency1 parameter MFnNumericAttribute freqAttr1; frequency1 = freqAttr1.create("firstFrequency", "freq1", MFnNumericData::kDouble); freqAttr1.setDefault(0.5); freqAttr1.setKeyable(true); freqAttr1.setSoftMin(0.0); freqAttr1.setSoftMax(100); freqAttr1.setMin(0.0); freqAttr1.setMax(100); addAttribute(frequency1); attributeAffects(proWater::frequency1, proWater::outputGeom); // //amplitude2 parameter MFnNumericAttribute ampAttr2; amplitude2 = ampAttr2.create("secondOctaveAmplitude", "amp2", MFnNumericData::kDouble); ampAttr2.setDefault(1.3); ampAttr2.setKeyable(true); ampAttr2.setSoftMin(0.0); ampAttr2.setSoftMax(100); ampAttr2.setMin(0.0); ampAttr2.setMax(100); addAttribute(amplitude2); attributeAffects(proWater::amplitude2, proWater::outputGeom); // //frequency2 parameter MFnNumericAttribute freqAttr2; frequency2 = freqAttr2.create("secondFrequency", "freq2", MFnNumericData::kDouble); freqAttr2.setDefault(0.7); freqAttr2.setKeyable(true); freqAttr2.setSoftMin(0.0); freqAttr2.setSoftMax(100); freqAttr2.setMin(0.0); freqAttr2.setMax(100); addAttribute(frequency2); attributeAffects(proWater::frequency2, proWater::outputGeom); // MFnMatrixAttribute mAttr; offsetMatrix=mAttr.create( "locateMatrix", "lm"); mAttr.setStorable(false); mAttr.setConnectable(true); // deformation attributes addAttribute( offsetMatrix); attributeAffects( proWater::offsetMatrix, proWater::outputGeom ); return MStatus::kSuccess; }
MStatus ropeGenerator::initialize() { MStatus stat; MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MRampAttribute rAttr; inCurve = tAttr.create( "inCurve", "inCurve", MFnData::kNurbsCurve ); tAttr.setHidden( true); divisions = nAttr.create( "divisions", "divisions", MFnNumericData::kInt, 15 ); nAttr.setMin( 2 ); nAttr.setSoftMax( 100 ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); createRope = nAttr.create( "createRope", "createRope", MFnNumericData::kBoolean, false ); nAttr.setWritable( true ); nAttr.setStorable( true ); nAttr.setKeyable( true ); ropesCount = nAttr.create( "ropesCount", "ropesCount", MFnNumericData::kInt, 5 ); nAttr.setMin( 3 ); nAttr.setSoftMax( 10 ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); pointsPerRope = nAttr.create( "pointsPerRope", "pointsPerRope", MFnNumericData::kInt, 6 ); nAttr.setMin( 3 ); nAttr.setSoftMax( 15 ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); ropesStrength = nAttr.create( "ropesStrength", "ropesStrength", MFnNumericData::kFloat, 1.0f ); nAttr.setMin( 0.0 ); nAttr.setMax( 1.0 ); nAttr.setWritable( true ); nAttr.setStorable( true ); nAttr.setKeyable( true ); pointsCount = nAttr.create( "pointsCount", "pointsCount", MFnNumericData::kInt, 5 ); nAttr.setMin(3); nAttr.setSoftMax( 20 ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); radius = nAttr.create( "radius", "radius", MFnNumericData::kFloat, 1.0f ); nAttr.setMin( 0.0 ); nAttr.setSoftMax( 30.0 ); nAttr.setKeyable( true ); nAttr.setWritable( true ); nAttr.setStorable( true ); taperRamp = rAttr.createCurveRamp( "tapper", "tapper" ); twist = nAttr.create( "twist", "twist", MFnNumericData::kFloat, 0.0f ); nAttr.setSoftMin( -3600.0 ); nAttr.setSoftMax( 3600.0 ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); twistRamp = rAttr.createCurveRamp( "twistRamp", "twistRamp" ); uvWidth = nAttr.create( "uvWidth", "uvWidth", MFnNumericData::kFloat, 1.0f ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); uvHeight = nAttr.create( "uvHeight", "uvHeight", MFnNumericData::kFloat, 1.0f ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); uvCapSize = nAttr.create( "uvCapSize", "uvCapSize", MFnNumericData::kFloat, 1.0f ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); outMesh = tAttr.create( "outMesh", "outMesh", MFnData::kMesh ); tAttr.setWritable( false ); tAttr.setStorable( false ); stat = addAttribute( inCurve ); if (!stat) { stat.perror("addAttribute inCurve"); return stat;} stat = addAttribute( divisions ); if (!stat) { stat.perror("addAttribute divisions"); return stat;} stat = addAttribute( createRope ); if (!stat) { stat.perror("addAttribute createRope"); return stat;} stat = addAttribute( ropesCount ); if (!stat) { stat.perror("addAttribute ropesCount"); return stat;} stat = addAttribute( pointsPerRope ); if (!stat) { stat.perror("addAttribute pointsPerRope"); return stat;} stat = addAttribute( ropesStrength ); if (!stat) { stat.perror("addAttribute ropesStrength"); return stat;} stat = addAttribute( pointsCount ); if (!stat) { stat.perror("addAttribute pointsCount"); return stat;} stat = addAttribute( radius ); if (!stat) { stat.perror("addAttribute radius"); return stat;} stat = addAttribute( taperRamp ); if (!stat) { stat.perror("addAttribute taperRamp"); return stat;} stat = addAttribute( twist ); if (!stat) { stat.perror("addAttribute twist"); return stat;} stat = addAttribute( twistRamp ); if (!stat) { stat.perror("addAttribute twistRamp"); return stat;} stat = addAttribute( uvWidth ); if (!stat) { stat.perror("addAttribute uvWidth"); return stat;} stat = addAttribute( uvHeight ); if (!stat) { stat.perror("addAttribute uvHeight"); return stat;} stat = addAttribute( uvCapSize ); if (!stat) { stat.perror("addAttribute uvCapSize"); return stat;} stat = addAttribute( outMesh ); if (!stat) { stat.perror("addAttribute outMesh"); return stat;} stat = attributeAffects( inCurve, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( divisions, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( createRope, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( ropesCount, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( pointsPerRope, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( ropesStrength, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( pointsCount, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( radius, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( taperRamp, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( twist, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( twistRamp, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( uvWidth, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( uvHeight, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( uvCapSize, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} return MS::kSuccess; }
static MStatus initialize() { // set up uder-defined attribute MFnNumericAttribute numericAttrFn; MFnGenericAttribute genericAttrFn; // enable thie node aEnable = numericAttrFn.create( "enbale", "e", MFnNumericData::kBoolean, 0, &status ); CHECK_MSTATUS(status); numericAttrFn.setDefault(0); numericAttrFn.setKeyable(true); addAttribute(aEnable); // enable when rendering aEnableRender = numericAttrFn.create( "enbaleAsRendering", "er", MFnNumericData::kBoolean, 0, &status ); CHECK_MSTATUS(status); numericAttrFn.setDefault(0); numericAttrFn.setKeyable(true); addAttribute(aEnableRender); // Inputs // // input color aColor = numericAttrFn.createColor( "Color", "c", &status ); CHECK_MSTATUS(status); numericAttrFn.setDefault( 0.0, 0.5, 0.0); addAttribute(aColor); // enable supersampling aIsSpuersampling = numericAttrFn.create( "supersampling", "ssp", MFnNumericData::kBoolean, 0, &status ); CHECK_MSTATUS(status); numericAttrFn.setDefault(1); numericAttrFn.setKeyable(true); addAttribute(aIsSpuersampling); // filter size /* aFSize = numericAttrFn.create( "filterSize", "fs", MFnNumericData::k3Float, 0.0, &status ); CHECK_MSTATUS(status); numericAttrFn.setMin( 0.0, 0.0, 0.0 ); numericAttrFn.setMax( 10.0, 10.0, 10.0 ); numericAttrFn.setDefault( 1.0, 1.0, 1.0 ); addAttribute(aFSize); */ // filter size aFilterSize = numericAttrFn.create( "filterSizes", "fls", MFnNumericData::k2Int, 0, &status ); CHECK_MSTATUS(status); numericAttrFn.setMin( 0, 0 ); numericAttrFn.setMax( 10, 10 ); numericAttrFn.setDefault( 0, 0 ); addAttribute(aFilterSize); // sample offset aOffsetSample = numericAttrFn.create( "sampleOffset", "ao", MFnNumericData::kFloat, 0.0 , &status ); CHECK_MSTATUS(status); numericAttrFn.setSoftMin( 0.0f ); numericAttrFn.setSoftMax( 0.1f ); numericAttrFn.setDefault( 0.01f); addAttribute(aOffsetSample); // UV coordinate MObject uCoord = numericAttrFn.create( "uCoord", "u", MFnNumericData::kDouble ); MObject vCoord = numericAttrFn.create( "vCoord", "v", MFnNumericData::kDouble ); aUVCoord = numericAttrFn.create( "uvCoord", "uv", uCoord, vCoord, MObject::kNullObj, &status); CHECK_MSTATUS(status); numericAttrFn.setHidden(true); numericAttrFn.setRenderSource(true); addAttribute(aUVCoord); // UV filter size MObject sUVFilterSizeX = numericAttrFn.create( "uvFilterSizeX", "ufx", MFnNumericData::kFloat ); MObject sUVFilterSizeY = numericAttrFn.create( "uvFilterSizeY", "ufy", MFnNumericData::kFloat ); aUVFilterSize = numericAttrFn.create( "uvFilterSize", "uf", sUVFilterSizeX, sUVFilterSizeY, MObject::kNullObj, &status ); CHECK_MSTATUS(status); numericAttrFn.setHidden(true); addAttribute(aUVFilterSize); // World-space position aPointWorld = numericAttrFn.createPoint( "pointWorld", "pw", &status ); CHECK_MSTATUS(status); numericAttrFn.setHidden(true); addAttribute(aPointWorld); // input Shape as the source aShape = genericAttrFn.create( "sourceShape", "s", &status ); //genericAttrFn.addDataAccept( MFnData::kNurbsSurface ); genericAttrFn.addAccept( MFnData::kNurbsSurface ); genericAttrFn.addAccept( MFnData::kMesh ); CHECK_MSTATUS(status); addAttribute(aShape); // target shape aTargetShape = genericAttrFn.create( "targetShape", "ts", &status ); //genericAttrFn.addDataAccept( MFnData::kNurbsSurface ); genericAttrFn.addAccept( MFnData::kNurbsSurface ); genericAttrFn.addAccept( MFnData::kMesh ); CHECK_MSTATUS(status); addAttribute(aTargetShape); // output // // output color aOutColor = numericAttrFn.createColor( "outColor", "oc", &status); CHECK_MSTATUS(status); numericAttrFn.setWritable(false); addAttribute(aOutColor); // affect Attribute //attributeAffects( aFSize, aOutColor ); attributeAffects( aEnable, aOutColor ); attributeAffects( aEnableRender, aOutColor ); attributeAffects( aColor, aOutColor ); attributeAffects( aIsSpuersampling, aOutColor ); attributeAffects( aFilterSize, aOutColor ); attributeAffects( aOffsetSample, aOutColor ); attributeAffects( aUVCoord, aOutColor ); attributeAffects( aUVFilterSize, aOutColor ); attributeAffects( aPointWorld, aOutColor ); attributeAffects( aShape, aOutColor ); attributeAffects( aTargetShape, aOutColor ); attributeAffects( aUVCoord, aUVCoord ); return MS::kSuccess; }