MStatus mapBlendShape::initialize() { MStatus status; MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; aBlendMesh = tAttr.create("blendMesh", "blendMesh", MFnData::kMesh); addAttribute(aBlendMesh); aBlendMap = nAttr.createColor("blendMap", "blendMap"); addAttribute(aBlendMap); aUseBlendMap = nAttr.create("useBlendMap", "useBlendMap", MFnNumericData::kBoolean); nAttr.setDefault(true); addAttribute(aUseBlendMap); aBlendMapMultiplier = nAttr.create("blendMapMultiplier", "blendMapMultiplier", MFnNumericData::kFloat); nAttr.setDefault(1.0); nAttr.setMin(0.0); addAttribute(aBlendMapMultiplier); attributeAffects(aBlendMesh, outputGeom); attributeAffects(aBlendMap, outputGeom); attributeAffects(aUseBlendMap, outputGeom); attributeAffects(aBlendMapMultiplier, outputGeom); MGlobal::executeCommand( "makePaintable -attrType multiFloat -sm deformer blendNode weights;" ); return MS::kSuccess; }
/*! * Initialize attributes in Maya. */ MStatus ffdPlanar::initialize() { // Local attributes. MFnNumericAttribute nAttr; latticeRow1 = nAttr.create( "row1", "r1", MFnNumericData::k3Double ); nAttr.setDefault( 0.0, 0.0, 0.0 ); nAttr.setMin( -100.0, -100.0, -100.0 ); nAttr.setMax( 100.0, 100.0, 100.0 ); nAttr.setKeyable( true ); addAttribute( latticeRow1 ); latticeRow2 = nAttr.create( "row2", "r2", MFnNumericData::k3Double ); nAttr.setDefault( 0.0, 0.0, 0.0 ); nAttr.setMin( -100.0, -100.0, -100.0 ); nAttr.setMax( 100.0, 100.0, 100.0 ); nAttr.setKeyable( true ); addAttribute( latticeRow2 ); latticeRow3 = nAttr.create( "row3", "r3", MFnNumericData::k3Double ); nAttr.setDefault( 0.0, 0.0, 0.0 ); nAttr.setMin( -100.0, -100.0, -100.0 ); nAttr.setMax( 100.0, 100.0, 100.0 ); nAttr.setKeyable( true ); addAttribute( latticeRow3 ); // Attributes affect geometry. attributeAffects( ffdPlanar::latticeRow1, ffdPlanar::outputGeom ); attributeAffects( ffdPlanar::latticeRow2, ffdPlanar::outputGeom ); attributeAffects( ffdPlanar::latticeRow3, ffdPlanar::outputGeom ); return MS::kSuccess; }
MStatus texLayerNode::initialize() { MStatus stat; MFnNumericAttribute numAttr; MFnEnumAttribute enumAttr; layerInput1=numAttr.createColor("LayerInput1","li1"); numAttr.setDefault(1.0,1.0,1.0); MAKE_INPUT(numAttr); layerInput2=numAttr.createColor("LayerInput2","li2"); MAKE_INPUT(numAttr); numAttr.setDefault(1.0,1.0,1.0); layerInput3=numAttr.createColor("LayerInput3","li3"); MAKE_INPUT(numAttr); numAttr.setDefault(1.0,1.0,1.0); layerInput4=numAttr.createColor("LayerInput4","li4"); MAKE_INPUT(numAttr); numAttr.setDefault(1.0,1.0,1.0); MObject u=numAttr.create("uCoord","u",MFnNumericData::kFloat); MObject v=numAttr.create("vCoord","v",MFnNumericData::kFloat); layerUV=numAttr.create("uvCoord","uv",u,v); MAKE_INPUT(numAttr); MObject filterX=numAttr.create("uvFilterSizeX", "fsx", MFnNumericData::kFloat); MObject filterY=numAttr.create( "uvFilterSizeY", "fsy", MFnNumericData::kFloat); layerUVFilterSize=numAttr.create("uvFilterSize", "fs", filterX, filterY); MAKE_INPUT(numAttr); layerOutput=numAttr.createColor("outColor","oc"); MAKE_OUTPUT(numAttr); numAttr.setHidden(true); addAttribute(layerInput1); addAttribute(layerInput2); addAttribute(layerInput3); addAttribute(layerInput4); addAttribute(layerUV); addAttribute(layerUVFilterSize); addAttribute(layerOutput); attributeAffects(layerInput1,layerOutput); attributeAffects(layerInput2,layerOutput); attributeAffects(layerInput3,layerOutput); attributeAffects(layerInput4,layerOutput); attributeAffects(layerUV,layerOutput); attributeAffects(layerUVFilterSize,layerOutput); return stat; }
// initializes attribute information MStatus myComp::initialize() { MFnNumericAttribute nAttr; // Create input attributes aForegroundColor = nAttr.createColor("foreground", "fg"); MAKE_INPUT(nAttr); aBackgroundColor = nAttr.createColor("background", "bg"); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setDefault(1., 1., 1.)); aBackColor = nAttr.createColor("backColor", "bk"); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setDefault(1., 1., 1.)); aMask = nAttr.create( "mask", "ms", MFnNumericData::kFloat); CHECK_MSTATUS( nAttr.setMin(0.f)); CHECK_MSTATUS( nAttr.setMax(1.f)); MAKE_INPUT(nAttr); // Create output attributes here aOutColor = nAttr.createColor("outColor", "oc"); MAKE_OUTPUT(nAttr); aOutAlpha = nAttr.create( "outAlpha", "oa", MFnNumericData::kFloat); MAKE_OUTPUT(nAttr); // Add the attributes here CHECK_MSTATUS( addAttribute(aForegroundColor) ); CHECK_MSTATUS( addAttribute(aBackgroundColor) ); CHECK_MSTATUS( addAttribute(aBackColor) ); CHECK_MSTATUS( addAttribute(aMask) ); CHECK_MSTATUS( addAttribute(aOutColor) ); CHECK_MSTATUS( addAttribute(aOutAlpha) ); // all input affect the output color and alpha CHECK_MSTATUS( attributeAffects(aForegroundColor, aOutColor) ); CHECK_MSTATUS( attributeAffects(aForegroundColor, aOutAlpha) ); CHECK_MSTATUS( attributeAffects(aBackgroundColor, aOutColor) ); CHECK_MSTATUS( attributeAffects(aBackgroundColor, aOutAlpha) ); CHECK_MSTATUS( attributeAffects(aBackColor, aOutColor) ); CHECK_MSTATUS( attributeAffects(aBackColor, aOutAlpha) ); CHECK_MSTATUS( attributeAffects(aMask, aOutColor) ); CHECK_MSTATUS( attributeAffects(aMask, aOutAlpha) ); return MS::kSuccess; }
MStatus OpenSubdivShader::initialize() { MStatus stat; MFnTypedAttribute typedAttr; MFnNumericAttribute numAttr; MFnEnumAttribute enumAttr; aLevel = numAttr.create("level", "lv", MFnNumericData::kLong, 1); numAttr.setInternal(true); numAttr.setMin(1); numAttr.setSoftMax(5); aScheme = enumAttr.create("scheme", "sc"); enumAttr.addField("Catmull-Clark", kCatmark); enumAttr.addField("Loop", kLoop); enumAttr.addField("Bilinear", kBilinear); enumAttr.setInternal(true); aKernel = enumAttr.create("kernel", "kn"); enumAttr.addField("CPU", OpenSubdiv::OsdKernelDispatcher::kCPU); if (OpenSubdiv::OsdKernelDispatcher::HasKernelType(OpenSubdiv::OsdKernelDispatcher::kOPENMP)) enumAttr.addField("OpenMP", OpenSubdiv::OsdKernelDispatcher::kOPENMP); if (OpenSubdiv::OsdKernelDispatcher::HasKernelType(OpenSubdiv::OsdKernelDispatcher::kCL)) enumAttr.addField("CL", OpenSubdiv::OsdKernelDispatcher::kCL); if (OpenSubdiv::OsdKernelDispatcher::HasKernelType(OpenSubdiv::OsdKernelDispatcher::kCUDA)) enumAttr.addField("CUDA", OpenSubdiv::OsdKernelDispatcher::kCUDA); enumAttr.setInternal(true); aDiffuse = numAttr.createColor("diffuse", "d"); numAttr.setDefault(1.0f, 1.0f, 1.0f); aSpecular = numAttr.createColor("specular", "s"); numAttr.setDefault(1.0f, 1.0f, 1.0f); aAmbient = numAttr.createColor("ambient", "a"); numAttr.setDefault(1.0f, 1.0f, 1.0f); aShininess = numAttr.create("shininess", "shin", MFnNumericData::kFloat, 16.0f); numAttr.setMin(0); numAttr.setMax(128.0f); aWireframe = numAttr.create("wireframe", "wf", MFnNumericData::kBoolean); addAttribute(aLevel); addAttribute(aScheme); addAttribute(aKernel); addAttribute(aDiffuse); addAttribute(aSpecular); addAttribute(aAmbient); addAttribute(aShininess); addAttribute(aWireframe); 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 depthShader::initialize() { MFnNumericAttribute nAttr; // Create input attributes aColorNear = nAttr.createColor("color", "c"); MAKE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setDefault(0., 1., 0.)); // Green aColorFar = nAttr.createColor("colorFar", "cf"); MAKE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setDefault(0., 0., 1.)); // Blue aNear = nAttr.create("near", "n", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setMin(0.0f)); CHECK_MSTATUS(nAttr.setSoftMax(1000.0f)); aFar = nAttr.create("far", "f", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setMin(0.0f)); CHECK_MSTATUS(nAttr.setSoftMax(1000.0f)); CHECK_MSTATUS(nAttr.setDefault(2.0f)); aPointCamera = nAttr.createPoint("pointCamera", "p"); MAKE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setHidden(true)); // Create output attributes aOutColor = nAttr.createColor("outColor", "oc"); MAKE_OUTPUT(nAttr); CHECK_MSTATUS(addAttribute(aColorNear)); CHECK_MSTATUS(addAttribute(aColorFar)); CHECK_MSTATUS(addAttribute(aNear) ); CHECK_MSTATUS(addAttribute(aFar)); CHECK_MSTATUS(addAttribute(aPointCamera)); CHECK_MSTATUS(addAttribute(aOutColor)); CHECK_MSTATUS(attributeAffects(aColorNear, aOutColor)); CHECK_MSTATUS(attributeAffects(aColorFar, aOutColor)); CHECK_MSTATUS(attributeAffects(aNear, aOutColor)); CHECK_MSTATUS(attributeAffects(aFar, aOutColor)); CHECK_MSTATUS(attributeAffects(aPointCamera, aOutColor)); 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 PRTAttrs::addColorParameter(MFnDependencyNode & node, MObject & attr, const MString & name, MString & value ) { MStatus stat; MFnNumericAttribute nAttr; const wchar_t* s = value.asWChar(); attr = nAttr.createColor(longName(name), briefName(name), &stat ); MCHECK(stat); double r = 0.0; double g = 0.0; double b = 0.0; if (s[0] == '#' && wcslen(s) >= 7) { r = (double)((prtu::fromHex(s[1]) << 4) + prtu::fromHex(s[2])) / 255.0; g = (double)((prtu::fromHex(s[3]) << 4) + prtu::fromHex(s[4])) / 255.0; b = (double)((prtu::fromHex(s[5]) << 4) + prtu::fromHex(s[6])) / 255.0; nAttr.setDefault(r, g, b); } MCHECK(addParameter(node, attr, nAttr)); MFnNumericData fnData; MObject rgb = fnData.create(MFnNumericData::k3Double, &stat); MCHECK(stat); fnData.setData(r, g, b); MPlug plug(node.object(), attr); MCHECK(plug.setValue(rgb)); return MS::kSuccess; }
// // DESCRIPTION: /////////////////////////////////////////////////////// MStatus Gamma::initialize() { MFnNumericAttribute nAttr; // Input attributes aColor = nAttr.createColor( "color", "c" ); MAKE_INPUT(nAttr); aGamma = nAttr.createPoint( "gamma", "g" ); MAKE_INPUT(nAttr); CHECK_MSTATUS ( nAttr.setDefault(1.f, 1.f, 1.f) ); // Output attributes aOutColor= nAttr.createColor( "outColor", "oc" ); MAKE_OUTPUT(nAttr); // Add attributes to the node database. CHECK_MSTATUS ( addAttribute(aColor) ); CHECK_MSTATUS ( addAttribute(aGamma) ); CHECK_MSTATUS ( addAttribute(aOutColor) ); // All input affect the output color CHECK_MSTATUS ( attributeAffects( aColor, aOutColor )); CHECK_MSTATUS ( attributeAffects( aGamma, aOutColor )); return MS::kSuccess; }
MStatus liqCoordSysNode::initialize() { MFnEnumAttribute eAttr; MFnNumericAttribute numAttr; MStatus status; aCoordType = eAttr.create( "type", "t", 0, &status ); eAttr.addField( "Card", 0 ); eAttr.addField( "Sphere", 1 ); eAttr.addField( "Cylinder", 2 ); eAttr.addField( "Cube", 3 ); eAttr.addField( "Deep Card", 4 ); eAttr.addField( "Clipping Plane", 5 ); MAKE_INPUT(eAttr); CHECK_MSTATUS(eAttr.setConnectable(false)); CHECK_MSTATUS( addAttribute( aCoordType ) ); aCoordColor = numAttr.createColor( "coordColor", "cc", &status ); MAKE_INPUT(numAttr); CHECK_MSTATUS( numAttr.setMin( 0.0, 0.0, 0.0 ) ); CHECK_MSTATUS( numAttr.setMax( 1.0, 1.0, 1.0 ) ); CHECK_MSTATUS( numAttr.setDefault( 0.0, 0.0, 0.5) ); CHECK_MSTATUS( addAttribute( aCoordColor ) ); aCoordOpacity = numAttr.create( "coordOpacity", "co", MFnNumericData::kFloat, 0.0, &status ); MAKE_INPUT(numAttr); CHECK_MSTATUS( numAttr.setMin( 0.0 ) ); CHECK_MSTATUS( numAttr.setMax( 1.0 ) ); CHECK_MSTATUS( addAttribute( aCoordOpacity ) ); 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 areaLightNode::initialize() { MStatus stat; MFnNumericAttribute numAttr; areaLightColor=numAttr.createColor("LightColor","lico"); numAttr.setKeyable(true); numAttr.setStorable(true); numAttr.setDefault(0.5,0.5,0.5); areaPower=numAttr.create("Power","ap",MFnNumericData::kFloat,1.0); numAttr.setKeyable(true); numAttr.setStorable(true); numAttr.setMin(0.0); numAttr.setMax(10000.0); areaSamples=numAttr.create("Samples","as",MFnNumericData::kInt,1); numAttr.setKeyable(true); numAttr.setStorable(true); numAttr.setMin(0); numAttr.setMax(512); areaMakeGeo=numAttr.create("MakeGeometry","mg",MFnNumericData::kBoolean,0); numAttr.setKeyable(true); numAttr.setStorable(true); addAttribute(areaLightColor); addAttribute(areaPower); addAttribute(areaSamples); addAttribute(areaMakeGeo); return stat; }
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; }
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; }
// // DESCRIPTION: /////////////////////////////////////////////////////// MStatus MixtureNode::initialize() { MFnNumericAttribute nAttr; // Input attributes aColor1 = nAttr.createColor( "color1", "c1" ); MAKE_INPUT(nAttr); CHECK_MSTATUS ( nAttr.setDefault(0.0f, 1.0f, 0.0f) ); // Green aColor2 = nAttr.createColor( "color2", "c2" ); MAKE_INPUT(nAttr); CHECK_MSTATUS ( nAttr.setDefault(0.0f, 0.0f, 1.0f) ); // Blue aAlphaInput1= nAttr.createColor( "mask1", "m1" ); MAKE_INPUT(nAttr); CHECK_MSTATUS ( nAttr.setDefault(.5f, .5f, .5f) ); aAlphaInput2= nAttr.createColor( "mask2", "m2" ); MAKE_INPUT(nAttr); CHECK_MSTATUS ( nAttr.setDefault(.5f, .5f, .5f) ); // Output attributes aOutColor = nAttr.createColor( "outColor", "oc" ); MAKE_OUTPUT(nAttr); // Add attributes to the node database. CHECK_MSTATUS ( addAttribute(aColor1) ); CHECK_MSTATUS ( addAttribute(aColor2) ); CHECK_MSTATUS ( addAttribute(aAlphaInput1) ); CHECK_MSTATUS ( addAttribute(aAlphaInput2) ); CHECK_MSTATUS ( addAttribute(aOutColor) ); // All input affect the output color CHECK_MSTATUS ( attributeAffects(aColor1, aOutColor) ); CHECK_MSTATUS ( attributeAffects(aColor2, aOutColor) ); CHECK_MSTATUS ( attributeAffects(aAlphaInput1, aOutColor) ); CHECK_MSTATUS ( attributeAffects(aAlphaInput2, aOutColor) ); return MS::kSuccess; }
// Initialize the plug-in. Called once when the plug-in is loaded. // This mostly involve creating attributes. MStatus hwRefractReflectShader_NV20::initialize() { MFnNumericAttribute nAttr; MStatus status; MFnTypedAttribute sAttr; // For string attributes // Create input attributes colorR = nAttr.create( "colorR", "cr",MFnNumericData::kFloat); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setDefault(1.0f); colorG = nAttr.create( "colorG", "cg",MFnNumericData::kFloat); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setDefault(0.5f); colorB = nAttr.create( "colorB", "cb",MFnNumericData::kFloat); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setDefault(0.5f); color = nAttr.create( "color", "c", colorR, colorG, colorB); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setDefault(1.0f, 0.5f, 0.5f); nAttr.setUsedAsColor(true); refractionIndex = nAttr.create( "refractionIndex", "ri", MFnNumericData::kFloat); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setMin(1.0f); nAttr.setMax(2.0f); nAttr.setDefault(1.1f); reflectivity = nAttr.create( "reflectivity", "rfl", MFnNumericData::kFloat); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setMin(0.0f); nAttr.setMax(1.0f); nAttr.setDefault(0.5f); // Add the attributes here addAttribute(color); addAttribute(refractionIndex); addAttribute(reflectivity); attributeAffects (colorR, outColor); attributeAffects (colorG, outColor); attributeAffects (colorB, outColor); attributeAffects (color, outColor); attributeAffects (refractionIndex, outColor); attributeAffects (reflectivity, outColor); return MS::kSuccess; }
// // DESCRIPTION: MStatus Gradient::initialize() { MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; MFnGenericAttribute gAttr; MFnEnumAttribute eAttr; MFnMessageAttribute mAttr; MStatus status; outColor = nAttr.createColor("outColor", "outColor"); MAKE_OUTPUT(nAttr); CHECK_MSTATUS(addAttribute( outColor )); //---------------------------- automatically created attributes start ------------------------------------ high = nAttr.createColor("high", "high"); nAttr.setDefault(0,0,0); CHECK_MSTATUS(addAttribute( high )); low = nAttr.createColor("low", "low"); nAttr.setDefault(1,1,1); CHECK_MSTATUS(addAttribute( low )); MObject directionX = nAttr.create("directionX", "directionx", MFnNumericData::kDouble, 0.0); MObject directionY = nAttr.create("directionY", "directiony", MFnNumericData::kDouble, 0.0); MObject directionZ = nAttr.create("directionZ", "directionz", MFnNumericData::kDouble, 0.0); direction = nAttr.create("direction", "direction", directionX, directionY, directionZ); MAKE_INPUT(nAttr); nAttr.setDefault(1,0,0); CHECK_MSTATUS(addAttribute( direction )); //---------------------------- automatically created attributes end ------------------------------------ return MS::kSuccess; }
MStatus BasicLocator::initialize() { MFnUnitAttribute unitFn; MFnNumericAttribute numFn; MStatus stat; xWidth = unitFn.create( "xWidth", "xw", MFnUnitAttribute::kDistance ); unitFn.setDefault( MDistance(1.0, MDistance::uiUnit()) ); unitFn.setMin( MDistance(0.0, MDistance::uiUnit()) ); unitFn.setKeyable( true ); stat = addAttribute( xWidth ); if (!stat) { stat.perror( "Unable to add \"xWidth\" attribute" ); return stat; } zWidth = unitFn.create( "zWidth", "zw", MFnUnitAttribute::kDistance ); unitFn.setDefault( MDistance(1.0, MDistance::uiUnit()) ); unitFn.setMin( MDistance(0.0, MDistance::uiUnit()) ); unitFn.setKeyable( true ); stat = addAttribute( zWidth ); if (!stat) { stat.perror( "Unable to add \"zWidth\" attribute" ); return stat; } dispType = numFn.create( "dispType", "att", MFnNumericData::kShort ); numFn.setDefault( 0); numFn.setMin( 0 ); numFn.setMax( 2 ); numFn.setKeyable( true ); stat = addAttribute( dispType ); if (!stat) { stat.perror( "Unable to add \"dispType\" attribute" ); return stat; } // Notify Maya that there is an associated manipulator for this particular type of node MPxManipContainer::addToManipConnectTable( const_cast<MTypeId &>( typeId ) ); return MS::kSuccess; }
MStatus TransformationMatrixParameterHandler<T>::setVecDefaultValues( MPlug vecPlug, Imath::Vec3<T> &defaultValue ) const { if( vecPlug.numChildren() != 3 ) { return MS::kFailure; } MFnNumericAttribute fnN; for( unsigned int i=0; i<3; i++ ) { fnN.setObject( vecPlug.child(i).attribute() ); if( !fnN.setDefault( defaultValue[i] ) ) { return MS::kFailure; } } return MS::kSuccess; }
MStatus sphereLightNode::initialize() { MStatus stat; MFnNumericAttribute numAttr; sphereColor=numAttr.createColor("LightColor","lico"); numAttr.setKeyable(true); numAttr.setStorable(true); numAttr.setDefault(1.0,1.0,1.0); spherePower=numAttr.create("Power","pw",MFnNumericData::kFloat,1.0); numAttr.setKeyable(true); numAttr.setStorable(true); numAttr.setMin(0.0); numAttr.setMax(10000.0); sphereRadius=numAttr.create("Radius","ra",MFnNumericData::kFloat,1.0); numAttr.setKeyable(true); numAttr.setStorable(true); numAttr.setMin(0.0); numAttr.setMax(100.0); sphereSamples=numAttr.create("Samples","sam",MFnNumericData::kInt,16); numAttr.setKeyable(true); numAttr.setStorable(true); numAttr.setMin(0); numAttr.setMax(512); sphereMakeGeometry=numAttr.create("MakeGeometry","mg",MFnNumericData::kBoolean,0); numAttr.setKeyable(true); numAttr.setStorable(true); addAttribute(sphereColor); addAttribute(spherePower); addAttribute(sphereRadius); addAttribute(sphereSamples); addAttribute(sphereMakeGeometry); return stat; }
// // DESCRIPTION: MStatus constant::initialize() { MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; MFnGenericAttribute gAttr; MFnEnumAttribute eAttr; MFnMessageAttribute mAttr; MStatus status; outColor = nAttr.createColor("outColor", "outColor"); MAKE_OUTPUT(nAttr); CHECK_MSTATUS(addAttribute( outColor )); //---------------------------- automatically created attributes start ------------------------------------ color = nAttr.createColor("color", "color"); MAKE_INPUT(nAttr); nAttr.setDefault(1.0,1.0,1.0); CHECK_MSTATUS(addAttribute( color )); luxOutFloat = nAttr.create("luxOutFloat", "luxOutFloat", MFnNumericData::kFloat); MAKE_OUTPUT(nAttr); CHECK_MSTATUS(addAttribute( luxOutFloat )); luxOutColor = nAttr.createColor("luxOutColor", "luxOutColor"); MAKE_OUTPUT(nAttr); CHECK_MSTATUS(addAttribute( luxOutColor )); luxOutFresnel = nAttr.create("luxOutFresnel", "luxOutFresnel", MFnNumericData::kFloat); MAKE_OUTPUT(nAttr); CHECK_MSTATUS(addAttribute( luxOutFresnel )); CHECK_MSTATUS ( attributeAffects( color, luxOutFloat)); CHECK_MSTATUS ( attributeAffects( color, luxOutColor)); CHECK_MSTATUS ( attributeAffects( color, luxOutFresnel)); CHECK_MSTATUS ( attributeAffects( color, outColor)); //---------------------------- automatically created attributes end ------------------------------------ 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 ); }
MStatus pointLightNode::initialize() { MStatus stat; MFnNumericAttribute numAttr; pointLightColor=numAttr.createColor("LightColor","plico"); numAttr.setKeyable(true); numAttr.setStorable(true); numAttr.setDefault(1.0,1.0,1.0); pointPower=numAttr.create("Power","pp",MFnNumericData::kFloat,1.0); numAttr.setKeyable(true); numAttr.setStorable(true); numAttr.setMin(0.0); numAttr.setMax(10000.0); addAttribute(pointLightColor); addAttribute(pointPower); return stat=MStatus::kSuccess; }
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 ); }
static MStatus initialize() { MFnEnumAttribute enumAttrFn; MFnNumericAttribute numericAttrFn; MFnGenericAttribute genericAttrFn; MFnTypedAttribute typeAttrFn; // enable node aEnable = numericAttrFn.create( "enbale", "e", MFnNumericData::kBoolean, 0, &status ); numericAttrFn.setDefault(0); numericAttrFn.setKeyable(true); addAttribute(aEnable); aFixPanel = numericAttrFn.create( "fixPanel", "fpn", MFnNumericData::kBoolean, 0, &status); numericAttrFn.setDefault(1); numericAttrFn.setConnectable(true); addAttribute(aFixPanel); aKeepSel = numericAttrFn.create( "keepSelection", "ks", MFnNumericData::kBoolean, 0, &status); numericAttrFn.setDefault(0); addAttribute(aKeepSel); // component type aComponentType = enumAttrFn.create( "componetType", "ct", 0, &status ); CHECK_MSTATUS( status ); enumAttrFn.setDefault(0); enumAttrFn.addField( "vertex", 0 ); enumAttrFn.addField( "edge", 1 ); enumAttrFn.addField( "face", 2 ); enumAttrFn.addField( "uv", 3 ); addAttribute( aComponentType ); // source object aSourceObj = genericAttrFn.create( "sourceObject", "so", &status ); genericAttrFn.addAccept(MFnData::kMesh); genericAttrFn.setStorable(false); addAttribute( aSourceObj ); CHECK_MSTATUS( status ); // volume object aVolumeObj = genericAttrFn.create( "volumeObject", "vo", &status ); genericAttrFn.addAccept(MFnData::kMesh); genericAttrFn.setArray(true); addAttribute( aVolumeObj ); CHECK_MSTATUS( status ); aClosedObj = numericAttrFn.create( "closedVolumeObject", "cvo", MFnNumericData::kBoolean, 1, &status ); numericAttrFn.setDefault(1); addAttribute( aClosedObj ); // ouput attribute // aOutValue = numericAttrFn.create( "outValue", "ov", MFnNumericData::kInt, 0, &status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable(false); addAttribute( aOutValue ); aOutCompList = typeAttrFn.create( "outComponent", "ocp", MFnComponentListData::kComponentList, &status ); CHECK_MSTATUS( status ); addAttribute(aOutCompList); aOutMesh = typeAttrFn.create( "outMesh", "om", MFnData::kMesh, &status ); CHECK_MSTATUS( status ); addAttribute(aOutMesh); // Attribute Affects for aOutValue attributeAffects( aEnable, aOutValue ); attributeAffects( aFixPanel, aOutValue ); attributeAffects( aComponentType, aOutValue ); attributeAffects( aKeepSel, aOutValue ); attributeAffects( aClosedObj, aOutValue ); attributeAffects( aSourceObj, aOutValue ); attributeAffects( aVolumeObj, aOutValue ); //Attribute Affects for aOutCompList attributeAffects( aEnable, aOutCompList); attributeAffects( aFixPanel, aOutCompList ); attributeAffects( aComponentType, aOutCompList ); attributeAffects( aKeepSel, aOutCompList ); attributeAffects( aClosedObj, aOutCompList ); attributeAffects( aSourceObj, aOutCompList ); attributeAffects( aVolumeObj, aOutCompList ); //Attribute Affects for aOutMesh attributeAffects( aEnable, aOutMesh); attributeAffects( aFixPanel, aOutMesh ); attributeAffects( aComponentType, aOutMesh ); attributeAffects( aKeepSel, aOutMesh ); attributeAffects( aClosedObj, aOutMesh ); attributeAffects( aSourceObj, aOutMesh ); attributeAffects( aVolumeObj, aOutMesh ); return MS::kSuccess; }
MStatus OpenSubdivPtexShader::initialize() { MFnTypedAttribute typedAttr; MFnNumericAttribute numAttr; MFnEnumAttribute enumAttr; // level aLevel = numAttr.create("level", "lv", MFnNumericData::kLong, 3); numAttr.setInternal(true); numAttr.setMin(1); numAttr.setSoftMax(5); numAttr.setMax(10); // tessFactor aTessFactor = numAttr.create("tessFactor", "tessf", MFnNumericData::kLong, 2); numAttr.setInternal(true); numAttr.setMin(1); numAttr.setMax(10); // scheme aScheme = enumAttr.create("scheme", "sc", OsdPtexMeshData::kCatmark); enumAttr.addField("Catmull-Clark", OsdPtexMeshData::kCatmark); enumAttr.addField("Loop", OsdPtexMeshData::kLoop); enumAttr.addField("Bilinear", OsdPtexMeshData::kBilinear); enumAttr.setInternal(true); // kernel aKernel = enumAttr.create("kernel", "kn", OsdPtexMeshData::kCPU); enumAttr.addField("CPU", OsdPtexMeshData::kCPU); #ifdef OPENSUBDIV_HAS_OPENMP enumAttr.addField("OpenMP", OsdPtexMeshData::kOPENMP); #endif #ifdef OPENSUBDIV_HAS_OPENCL enumAttr.addField("CL", OsdPtexMeshData::kCL); #endif #ifdef OPENSUBDIV_HAS_CUDA enumAttr.addField("CUDA", OsdPtexMeshData::kCUDA); #endif enumAttr.setInternal(true); // interpolateBoundary aInterpolateBoundary = enumAttr.create("interpolateBoundary", "ib", OsdPtexMeshData::kInterpolateBoundaryNone); enumAttr.addField("None", OsdPtexMeshData::kInterpolateBoundaryNone); enumAttr.addField("Edge Only", OsdPtexMeshData::kInterpolateBoundaryEdgeOnly); enumAttr.addField("Edge and Corner", OsdPtexMeshData::kInterpolateBoundaryEdgeAndCorner); enumAttr.addField("Always Sharp", OsdPtexMeshData::kInterpolateBoundaryAlwaysSharp); enumAttr.setInternal(true); // adaptive aAdaptive = numAttr.create("adaptive", "adp", MFnNumericData::kBoolean, true); numAttr.setInternal(true); // wireframe aWireframe = numAttr.create("wireframe", "wf", MFnNumericData::kBoolean, false); // material attributes aDiffuse = numAttr.createColor("diffuse", "d"); numAttr.setDefault(0.6f, 0.6f, 0.7f); aAmbient = numAttr.createColor("ambient", "a"); numAttr.setDefault(0.1f, 0.1f, 0.1f); aSpecular = numAttr.createColor("specular", "s"); numAttr.setDefault(0.3f, 0.3f, 0.3f); // Ptex Texture Attributes // // diffuseEnvironmentMapFile; aDiffuseEnvironmentMapFile = typedAttr.create("diffuseEnvironmentMap", "difenv", MFnData::kString); typedAttr.setInternal(true); // don't let maya hold on to string when fileNode is disconnected typedAttr.setDisconnectBehavior(MFnAttribute::kReset); // specularEnvironmentMapFile; aSpecularEnvironmentMapFile = typedAttr.create("specularEnvironmentMap", "specenv", MFnData::kString); typedAttr.setInternal(true); // don't let maya hold on to string when fileNode is disconnected typedAttr.setDisconnectBehavior(MFnAttribute::kReset); // colorFile; aColorFile = typedAttr.create("colorFile", "cf", MFnData::kString); typedAttr.setInternal(true); // displacementFile; aDisplacementFile = typedAttr.create("displacementFile", "df", MFnData::kString); typedAttr.setInternal(true); // occlusionFile; aOcclusionFile = typedAttr.create("occlusionFile", "of", MFnData::kString); typedAttr.setInternal(true); // enableDisplacement; aEnableDisplacement = numAttr.create("enableDisplacement", "end", MFnNumericData::kBoolean, 1); numAttr.setInternal(true); // enableColor; aEnableColor = numAttr.create("enableColor", "enc", MFnNumericData::kBoolean, 1); numAttr.setInternal(true); // enableOcclusion; aEnableOcclusion = numAttr.create("enableOcclusion", "eno", MFnNumericData::kBoolean, 1); numAttr.setInternal(true); // enableNormal; aEnableNormal = numAttr.create("enableNormal", "enn", MFnNumericData::kBoolean, 1); numAttr.setInternal(true); // fresnelBias; aFresnelBias = numAttr.create("fresnelBias", "fb", MFnNumericData::kFloat, 0.2f); numAttr.setMin(0); numAttr.setMax(1); // fresnelScale; aFresnelScale = numAttr.create("fresnelScale", "fs", MFnNumericData::kFloat, 1.0f); numAttr.setMin(0); numAttr.setSoftMax(1); // fresnelPower; aFresnelPower = numAttr.create("fresnelPower", "fp", MFnNumericData::kFloat, 5.0f); numAttr.setMin(0); numAttr.setSoftMax(10); // shaderSource; aShaderSource = typedAttr.create("shaderSource", "ssrc", MFnData::kString); typedAttr.setInternal(true); // add attributes addAttribute(aLevel); addAttribute(aTessFactor); addAttribute(aScheme); addAttribute(aKernel); addAttribute(aInterpolateBoundary); addAttribute(aAdaptive); addAttribute(aWireframe); addAttribute(aDiffuse); addAttribute(aAmbient); addAttribute(aSpecular); addAttribute(aShaderSource); addAttribute(aDiffuseEnvironmentMapFile); addAttribute(aSpecularEnvironmentMapFile); addAttribute(aColorFile); addAttribute(aDisplacementFile); addAttribute(aOcclusionFile); addAttribute(aEnableDisplacement); addAttribute(aEnableColor); addAttribute(aEnableOcclusion); addAttribute(aEnableNormal); addAttribute(aFresnelBias); addAttribute(aFresnelScale); addAttribute(aFresnelPower); return MS::kSuccess; }
// // DESCRIPTION: /////////////////////////////////////////////////////// MStatus Cell3D::initialize() { MFnMatrixAttribute mAttr; MFnNumericAttribute nAttr; // Input attributes aColorGain = nAttr.createColor("colorGain", "cg"); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setDefault(1.0f,1.0f,1.0f) ); aColorOffset = nAttr.createColor("colorOffset", "co"); MAKE_INPUT(nAttr); aPlaceMat = mAttr.create("placementMatrix", "pm", MFnMatrixAttribute::kFloat); MAKE_INPUT(mAttr); // Implicit shading network attributes aPointWorld = nAttr.createPoint("pointWorld", "pw"); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setHidden(true) ); // Create output attributes aOutF0 = nAttr.create( "F0", "f0", MFnNumericData::kFloat); MAKE_OUTPUT(nAttr); aOutF1 = nAttr.create( "F1", "f1", MFnNumericData::kFloat); MAKE_OUTPUT(nAttr); aOutN0 = nAttr.create( "N0", "n0", MFnNumericData::kFloat); MAKE_OUTPUT(nAttr); aOutBorderDist = nAttr.create("borderDistance", "bd", MFnNumericData::kFloat); MAKE_OUTPUT(nAttr); aOutColor = nAttr.createColor("outColor", "oc"); MAKE_OUTPUT(nAttr); aOutAlpha = nAttr.create( "outAlpha", "oa", MFnNumericData::kFloat); MAKE_OUTPUT(nAttr); // Add attributes to the node database. CHECK_MSTATUS( addAttribute(aColorGain) ); CHECK_MSTATUS( addAttribute(aColorOffset) ); CHECK_MSTATUS( addAttribute(aPointWorld) ); CHECK_MSTATUS( addAttribute(aPlaceMat) ); CHECK_MSTATUS( addAttribute(aOutAlpha) ); CHECK_MSTATUS( addAttribute(aOutColor) ); CHECK_MSTATUS( addAttribute(aOutF0) ); CHECK_MSTATUS( addAttribute(aOutF1) ); CHECK_MSTATUS( addAttribute(aOutN0) ); CHECK_MSTATUS( addAttribute(aOutBorderDist) ); // All input affect the output color and alpha CHECK_MSTATUS( attributeAffects (aColorGain, aOutColor) ); CHECK_MSTATUS( attributeAffects (aColorOffset, aOutColor) ); CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutColor) ); CHECK_MSTATUS( attributeAffects (aPointWorld, aOutColor) ); CHECK_MSTATUS( attributeAffects (aColorGain, aOutAlpha) ); CHECK_MSTATUS( attributeAffects (aColorOffset, aOutAlpha) ); CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutAlpha) ); CHECK_MSTATUS( attributeAffects (aPointWorld, aOutAlpha) ); // Geometry attribute affect all other outputs. CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutF0) ); CHECK_MSTATUS( attributeAffects (aPointWorld, aOutF0) ); CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutF1) ); CHECK_MSTATUS( attributeAffects (aPointWorld, aOutF1) ); CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutN0) ); CHECK_MSTATUS( attributeAffects (aPointWorld, aOutN0) ); CHECK_MSTATUS( attributeAffects (aPlaceMat, aOutBorderDist) ); CHECK_MSTATUS( attributeAffects (aPointWorld, aOutBorderDist) ); return MS::kSuccess; }