MStatus SurfaceAttach::initialize() { MFnTypedAttribute fnTypeAttr; MFnNumericAttribute fnNumAttr; MFnUnitAttribute fnUnitAttr; MFnCompoundAttribute fnCompoundAttr; MFnEnumAttribute fnEnumAttr; MFnMatrixAttribute fnMatAttr; MStatus stat; // Input Attributes direction = fnEnumAttr.create("direction", "dire", 0); fnEnumAttr.addField("U", 0); fnEnumAttr.addField("V", 1); surface = fnTypeAttr.create("surface", "surface", MFnData::kNurbsSurface); parentInverse = fnMatAttr.create("parentInverse", "ps", MFnMatrixAttribute::kDouble); fnMatAttr.setKeyable(true); samples = fnNumAttr.create("samples", "samples", MFnNumericData::kInt, 1000); fnNumAttr.setKeyable(true); fnNumAttr.setMin(1.0); staticLength = fnNumAttr.create("staticLength", "staticLength", MFnNumericData::kDouble, 0.0001); fnNumAttr.setKeyable(true); fnNumAttr.setMin(0.0001); offset = fnNumAttr.create("offset", "offset", MFnNumericData::kDouble, 0.0); fnNumAttr.setKeyable(true); genus = fnEnumAttr.create("type", "type", 0); fnEnumAttr.addField("Parametric", 0); fnEnumAttr.addField("Percentage", 1); fnEnumAttr.addField("FixedLength", 2); fnEnumAttr.setKeyable(true); reverse = fnNumAttr.create("reverse", "reverse", MFnNumericData::kBoolean, false); fnNumAttr.setKeyable(true); inU = fnNumAttr.create("inU", "U", MFnNumericData::kDouble, 0.5); fnNumAttr.setKeyable(true); inV = fnNumAttr.create("inV", "V", MFnNumericData::kDouble, 0.5); fnNumAttr.setKeyable(true); inUV = fnCompoundAttr.create("inUV", "inUV"); fnCompoundAttr.setKeyable(true); fnCompoundAttr.setArray(true); fnCompoundAttr.addChild(inU); fnCompoundAttr.addChild(inV); fnCompoundAttr.setUsesArrayDataBuilder(true); // Output Attributes translateX = fnNumAttr.create("translateX", "translateX", MFnNumericData::kDouble); fnNumAttr.setWritable(false); fnNumAttr.setStorable(false); translateY = fnNumAttr.create("translateY", "translateY", MFnNumericData::kDouble); fnNumAttr.setWritable(false); fnNumAttr.setStorable(false); translateZ = fnNumAttr.create("translateZ", "translateZ", MFnNumericData::kDouble); fnNumAttr.setWritable(false); fnNumAttr.setStorable(false); translate = fnNumAttr.create("translate", "translate", translateX, translateY, translateZ); fnNumAttr.setWritable(false); fnNumAttr.setStorable(false); rotateX = fnUnitAttr.create("rotateX", "rotateX", MFnUnitAttribute::kAngle); fnUnitAttr.setWritable(false); fnUnitAttr.setStorable(false); rotateY = fnUnitAttr.create("rotateY", "rotateY", MFnUnitAttribute::kAngle); fnUnitAttr.setWritable(false); fnUnitAttr.setStorable(false); rotateZ = fnUnitAttr.create("rotateZ", "rotateZ", MFnUnitAttribute::kAngle); fnUnitAttr.setWritable(false); fnUnitAttr.setStorable(false); rotate = fnNumAttr.create("rotate", "rotate", rotateX, rotateY, rotateZ); fnNumAttr.setWritable(false); out = fnCompoundAttr.create("out", "out"); fnCompoundAttr.setWritable(false); fnCompoundAttr.setArray(true); fnCompoundAttr.addChild(translate); fnCompoundAttr.addChild(rotate); fnCompoundAttr.setUsesArrayDataBuilder(true); // These aren't going to fail, give me a break :) // Add Attributes SurfaceAttach::addAttribute(direction); SurfaceAttach::addAttribute(surface); SurfaceAttach::addAttribute(parentInverse); SurfaceAttach::addAttribute(samples); SurfaceAttach::addAttribute(staticLength); SurfaceAttach::addAttribute(offset); SurfaceAttach::addAttribute(genus); SurfaceAttach::addAttribute(reverse); SurfaceAttach::addAttribute(inUV); SurfaceAttach::addAttribute(out); // Attribute Affects SurfaceAttach::attributeAffects(direction, translate); SurfaceAttach::attributeAffects(surface, translate); SurfaceAttach::attributeAffects(parentInverse, translate); SurfaceAttach::attributeAffects(staticLength, translate); SurfaceAttach::attributeAffects(samples, translate); SurfaceAttach::attributeAffects(offset, translate); SurfaceAttach::attributeAffects(genus, translate); SurfaceAttach::attributeAffects(reverse, translate); SurfaceAttach::attributeAffects(inU, translate); SurfaceAttach::attributeAffects(inV, translate); SurfaceAttach::attributeAffects(direction, rotate); SurfaceAttach::attributeAffects(surface, rotate); SurfaceAttach::attributeAffects(parentInverse, rotate); SurfaceAttach::attributeAffects(staticLength, rotate); SurfaceAttach::attributeAffects(samples, rotate); SurfaceAttach::attributeAffects(offset, rotate); SurfaceAttach::attributeAffects(genus, rotate); SurfaceAttach::attributeAffects(reverse, rotate); SurfaceAttach::attributeAffects(inU, rotate); SurfaceAttach::attributeAffects(inV, rotate); return MS::kSuccess; }
MStatus MG_softIk::initialize() { //This is the nurbs input attribute MFnTypedAttribute typedFn; MFnCompoundAttribute compund; MFnNumericAttribute numFn; MFnMatrixAttribute matrixFn; startMatrix =matrixFn.create("startMatrix","stm"); addAttribute(startMatrix); endMatrix =matrixFn.create("endMatrix","enm"); addAttribute(endMatrix); upInitLength = numFn.create("upInitLength","uil",MFnNumericData::kDouble,0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(upInitLength); downInitLength = numFn.create("downInitLength","dil",MFnNumericData::kDouble,0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(downInitLength); globalScale = numFn.create("globalScale","gb",MFnNumericData::kDouble,0); numFn.setStorable(true); numFn.setKeyable(true); numFn.setMin(0.001); addAttribute(globalScale); softDistance = numFn.create("softDistance","sd",MFnNumericData::kDouble,0); numFn.setMin(0.001); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(softDistance); stretch = numFn.create("stretch","str",MFnNumericData::kDouble,0); numFn.setMin(0.0); numFn.setMax(1.0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(stretch); slide = numFn.create("slide","sld",MFnNumericData::kDouble,0.5); numFn.setMin(0.0); numFn.setMax(1.0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(slide); upScale = numFn.create("upScale","ups",MFnNumericData::kDouble,1); numFn.setStorable(false); numFn.setKeyable(false); numFn.setWritable(false); addAttribute(upScale); downScale = numFn.create("downScale","dws",MFnNumericData::kDouble,1); numFn.setStorable(false); numFn.setKeyable(false); numFn.setWritable(false); addAttribute(downScale); outputTranslateX = numFn.create("outputTranslateX","otx",MFnNumericData::kDouble,0); numFn.setStorable(false); numFn.setKeyable(false); numFn.setWritable(false); addAttribute(outputTranslateX); outputTranslateY = numFn.create("outputTranslateY","oty",MFnNumericData::kDouble,0); numFn.setStorable(false); numFn.setWritable(false); numFn.setKeyable(false); addAttribute(outputTranslateY); outputTranslateZ = numFn.create("outputTranslateZ","otz",MFnNumericData::kDouble,0); numFn.setStorable(false); numFn.setKeyable(false); numFn.setWritable(false); addAttribute(outputTranslateZ); outputTranslate= compund.create("outputTranslate","ot"); compund.addChild(outputTranslateX); compund.addChild(outputTranslateY); compund.addChild(outputTranslateZ); compund.setStorable(false); compund.setKeyable(false); compund.setWritable(false); addAttribute(outputTranslate); attributeAffects( startMatrix ,outputTranslate) ; attributeAffects( endMatrix ,outputTranslate) ; attributeAffects( softDistance ,outputTranslate) ; attributeAffects( stretch ,outputTranslate) ; attributeAffects( slide ,outputTranslate) ; attributeAffects( globalScale ,outputTranslate) ; attributeAffects( startMatrix ,upScale) ; attributeAffects( endMatrix ,upScale) ; attributeAffects( stretch ,upScale) ; attributeAffects( softDistance ,upScale) ; attributeAffects( slide ,upScale) ; attributeAffects( globalScale ,upScale) ; attributeAffects( startMatrix ,downScale) ; attributeAffects( endMatrix ,downScale) ; attributeAffects( softDistance ,downScale) ; attributeAffects( stretch ,downScale) ; attributeAffects( slide ,downScale) ; attributeAffects( globalScale ,downScale) ; return MS::kSuccess; }
MStatus MG_nurbsRivet::initialize() { //This is the nurbs input attribute MFnTypedAttribute typedFn; MFnCompoundAttribute compund; MFnNumericAttribute numFn; MFnMatrixAttribute matrixFn; inputNurbSurface = typedFn.create("inputNurbSurface","in",MFnData::kNurbsSurface); typedFn.setStorable(true); addAttribute(inputNurbSurface); //This is the input point attribute inputPointX = numFn.create("inputPointX","ipx",MFnNumericData::kDouble,0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(inputPointX); inputPointY = numFn.create("inputPointY","ipy",MFnNumericData::kDouble,0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(inputPointY); inputPointZ = numFn.create("inputPointZ","ipz",MFnNumericData::kDouble,0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(inputPointZ); inputPoint= compund.create("inputPoint","ip"); compund.addChild(inputPointX); compund.addChild(inputPointY); compund.addChild(inputPointZ); addAttribute(inputPoint); //This is the recompute point checkbox recompute = numFn.create("recompute","r",MFnNumericData::kBoolean,1); numFn.setKeyable(true); numFn.setStorable(true); addAttribute(recompute); //This is U attribute uValue = numFn.create("uValue","u",MFnNumericData::kFloat , 0); numFn.setKeyable(true); numFn.setStorable(true); addAttribute(uValue); //This is V attribute vValue = numFn.create("vValue","v",MFnNumericData::kFloat , 0 ); numFn.setKeyable(true); numFn.setStorable(true); addAttribute(vValue); //This is the output translate attribute outputX = numFn.create("outputTranslateX","otx",MFnNumericData::kDouble,0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(outputX); outputY = numFn.create("outputTranslateY","oty",MFnNumericData::kDouble,0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(outputY); outputZ = numFn.create("outputTranslateZ","otz",MFnNumericData::kDouble,0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(outputZ); output= compund.create("outputTranslate","ot"); compund.addChild(outputX); compund.addChild(outputY); compund.addChild(outputZ); compund.setKeyable(false); compund.setStorable(false); compund.setWritable(false); addAttribute(output); //output = numFn.createPoint("outputTranslate","ot"); //numFn.setKeyable(false); //numFn.setStorable(false); //numFn.setWritable(false); //addAttribute(output); //This is the output rotate attribute outputRotateX = numFn.create("outputRotateX","orx",MFnNumericData::kDouble,0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(outputRotateX); outputRotateY = numFn.create("outputRotateY","ory",MFnNumericData::kDouble,0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(outputRotateY); outputRotateZ = numFn.create("outputRotateZ","orz",MFnNumericData::kDouble,0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(outputRotateZ); outputRotate= compund.create("outputRotate","oro"); compund.addChild(outputRotateX); compund.addChild(outputRotateY); compund.addChild(outputRotateZ); compund.setKeyable(false); compund.setStorable(false); compund.setWritable(false); addAttribute(outputRotate); //Those are all the matrix input outputMatrix =matrixFn.create("outputMatrix","om"); matrixFn.setKeyable(false); matrixFn.setStorable(false); matrixFn.setWritable(false); addAttribute(outputMatrix); //offset matrix offsetMatrix =matrixFn.create("offsetMatrix","ofm"); MMatrix defMatrix; defMatrix.setToIdentity(); matrixFn.setDefault(defMatrix); matrixFn.setKeyable(false); matrixFn.setStorable(true); matrixFn.setWritable(true); addAttribute(offsetMatrix); //all the attr affects attributeAffects (recompute,output); attributeAffects (inputPoint,output); attributeAffects (inputNurbSurface,output); attributeAffects (uValue,output); attributeAffects (vValue,output); attributeAffects (offsetMatrix,output); attributeAffects (recompute,outputRotate); attributeAffects (inputPoint,outputRotate); attributeAffects (inputNurbSurface,outputRotate); attributeAffects (uValue,outputRotate); attributeAffects (vValue,outputRotate); attributeAffects (offsetMatrix,outputRotate); attributeAffects (recompute,outputMatrix); attributeAffects (inputPoint,outputMatrix); attributeAffects (inputNurbSurface,outputMatrix); attributeAffects (uValue,outputMatrix); attributeAffects (vValue,outputMatrix); attributeAffects (offsetMatrix,outputMatrix); return MS::kSuccess; }