MStatus testNpassiveNode::initialize() { MStatus stat; MFnTypedAttribute tAttr; inputGeom = tAttr.create("inputGeom", "ing", MFnData::kMesh, MObject::kNullObj, &stat ); //statCheck(stat, "failed to create inputGeom"); tAttr.setWritable(true); tAttr.setStorable(true); tAttr.setHidden(true); currentState = tAttr.create("currentState", "cus", MFnData::kNObject, MObject::kNullObj, &stat ); // statCheck(stat, "failed to create currentState"); tAttr.setWritable(true); tAttr.setStorable(false); tAttr.setHidden(true); startState = tAttr.create( "startState", "sts", MFnData::kNObject, MObject::kNullObj, &stat ); //statCheck(stat, "failed to create startState"); tAttr.setWritable(true); tAttr.setStorable(false); tAttr.setHidden(true); MFnUnitAttribute uniAttr; currentTime = uniAttr.create( "currentTime", "ctm" , MFnUnitAttribute::kTime, 0.0, &stat ); addAttribute(inputGeom); addAttribute(currentTime); addAttribute(startState); addAttribute(currentState); attributeAffects(inputGeom, startState); attributeAffects(inputGeom, currentState); attributeAffects(currentTime, currentState); attributeAffects(currentTime, startState); return MStatus::kSuccess; }
MStatus AlembicCurvesDeformNode::initialize() { MStatus status; MFnUnitAttribute uAttr; MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MFnGenericAttribute gAttr; MFnStringData emptyStringData; MObject emptyStringObject = emptyStringData.create(""); // input time mTimeAttr = uAttr.create("inTime", "tm", MFnUnitAttribute::kTime, 0.0); status = uAttr.setStorable(true); status = uAttr.setKeyable(true); status = addAttribute(mTimeAttr); // input file name mFileNameAttr = tAttr.create("fileName", "fn", MFnData::kString, emptyStringObject); status = tAttr.setStorable(true); status = tAttr.setUsedAsFilename(true); status = tAttr.setKeyable(false); status = addAttribute(mFileNameAttr); // input identifier mIdentifierAttr = tAttr.create("identifier", "if", MFnData::kString, emptyStringObject); status = tAttr.setStorable(true); status = tAttr.setKeyable(false); status = addAttribute(mIdentifierAttr); // output for list of ArbGeomParams mGeomParamsList = tAttr.create("ExocortexAlembic_GeomParams", "exo_gp", MFnData::kString, emptyStringObject); status = tAttr.setStorable(true); status = tAttr.setKeyable(false); status = tAttr.setHidden(false); status = tAttr.setInternal(true); status = addAttribute(mGeomParamsList); // output for list of UserAttributes mUserAttrsList = tAttr.create("ExocortexAlembic_UserAttributes", "exo_ua", MFnData::kString, emptyStringObject); status = tAttr.setStorable(true); status = tAttr.setKeyable(false); status = tAttr.setHidden(false); status = tAttr.setInternal(true); status = addAttribute(mUserAttrsList); // create a mapping status = attributeAffects(mTimeAttr, outputGeom); status = attributeAffects(mFileNameAttr, outputGeom); status = attributeAffects(mIdentifierAttr, outputGeom); return status; }
MStatus testNucleusNode::initialize() { MStatus stat; MFnTypedAttribute tAttr; startState = tAttr.create("startState", "sst", MFnData::kNObject, MObject::kNullObj, &stat ); statCheck(stat, "failed to create startState"); tAttr.setWritable(true); tAttr.setStorable(true); tAttr.setHidden(true); tAttr.setArray(true); currentState = tAttr.create("currentState", "cst", MFnData::kNObject, MObject::kNullObj, &stat ); statCheck(stat, "failed to create currentState"); tAttr.setWritable(true); tAttr.setStorable(true); tAttr.setHidden(true); tAttr.setArray(true); nextState = tAttr.create("nextState", "nst", MFnData::kNObject, MObject::kNullObj, &stat ); statCheck(stat, "failed to create nextState"); tAttr.setWritable(true); tAttr.setStorable(true); tAttr.setHidden(true); tAttr.setArray(true); MFnUnitAttribute uniAttr; currentTime = uniAttr.create( "currentTime", "ctm" , MFnUnitAttribute::kTime, 0.0, &stat ); addAttribute(startState); addAttribute(currentState); addAttribute(nextState); addAttribute(currentTime); attributeAffects(startState, nextState); attributeAffects(currentState, nextState); attributeAffects(currentTime, nextState); return MStatus::kSuccess; }
MStatus PolyColourNode::initialize() { MStatus status; MFnTypedAttribute attrFn; MFnNumericAttribute attrNum; MFnEnumAttribute enumFn; m_inMesh = attrFn.create("inMesh", "im", MFnMeshData::kMesh); attrFn.setStorable(false); attrFn.setHidden(true); /* m_cpList = attrFn.create("inputComponents", "ics",MFnComponentListData::kComponentList); attrFn.setStorable(true); attrFn.setHidden(true); attrFn.setConnectable(false); */ m_colors = attrFn.create("colors", "cols", MFnData::kDoubleArray); attrFn.setStorable(false); attrFn.setHidden(true); m_colorsDest = attrFn.create("colorsDest", "colsd", MFnData::kDoubleArray); attrFn.setStorable(false); attrFn.setHidden(true); //attrFn.setConnectable(false); //m_verts = attrFn.create("verts", "vts",MFnData::kIntArray); //attrFn.setStorable(true); //attrFn.setHidden(false); status = addAttribute( m_inMesh ); // status = addAttribute( m_cpList ); status = addAttribute( m_colors ); status = addAttribute( m_colorsDest ); //status = addAttribute( m_verts ); // status = attributeAffects( m_inMesh, m_outMesh ); // status = attributeAffects( m_cpList, m_outMesh ); return status; }
MStatus ParameterisedHolder<B>::initialize() { MStatus s; MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; aParameterisedClassName = tAttr.create( "className", "clas", MFnData::kString ); tAttr.setReadable(true); tAttr.setWritable(true); tAttr.setStorable(true); tAttr.setConnectable(false); tAttr.setHidden(true); s = B::addAttribute( aParameterisedClassName ); assert(s); aParameterisedVersion = nAttr.create("version", "ver", MFnNumericData::kInt, 1, &s ); assert(s); nAttr.setReadable(true); nAttr.setWritable(true); nAttr.setStorable(true); nAttr.setConnectable(false); nAttr.setHidden(true); s = B::addAttribute( aParameterisedVersion ); assert(s); aParameterisedSearchPathEnvVar = tAttr.create("searchPathEnvVar", "spev", MFnData::kString ); tAttr.setReadable(true); tAttr.setWritable(true); tAttr.setStorable(true); tAttr.setConnectable(false); tAttr.setHidden(true); s = B::addAttribute( aParameterisedSearchPathEnvVar ); assert(s); MPxManipContainer::addToManipConnectTable( id ); return MS::kSuccess; }
// // Initialize the node // MStatus jhMeshBlur::initialize() { // attribute types MFnUnitAttribute unitAttr; MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; aOldMeshData = tAttr.create("oldMesh","om",MFnData::kPointArray); tAttr.setArray(true); tAttr.setHidden(true); tAttr.setIndexMatters(true); // create the attributes aStrength = nAttr.create( "Strength", "str", MFnNumericData::kFloat,1.0); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setMax(1.0); nAttr.setMin(0.0); aTreshhold = nAttr.create( "Treshold", "tres", MFnNumericData::kFloat,0.0); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setMin(0.0); aShapeFactor = nAttr.create( "ShapeFactor", "shapef", MFnNumericData::kFloat,0.5); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setMax(1.0); nAttr.setMin(0.0); aTweakBlur = nAttr.create( "TweakBlur", "tweak", MFnNumericData::kBoolean,false); nAttr.setKeyable(false); nAttr.setChannelBox(true); aQuadInterp = nAttr.create( "QuadInterpolation", "qi", MFnNumericData::kBoolean,true); nAttr.setKeyable(false); nAttr.setChannelBox(true); aInterpPower = nAttr.create( "InterpolationPower", "interp", MFnNumericData::kDouble, 0.75); nAttr.setKeyable(true); nAttr.setMax(1.0); nAttr.setMin(0.0); aTime = unitAttr.create( "time", "tm", MFnUnitAttribute::kTime, 1.0 ); unitAttr.setStorable(true); unitAttr.setCached(true); unitAttr.setReadable(true); unitAttr.setWritable(true); unitAttr.setAffectsAppearance(true); unitAttr.setAffectsWorldSpace(true); // Make the attributes visible to the user addAttribute( aStrength); addAttribute( aTreshhold); addAttribute( aTime); addAttribute( aTweakBlur); addAttribute( aQuadInterp); addAttribute( aInterpPower); addAttribute( aOldMeshData); // Make sure when an attribute changes, the node updates attributeAffects( aTime, outputGeom ); attributeAffects( aStrength, outputGeom ); attributeAffects( aTreshhold, outputGeom ); attributeAffects( aQuadInterp, outputGeom ); attributeAffects( aInterpPower, outputGeom ); // Not implented yet, but make the weights paintable :) MGlobal::executeCommand("makePaintable -attrType multiFloat -sm deformer jhMeshBlur weights;"); return MStatus::kSuccess; }
MStatus AlembicNode::initialize() { MStatus status; MFnUnitAttribute uAttr; MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MFnGenericAttribute gAttr; MFnEnumAttribute eAttr; // add the input attributes: time, file, sequence time mTimeAttr = uAttr.create("time", "tm", MFnUnitAttribute::kTime, 0.0); status = uAttr.setStorable(true); status = addAttribute(mTimeAttr); // input file name MFnStringData fileFnStringData; MObject fileNameDefaultObject = fileFnStringData.create(""); mAbcFileNameAttr = tAttr.create("abc_File", "fn", MFnData::kString, fileNameDefaultObject); status = tAttr.setStorable(true); status = tAttr.setUsedAsFilename(true); status = addAttribute(mAbcFileNameAttr); // playback speed mSpeedAttr = nAttr.create("speed", "sp", MFnNumericData::kDouble, 1.0, &status); status = nAttr.setWritable(true); status = nAttr.setStorable(true); status = nAttr.setKeyable(true); status = addAttribute(mSpeedAttr); // frame offset mOffsetAttr = nAttr.create("offset", "of", MFnNumericData::kDouble, 0, &status); status = nAttr.setWritable(true); status = nAttr.setStorable(true); status = nAttr.setKeyable(true); status = addAttribute(mOffsetAttr); // cycle type mCycleTypeAttr = eAttr.create("cycleType", "ct", 0, &status ); status = eAttr.addField("Hold", PLAYTYPE_HOLD); status = eAttr.addField("Loop", PLAYTYPE_LOOP); status = eAttr.addField("Reverse", PLAYTYPE_REVERSE); status = eAttr.addField("Bounce", PLAYTYPE_BOUNCE); status = eAttr.setWritable(true); status = eAttr.setStorable(true); status = eAttr.setKeyable(true); status = addAttribute(mCycleTypeAttr); // Regex Filter // This is a hidden variable to preserve a regexIncludefilter string // into a .ma file. mIncludeFilterAttr = tAttr.create("regexIncludeFilter", "ift", MFnData::kString); status = tAttr.setStorable(true); status = tAttr.setHidden(true); status = addAttribute(mIncludeFilterAttr); // Regex Filter // This is a hidden variable to preserve a regexExcludefilter string // into a .ma file. mExcludeFilterAttr = tAttr.create("regexExcludeFilter", "eft", MFnData::kString); status = tAttr.setStorable(true); status = tAttr.setHidden(true); status = addAttribute(mExcludeFilterAttr); // sequence min and max in frames mStartFrameAttr = nAttr.create("startFrame", "sf", MFnNumericData::kDouble, 0, &status); status = nAttr.setWritable(false); status = nAttr.setStorable(true); status = addAttribute(mStartFrameAttr); mEndFrameAttr = nAttr.create("endFrame", "ef", MFnNumericData::kDouble, 0, &status); status = nAttr.setWritable(false); status = nAttr.setStorable(true); status = addAttribute(mEndFrameAttr); // add the output attributes // sampled subD mesh MFnMeshData fnMeshData; MObject meshDefaultObject = fnMeshData.create(&status); mOutSubDArrayAttr = tAttr.create("outSubDMesh", "osubd", MFnData::kMesh, meshDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutSubDArrayAttr); // sampled poly mesh mOutPolyArrayAttr = tAttr.create("outPolyMesh", "opoly", MFnData::kMesh, meshDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutPolyArrayAttr); // sampled nurbs surface MFnNurbsSurfaceData fnNSData; MObject nsDefaultObject = fnNSData.create(&status); mOutNurbsSurfaceArrayAttr = tAttr.create("outNSurface", "ons", MFnData::kNurbsSurface, nsDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutNurbsSurfaceArrayAttr); // sampled nurbs curve group MFnNurbsCurveData fnNCData; MObject ncDefaultObject = fnNCData.create(&status); mOutNurbsCurveGrpArrayAttr = tAttr.create("outNCurveGrp", "onc", MFnData::kNurbsCurve, ncDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutNurbsCurveGrpArrayAttr); // sampled locator mOutLocatorPosScaleArrayAttr = nAttr.create("outLoc", "olo", MFnNumericData::kDouble, 0.0, &status); status = nAttr.setStorable(false); status = nAttr.setWritable(false); status = nAttr.setArray(true); status = nAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutLocatorPosScaleArrayAttr); // sampled transform operations mOutTransOpArrayAttr = nAttr.create("transOp", "to", MFnNumericData::kDouble, 0.0, &status); status = nAttr.setStorable(false); status = nAttr.setWritable(false); status = nAttr.setArray(true); status = nAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutTransOpArrayAttr); // sampled camera // assume the boolean variables cannot be keyed mOutCameraArrayAttr = nAttr.create("outCamera", "ocam", MFnNumericData::kDouble, 0.0, &status); status = nAttr.setStorable(false); status = nAttr.setWritable(false); status = nAttr.setArray(true); status = nAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutCameraArrayAttr); // sampled custom-attributes mOutPropArrayAttr = gAttr.create("prop", "pr", &status); status = gAttr.addNumericDataAccept(MFnNumericData::kBoolean); status = gAttr.addNumericDataAccept(MFnNumericData::kByte); status = gAttr.addNumericDataAccept(MFnNumericData::kShort); status = gAttr.addNumericDataAccept(MFnNumericData::k2Short); status = gAttr.addNumericDataAccept(MFnNumericData::k3Short); status = gAttr.addNumericDataAccept(MFnNumericData::kInt); status = gAttr.addNumericDataAccept(MFnNumericData::k2Int); status = gAttr.addNumericDataAccept(MFnNumericData::k3Int); status = gAttr.addNumericDataAccept(MFnNumericData::kFloat); status = gAttr.addNumericDataAccept(MFnNumericData::k2Float); status = gAttr.addNumericDataAccept(MFnNumericData::k3Float); status = gAttr.addNumericDataAccept(MFnNumericData::kDouble); status = gAttr.addNumericDataAccept(MFnNumericData::k2Double); status = gAttr.addNumericDataAccept(MFnNumericData::k3Double); status = gAttr.addNumericDataAccept(MFnNumericData::k4Double); status = gAttr.addDataAccept(MFnData::kString); status = gAttr.addDataAccept(MFnData::kIntArray); status = gAttr.addDataAccept(MFnData::kDoubleArray); status = gAttr.addDataAccept(MFnData::kVectorArray); status = gAttr.addDataAccept(MFnData::kPointArray); status = gAttr.setWritable(false); status = gAttr.setKeyable(false); status = gAttr.setArray(true); status = gAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutPropArrayAttr); // set up affection relationships status = attributeAffects(mTimeAttr, mOutSubDArrayAttr); status = attributeAffects(mTimeAttr, mOutPolyArrayAttr); status = attributeAffects(mTimeAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mTimeAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mTimeAttr, mOutTransOpArrayAttr); status = attributeAffects(mTimeAttr, mOutCameraArrayAttr); status = attributeAffects(mTimeAttr, mOutPropArrayAttr); status = attributeAffects(mTimeAttr, mOutLocatorPosScaleArrayAttr); status = attributeAffects(mSpeedAttr, mOutSubDArrayAttr); status = attributeAffects(mSpeedAttr, mOutPolyArrayAttr); status = attributeAffects(mSpeedAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mSpeedAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mSpeedAttr, mOutTransOpArrayAttr); status = attributeAffects(mSpeedAttr, mOutCameraArrayAttr); status = attributeAffects(mSpeedAttr, mOutPropArrayAttr); status = attributeAffects(mSpeedAttr, mOutLocatorPosScaleArrayAttr); status = attributeAffects(mOffsetAttr, mOutSubDArrayAttr); status = attributeAffects(mOffsetAttr, mOutPolyArrayAttr); status = attributeAffects(mOffsetAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mOffsetAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mOffsetAttr, mOutTransOpArrayAttr); status = attributeAffects(mOffsetAttr, mOutCameraArrayAttr); status = attributeAffects(mOffsetAttr, mOutPropArrayAttr); status = attributeAffects(mOffsetAttr, mOutLocatorPosScaleArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutSubDArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutPolyArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutTransOpArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutCameraArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutPropArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutLocatorPosScaleArrayAttr); MGlobal::executeCommand( UITemplateMELScriptStr ); return status; }
//---------------------------------------------------------------------------------------------------------------------- // this method creates the attributes for our node and sets some default values etc //---------------------------------------------------------------------------------------------------------------------- MStatus OceanNode::initialize(){ // Attributes to check whether the amplitude or wind vector have changed m_wdx = 0.0; m_wdz = 1.0; m_ws = 100.0; m_amp = 100.0; m_res = 0; MStatus status; // an emum attribute for use with the resolution MFnEnumAttribute enumAttr; // resolution m_resolution = enumAttr.create("resolution", "res", 0, &status); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to create \"resolution\" attribute"); enumAttr.addField("128x128", RES128); enumAttr.addField("256x256", RES256); enumAttr.addField("512x512", RES512); enumAttr.addField("1024x1024", RES1024); enumAttr.setKeyable(true); status = addAttribute(m_resolution); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"resolution\" attribute to OceanNode"); // now we are going to add several number attributes MFnNumericAttribute numAttr; // amplitde m_amplitude = numAttr.create( "amplitude", "amp", MFnNumericData::kDouble, 100.0, &status ); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL( status , "Unable to create \"amplitude\" attribute" ); numAttr.setChannelBox( true ); // add attribute status = addAttribute( m_amplitude ); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL( status , "Unable to add \"amplitude\" attribute to OceanNode" ); // frequency m_frequency = numAttr.create("frequency", "frq", MFnNumericData::kDouble, 0.5, &status); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to create \"frequency\" attribute"); numAttr.setChannelBox(true); status = addAttribute(m_frequency); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"frequency\" attribute to OceanNodee"); // the wind speed inputs MFnNumericAttribute windDirectionAttr; m_windDirectionX = windDirectionAttr.create( "windDirectionX", "wdx", MFnNumericData::kDouble, 0.0, &status); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL( status, "Unable to create \"wdx\" attribute"); windDirectionAttr.setChannelBox(true); windDirectionAttr.setMin(0.0); windDirectionAttr.setMax(1.0); // add attribute status = addAttribute( m_windDirectionX ); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"wdx\" attribute to OceanNode") m_windDirectionZ = windDirectionAttr.create( "windDirectionZ", "wdz", MFnNumericData::kDouble, 0.5, &status); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL( status, "Unable to create \"wdy\" attribute"); windDirectionAttr.setChannelBox(true); windDirectionAttr.setMin(0.0); windDirectionAttr.setMax(1.0); // add attribute status = addAttribute( m_windDirectionZ ); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"wdz\" attribute to OceanNode"); m_windSpeed = numAttr.create( "windSpeed", "ws", MFnNumericData::kDouble, 100.0, &status); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL( status, "Unable to create \"ws\" attribute"); numAttr.setChannelBox(true); // add attribute status = addAttribute( m_windSpeed ); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"ws\" attribute to OceanNode"); MFnNumericAttribute chopAttr; m_choppiness = chopAttr.create("chopiness", "chp", MFnNumericData::kDouble, 0.0, &status); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to create \"chopiness\" attribute"); chopAttr.setChannelBox(true); chopAttr.setMax(2.0); chopAttr.setMin(0.0); // add attribute status = addAttribute(m_choppiness); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"choppiness\" attribute to OceanNode"); // now the time inputs MFnNumericAttribute timeAttr; m_time = timeAttr.create("time", "t", MFnNumericData::kDouble, 0.0, &status); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to create \"t\" attribute"); // Add the attribute status = addAttribute(m_time); timeAttr.setHidden(true); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"t\" attribute to OceanNode"); // create the output attribute MFnTypedAttribute typeAttr; m_output = typeAttr.create("output", "out", MFnData::kMesh, &status); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to create \"output\" attribute"); typeAttr.setStorable(false); typeAttr.setHidden(true); status = addAttribute(m_output); CHECK_STATUS_AND_RETURN_MSTATUS_IF_FAIL(status, "Unable to add \"output\" attribute to OceanNode"); // this links the different elements together forcing a re-compute each time the values are changed attributeAffects(m_resolution, m_output); attributeAffects(m_amplitude,m_output); attributeAffects(m_windDirectionX, m_output); attributeAffects(m_windDirectionZ, m_output); attributeAffects(m_windSpeed, m_output); attributeAffects(m_choppiness, m_output); attributeAffects(m_time, m_output); // report all was good return MStatus::kSuccess; }
//---------------------------------------------------------------------------- MStatus BPT_InsertVtx::initialize() //---------------------------------------------------------------------------- { MFnEnumAttribute FnEnumAttr; MFnTypedAttribute FnTypedAttr; MFnNumericAttribute FnFloatAttr; MStatus status; IVinMesh = FnTypedAttr.create("inMesh","in",MFnData::kMesh); FnTypedAttr.setStorable(true); //FnTypedAttr.setCached(false); FnTypedAttr.setInternal(true); IVoutMesh = FnTypedAttr.create("outMesh","out",MFnData::kMesh); FnTypedAttr.setStorable(true); FnTypedAttr.setWritable(false); IVcount = FnFloatAttr.create("count","c",MFnNumericData::kLong); FnFloatAttr.setStorable(true); FnFloatAttr.setInternal(true); FnFloatAttr.setKeyable(true); FnFloatAttr.setMin(1); FnFloatAttr.setSoftMax(15); IVselEdgeIDs = FnTypedAttr.create("edgeIDs","eID",MFnData::kIntArray); FnTypedAttr.setStorable(true); FnTypedAttr.setHidden(true); FnTypedAttr.setConnectable(false); IVselVertIDs = FnTypedAttr.create("vertIDs","vID",MFnData::kIntArray); FnTypedAttr.setStorable(true); FnTypedAttr.setHidden(true); FnTypedAttr.setConnectable(false); IVoptions = FnTypedAttr.create("options","op",MFnData::kIntArray); FnTypedAttr.setStorable(true); FnTypedAttr.setHidden(true); FnTypedAttr.setConnectable(false); IVslide = FnFloatAttr.create("slide","sl",MFnNumericData::kDouble); FnFloatAttr.setStorable(true); FnFloatAttr.setInternal(true); // FnFloatAttr.setMin(0.0); // FnFloatAttr.setMax(1.0); FnFloatAttr.setKeyable(true); IVnormal = FnFloatAttr.create("alongNormal","an",MFnNumericData::kDouble); FnFloatAttr.setStorable(true); FnFloatAttr.setDefault(0.0); FnFloatAttr.setKeyable(true); IVslideRelative = FnFloatAttr.create("slideRelative","sr",MFnNumericData::kLong); FnFloatAttr.setStorable(true); FnFloatAttr.setMin(0.0); FnFloatAttr.setMax(1.0); FnFloatAttr.setKeyable(true); IVnormalRelative = FnFloatAttr.create("normalRelative","nr",MFnNumericData::kLong); FnFloatAttr.setStorable(true); FnFloatAttr.setMin(0.0); FnFloatAttr.setMax(1.0); FnFloatAttr.setKeyable(true); IVwhichSide = FnFloatAttr.create("side","si",MFnNumericData::kLong); FnFloatAttr.setStorable(true); FnFloatAttr.setMin(0.0); FnFloatAttr.setMax(1.0); FnFloatAttr.setKeyable(true); IVSlideLimited = FnFloatAttr.create("slideLimited","sll",MFnNumericData::kLong); FnFloatAttr.setStorable(true); FnFloatAttr.setMin(0.0); FnFloatAttr.setMax(1.0); FnFloatAttr.setKeyable(false); IVspin = FnFloatAttr.create("spin","sp",MFnNumericData::kLong); FnFloatAttr.setStorable(true); FnFloatAttr.setMin(0.0); FnFloatAttr.setKeyable(true); FnFloatAttr.setInternal(true); // Add attributes status = addAttribute(IVslideRelative); MCheckStatus(status, "AddAttrIVNode"); status = addAttribute(IVnormalRelative); MCheckStatus(status, "AddAttrIVNode"); status = addAttribute(IVwhichSide); MCheckStatus(status, "AddAttrIVNode"); status = addAttribute(IVnormal); MCheckStatus(status, "AddAttrIVNode"); status = addAttribute(IVslide); MCheckStatus(status, "AddAttrIVNode"); status = addAttribute(IVSlideLimited); MCheckStatus(status, "AddAttrIVNode"); status = addAttribute(IVoptions); MCheckStatus(status, "AddAttrIVNode"); status = addAttribute(IVspin); MCheckStatus(status, "AddAttrIVNode"); status = addAttribute(IVcount); MCheckStatus(status, "AddAttrIVNode"); status = addAttribute(IVselEdgeIDs); MCheckStatus(status, "AddAttrIVNode"); status = addAttribute(IVselVertIDs); MCheckStatus(status, "AddAttrIVNode"); status = addAttribute(IVoutMesh); MCheckStatus(status, "AddAttrIVNode"); status = addAttribute(IVinMesh); MCheckStatus(status, "AddAttrIVNode"); // Add attribute affects status = attributeAffects( IVspin, IVoutMesh ); MCheckStatus(status, "AddAttrAffectsIVNode"); status = attributeAffects( IVcount, IVoutMesh ); MCheckStatus(status, "AddAttrAffectsIVNode"); status = attributeAffects( IVinMesh, IVoutMesh ); MCheckStatus(status, "AddAttrAffectsIVNode"); status = attributeAffects( IVslide, IVoutMesh); MCheckStatus(status, "AddAttrAffectsIVNode"); status = attributeAffects( IVslideRelative, IVoutMesh); MCheckStatus(status, "AddAttrAffectsIVNode"); status = attributeAffects( IVnormalRelative, IVoutMesh); MCheckStatus(status, "AddAttrAffectsIVNode"); status = attributeAffects( IVwhichSide, IVoutMesh); MCheckStatus(status, "AddAttrAffectsIVNode"); status = attributeAffects( IVnormal, IVoutMesh); MCheckStatus(status, "AddAttrAffectsIVNode"); // Zuletzt die SoftTransformationAttribute hinzufuegen // Per Macro - dirty, aber funktioniert - wie machen die ALIAS Typen das ??? Die leiten auch stuendig von einer BaseNode ab, und da gehen dann keine Attribute flueten // Oder werden unbrauchbar so wie bei mir, so dass im Endeffekt suemtliche Attribute ein eindeutiges statisches Attribut haben muessen STE_ADD_ATTRIBUTES(IV) return status; }
// Create and Add Attributes // // 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 MayaPolySmooth::initialize() { MStatus stat; MFnCompoundAttribute cAttr; MFnEnumAttribute eAttr; MFnGenericAttribute gAttr; MFnLightDataAttribute lAttr; MFnMatrixAttribute mAttr; MFnMessageAttribute msgAttr; MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; MFnUnitAttribute uAttr; // MAYA_NODE_BUILDER:BEG [ATTRIBUTE CREATION] ========== // a_inputPolymesh : This is a description for this attribute a_inputPolymesh = tAttr.create("inputPolymesh", "ip", MFnData::kMesh, MObject::kNullObj, &stat); MCHECKERR( stat, "cannot create MayaPolySmooth::inputPolymesh" ); stat = tAttr.setReadable(true); MCHECKERR( stat, "cannot MayaPolySmooth::inputPolymesh.setReadable()" ); stat = tAttr.setWritable(true); MCHECKERR( stat, "cannot MayaPolySmooth::inputPolymesh.setWritable()" ); stat = tAttr.setHidden(true); MCHECKERR( stat, "cannot MayaPolySmooth::inputPolymesh.setHidden()" ); stat = addAttribute( a_inputPolymesh ); MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_inputPolymesh)" ); // a_output : This is a description for this attribute a_output = tAttr.create("output", "out", MFnData::kMesh, MObject::kNullObj, &stat); MCHECKERR( stat, "cannot create MayaPolySmooth::output" ); stat = tAttr.setReadable(true); MCHECKERR( stat, "cannot MayaPolySmooth::output.setReadable()" ); stat = tAttr.setWritable(false); MCHECKERR( stat, "cannot MayaPolySmooth::output.setWritable()" ); stat = tAttr.setHidden(true); MCHECKERR( stat, "cannot MayaPolySmooth::output.setHidden()" ); stat = addAttribute( a_output ); MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_output)" ); // a_subdivisionLevels : The number of recursive quad subdivisions to perform on each face. a_subdivisionLevels = nAttr.create("subdivisionLevels", "sl", MFnNumericData::kInt, 0.0, &stat); MCHECKERR( stat, "cannot create MayaPolySmooth::subdivisionLevels" ); stat = nAttr.setDefault(2); MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setDefault(2)" ); stat = nAttr.setMin(0); MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setMin(0)" ); stat = nAttr.setMax(10); MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setMax(10)" ); stat = nAttr.setSoftMax(4); MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setSoftMax(4)" ); stat = nAttr.setReadable(true); MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setReadable()" ); stat = nAttr.setWritable(true); MCHECKERR( stat, "cannot MayaPolySmooth::subdivisionLevels.setWritable()" ); stat = addAttribute( a_subdivisionLevels ); MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_subdivisionLevels)" ); // a_recommendedIsolation : The number of recursive quad subdivisions to perform on each face. a_recommendedIsolation = nAttr.create("recommendedIsolation", "ri", MFnNumericData::kInt, 0.0, &stat); MCHECKERR( stat, "cannot create MayaPolySmooth::recommendedIsolation" ); stat = nAttr.setDefault(2); MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setDefault(0)" ); stat = nAttr.setMin(0); MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setMin(0)" ); stat = nAttr.setMax(10); MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setSoftMax(10)" ); stat = nAttr.setReadable(true); MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setReadable()" ); stat = nAttr.setWritable(false); MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setWritable()" ); stat = nAttr.setHidden(false); MCHECKERR( stat, "cannot MayaPolySmooth::recommendedIsolation.setHidden()" ); stat = addAttribute( a_recommendedIsolation ); MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_recommendedIsolation)" ); // a_vertBoundaryMethod : Controls how boundary edges and vertices are interpolated. <ul> <li>Smooth, Edges: Renderman: InterpolateBoundaryEdgeOnly</li> <li>Smooth, Edges and Corners: Renderman: InterpolateBoundaryEdgeAndCorner</li> </ul> a_vertBoundaryMethod = eAttr.create("vertBoundaryMethod", "vbm", 0, &stat); MCHECKERR( stat, "cannot create MayaPolySmooth::vertBoundaryMethod" ); stat = eAttr.addField("Interpolate Edges", k_BoundaryMethod_InterpolateBoundaryEdgeOnly); MCHECKERR( stat, "cannot MayaPolySmooth::vertBoundaryMethod.addField(Interpolate Edges, k_BoundaryMethod_InterpolateBoundaryEdgeOnly)" ); stat = eAttr.addField("Interpolate Edges And Corners", k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner); MCHECKERR( stat, "cannot MayaPolySmooth::vertBoundaryMethod.addField(Interpolate Edges And Corners, k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner)" ); stat = eAttr.setDefault(k_BoundaryMethod_InterpolateBoundaryEdgeOnly); MCHECKERR( stat, "cannot MayaPolySmooth::vertBoundaryMethod.setDefault(k_BoundaryMethod_InterpolateBoundaryEdgeOnly)" ); stat = eAttr.setReadable(true); MCHECKERR( stat, "cannot MayaPolySmooth::vertBoundaryMethod.setReadable()" ); stat = eAttr.setWritable(true); MCHECKERR( stat, "cannot MayaPolySmooth::vertBoundaryMethod.setWritable()" ); stat = addAttribute( a_vertBoundaryMethod ); MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_vertBoundaryMethod)" ); // a_fvarBoundaryMethod : Controls how boundaries are treated for face-varying data (UVs and Vertex Colors). <ul> <li>Bi-linear (None): Renderman: InterpolateBoundaryNone</li> <li>Smooth, (Edge Only): Renderman: InterpolateBoundaryEdgeOnly</li> <li>Smooth, (Edges and Corners: Renderman: InterpolateBoundaryEdgeAndCorner</li> <li>Smooth, (ZBrush and Maya "Smooth Internal Only"): Renderman: InterpolateBoundaryAlwaysSharp</li> </ul> a_fvarBoundaryMethod = eAttr.create("fvarBoundaryMethod", "fvbm", 0, &stat); MCHECKERR( stat, "cannot create MayaPolySmooth::fvarBoundaryMethod" ); stat = eAttr.addField("Bi-linear (None)", k_BoundaryMethod_InterpolateBoundaryNone); MCHECKERR( stat, "cannot MayaPolySmooth::fvarBoundaryMethod.addField(Bi-linear (None), k_BoundaryMethod_InterpolateBoundaryNone)" ); stat = eAttr.addField("Smooth (Edge Only)", k_BoundaryMethod_InterpolateBoundaryEdgeOnly); MCHECKERR( stat, "cannot MayaPolySmooth::fvarBoundaryMethod.addField(Smooth (Edge Only), k_BoundaryMethod_InterpolateBoundaryEdgeOnly)" ); stat = eAttr.addField("Smooth (Edge and Corner)", k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner); MCHECKERR( stat, "cannot MayaPolySmooth::fvarBoundaryMethod.addField(Smooth (Edge and Corner), k_BoundaryMethod_InterpolateBoundaryEdgeAndCorner)" ); stat = eAttr.addField("Smooth (Always Sharp)", k_BoundaryMethod_InterpolateBoundaryAlwaysSharp); MCHECKERR( stat, "cannot MayaPolySmooth::fvarBoundaryMethod.addField(Smooth (Always Sharp), k_BoundaryMethod_InterpolateBoundaryAlwaysSharp)" ); stat = eAttr.setDefault(k_BoundaryMethod_InterpolateBoundaryNone); MCHECKERR( stat, "cannot MayaPolySmooth::fvarBoundaryMethod.setDefault(k_BoundaryMethod_InterpolateBoundaryNone)" ); stat = eAttr.setReadable(true); MCHECKERR( stat, "cannot MayaPolySmooth::fvarBoundaryMethod.setReadable()" ); stat = eAttr.setWritable(true); MCHECKERR( stat, "cannot MayaPolySmooth::fvarBoundaryMethod.setWritable()" ); stat = addAttribute( a_fvarBoundaryMethod ); MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_fvarBoundaryMethod)" ); // a_fvarPropagateCorners : a_fvarPropagateCorners = nAttr.create("fvarPropagateCorners", "fvpc", MFnNumericData::kBoolean, 0.0, &stat); MCHECKERR( stat, "cannot create MayaPolySmooth::fvarPropagateCorners" ); stat = nAttr.setDefault(false); MCHECKERR( stat, "cannot MayaPolySmooth::fvarPropagateCorners.setDefault(false)" ); stat = nAttr.setReadable(true); MCHECKERR( stat, "cannot MayaPolySmooth::fvarPropagateCorners.setReadable()" ); stat = nAttr.setWritable(true); MCHECKERR( stat, "cannot MayaPolySmooth::fvarPropagateCorners.setWritable()" ); stat = addAttribute( a_fvarPropagateCorners ); MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_fvarPropagateCorners)" ); // a_smoothTriangles : Apply a special subdivision rule be applied to all triangular faces that was empirically determined to make triangles subdivide more smoothly. a_smoothTriangles = nAttr.create("smoothTriangles", "stri", MFnNumericData::kBoolean, 0.0, &stat); MCHECKERR( stat, "cannot create MayaPolySmooth::smoothTriangles" ); stat = nAttr.setDefault(true); MCHECKERR( stat, "cannot MayaPolySmooth::smoothTriangles.setDefault(true)" ); stat = nAttr.setReadable(true); MCHECKERR( stat, "cannot MayaPolySmooth::smoothTriangles.setReadable()" ); stat = nAttr.setWritable(true); MCHECKERR( stat, "cannot MayaPolySmooth::smoothTriangles.setWritable()" ); stat = addAttribute( a_smoothTriangles ); MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_smoothTriangles)" ); // a_creaseMethod : Controls how boundary edges and vertices are interpolated. <ul> <li>Normal</li> <li>Chaikin: Improves the appearance of multiedge creases with varying weight</li> </ul> a_creaseMethod = eAttr.create("creaseMethod", "crm", 0, &stat); MCHECKERR( stat, "cannot create MayaPolySmooth::creaseMethod" ); stat = eAttr.addField("Normal", k_creaseMethod_normal); MCHECKERR( stat, "cannot MayaPolySmooth::creaseMethod.addField(Normal, k_creaseMethod_normal)" ); stat = eAttr.addField("Chaikin", k_creaseMethod_chaikin); MCHECKERR( stat, "cannot MayaPolySmooth::creaseMethod.addField(Chaikin, k_creaseMethod_chaikin)" ); stat = eAttr.setDefault(0); MCHECKERR( stat, "cannot MayaPolySmooth::creaseMethod.setDefault(0)" ); stat = eAttr.setReadable(true); MCHECKERR( stat, "cannot MayaPolySmooth::creaseMethod.setReadable()" ); stat = eAttr.setWritable(true); MCHECKERR( stat, "cannot MayaPolySmooth::creaseMethod.setWritable()" ); stat = addAttribute( a_creaseMethod ); MCHECKERR( stat, "cannot MayaPolySmooth::addAttribute(a_creaseMethod)" ); // MAYA_NODE_BUILDER:END [ATTRIBUTE CREATION] ========== // 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. // // MAYA_NODE_BUILDER:BEG [ATTRIBUTE DEPENDS] ========== stat = attributeAffects( a_creaseMethod, a_output ); MCHECKERR( stat, "cannot have attribute creaseMethod affect output" ); stat = attributeAffects( a_inputPolymesh, a_output ); MCHECKERR( stat, "cannot have attribute inputPolymesh affect output" ); stat = attributeAffects( a_subdivisionLevels, a_output ); MCHECKERR( stat, "cannot have attribute subdivisionLevels affect output" ); stat = attributeAffects( a_smoothTriangles, a_output ); MCHECKERR( stat, "cannot have attribute smoothTriangles affect output" ); stat = attributeAffects( a_fvarPropagateCorners, a_output ); MCHECKERR( stat, "cannot have attribute fvarPropagateCorners affect output" ); stat = attributeAffects( a_vertBoundaryMethod, a_output ); MCHECKERR( stat, "cannot have attribute vertBoundaryMethod affect output" ); stat = attributeAffects( a_fvarBoundaryMethod, a_output ); MCHECKERR( stat, "cannot have attribute fvarBoundaryMethod affect output" ); stat = attributeAffects( a_creaseMethod, a_recommendedIsolation ); MCHECKERR( stat, "cannot have attribute creaseMethod affect .si output" ); stat = attributeAffects( a_inputPolymesh, a_recommendedIsolation ); MCHECKERR( stat, "cannot have attribute inputPolymesh affect .si output" ); stat = attributeAffects( a_subdivisionLevels, a_recommendedIsolation ); MCHECKERR( stat, "cannot have attribute subdivisionLevels affect .si output" ); stat = attributeAffects( a_smoothTriangles, a_recommendedIsolation ); MCHECKERR( stat, "cannot have attribute smoothTriangles affect .si output" ); stat = attributeAffects( a_fvarPropagateCorners, a_recommendedIsolation ); MCHECKERR( stat, "cannot have attribute fvarPropagateCorners affect .si output" ); stat = attributeAffects( a_vertBoundaryMethod, a_recommendedIsolation ); MCHECKERR( stat, "cannot have attribute vertBoundaryMethod affect .si output" ); stat = attributeAffects( a_fvarBoundaryMethod, a_recommendedIsolation ); MCHECKERR( stat, "cannot have attribute fvarBoundaryMethod affect .si output" ); // MAYA_NODE_BUILDER:END [ATTRIBUTE DEPENDS] ========== return MS::kSuccess; }
MStatus Trimmer::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 // { // This sample creates a single input float attribute and a single // output float attribute. // MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MStatus stat; maxLength = nAttr.create( "percentLength", "l", MFnNumericData::kFloat, 1.0f, &stat ); if ( !stat ) return stat; nAttr.setMin( 0 ); nAttr.setMax( 1.0f ); nAttr.setWritable( true ); nAttr.setStorable( true ); inputData = tAttr.create( "input", "in", GrowerData::id, MObject::kNullObj, &stat ); if ( !stat ) return stat; tAttr.setWritable( true ); tAttr.setReadable( true ); tAttr.setStorable(false); tAttr.setHidden( true ); outputData = tAttr.create( "output", "out", GrowerData::id, MObject::kNullObj, &stat ); if ( !stat ) return stat; tAttr.setWritable( false ); tAttr.setReadable( true ); tAttr.setStorable(false); // Add the attributes we have created to the node // stat = addAttribute( maxLength ); if (!stat) { stat.perror("addAttribute"); return stat; } stat = addAttribute( inputData ); if (!stat) { stat.perror("addAttribute"); return stat; } stat = addAttribute( outputData ); if (!stat) { stat.perror("addAttribute"); return stat; } // 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( maxLength, outputData ); if (!stat) { stat.perror("attributeAffects"); return stat; } stat = attributeAffects( inputData, outputData ); if (!stat) { stat.perror("attributeAffects"); return stat; } return MS::kSuccess; }
MStatus puttyNode::initialize() { MStatus status; MFnNumericAttribute nAttr; MFnEnumAttribute eAttr; MFnTypedAttribute tAttr; MFnMatrixAttribute mAttr; // the script aScript = tAttr.create( "script", "scr", MFnData::kString); tAttr.setStorable(true); tAttr.setKeyable(false); SYS_ERROR_CHECK( addAttribute( aScript ), "adding aScript" ); aCmdBaseName = tAttr.create( "cmdBaseName", "cbn", MFnData::kString); tAttr.setStorable(true); tAttr.setKeyable(false); tAttr.setHidden(true); SYS_ERROR_CHECK( addAttribute( aCmdBaseName ), "adding aCmdBaseName" ); // refresh aSource = nAttr.create( "source", "src", MFnNumericData::kBoolean, 0 ); nAttr.setHidden(true); SYS_ERROR_CHECK( addAttribute( aSource ), "adding aSource" ); // it is important that script sourced is initialised false and not storable // so this way the function gets sourced on maya startup aScriptSourced = nAttr.create( "scriptSourced", "ssrc", MFnNumericData::kBoolean, 0 ); nAttr.setStorable(false); nAttr.setHidden(true); SYS_ERROR_CHECK( addAttribute( aScriptSourced ), "adding aScriptSourced" ); aNodeReady = nAttr.create( "nodeReady", "nr", MFnNumericData::kBoolean, 0 ); nAttr.setHidden(true); SYS_ERROR_CHECK( addAttribute( aNodeReady ), "adding aNodeReady" ); aDynDirty = nAttr.create( "dynDirty", "dd", MFnNumericData::kBoolean, 0 ); nAttr.setHidden(true); SYS_ERROR_CHECK( addAttribute( aDynDirty ), "adding aDynDirty" ); // space aDefSpace = eAttr.create("deformerSpace", "dsp", MSD_SPACE_OBJECT, &status); eAttr.addField("object (default)", MSD_SPACE_OBJECT); eAttr.addField("world (automatic conversion)", MSD_SPACE_WORLD); eAttr.setKeyable(false); eAttr.setStorable(true); SYS_ERROR_CHECK( addAttribute( aDefSpace ), "adding aDefSpace" ); // envelope aDefEnvelope = eAttr.create("deformerEnvelope", "de", MSD_ENVELOPE_AUTO, &status); eAttr.addField("auto", MSD_ENVELOPE_AUTO); eAttr.addField("user", MSD_ENVELOPE_USER); eAttr.setKeyable(false); eAttr.setStorable(true); SYS_ERROR_CHECK( addAttribute( aDefEnvelope ), "adding aDefEnvelope" ); // weights aDefWeights = eAttr.create("deformerWeights", "dw", MSD_WEIGHTS_AUTO, &status); eAttr.addField("auto", MSD_WEIGHTS_AUTO); eAttr.addField("user", MSD_WEIGHTS_USER); eAttr.setKeyable(false); eAttr.setStorable(true); SYS_ERROR_CHECK( addAttribute( aDefWeights ), "adding aDefWeights" ); ///////////////////////////////////////////////////////////////////////////// // current values aCurrPosition = tAttr.create( "currentPosition", "cpos", MFnData::kVectorArray); tAttr.setStorable(false); tAttr.setKeyable(false); tAttr.setConnectable(false); tAttr.setWritable(false); SYS_ERROR_CHECK( addAttribute( aCurrPosition ), "adding aCurrPos" ); aCurrWeight = tAttr.create( "currentWeight", "cwgh", MFnData::kDoubleArray); tAttr.setStorable(false); tAttr.setKeyable(false); tAttr.setConnectable(false); tAttr.setWritable(false); SYS_ERROR_CHECK( addAttribute( aCurrWeight ), "adding aCurrWeight" ); aCurrMultiIndex = nAttr.create("currentMultiIndex","cmi",MFnNumericData::kInt); nAttr.setStorable(false); nAttr.setKeyable(false); nAttr.setConnectable(false); nAttr.setWritable(false); SYS_ERROR_CHECK( addAttribute( aCurrMultiIndex ), "adding aCurrMultiIndex" ); aCurrWorldMatrix = mAttr.create("currentWorldMatrix","cwm"); mAttr.setStorable(false); mAttr.setKeyable(false); mAttr.setConnectable(false); mAttr.setWritable(false); SYS_ERROR_CHECK( addAttribute( aCurrWorldMatrix ), "adding aCurrObjectName" ); /* aCurrGeometryName= tAttr.create( "currentGeometryName", "con", MFnData::kString); tAttr.setStorable(false); tAttr.setKeyable(false); tAttr.setConnectable(false); tAttr.setWritable(false); SYS_ERROR_CHECK( addAttribute( aCurrGeometryName ), "adding aCurrObjectName" ); */ aCurrGeometryType= tAttr.create( "currentGeometryType", "cot", MFnData::kString); tAttr.setStorable(false); tAttr.setKeyable(false); tAttr.setConnectable(false); tAttr.setWritable(false); SYS_ERROR_CHECK( addAttribute( aCurrGeometryType ), "adding aCurrGeometryType" ); ///////////////////////////////////////////////////////////////////////////// // affects attributeAffects( aScript ,aNodeReady); attributeAffects( aSource, aNodeReady ); attributeAffects( aScriptSourced, aNodeReady ); attributeAffects( aScript,aScriptSourced); attributeAffects( aSource,aScriptSourced); attributeAffects( aScriptSourced, outputGeom ); attributeAffects( aDynDirty,outputGeom ); attributeAffects( aNodeReady,outputGeom ); attributeAffects( aScript ,outputGeom); attributeAffects( aCmdBaseName ,outputGeom); attributeAffects( aSource ,outputGeom ); attributeAffects( aDefSpace, outputGeom ); attributeAffects( aDefWeights,outputGeom); attributeAffects( aDefEnvelope,outputGeom ); return MS::kSuccess; }
//initialize MStatus Ocio_log_convert::initialize() { //MFnSets MFnEnumAttribute eAttr; MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; //a_verbose a_verbose = eAttr.create("verbose", "verbose", 1); eAttr.addField("no verbose", 0); eAttr.addField("verbose", 1); addAttribute(a_verbose); //a_input_color a_input_color = nAttr.createColor("input_color", "input_color"); nAttr.setUsedAsColor(true); nAttr.setStorable(true); addAttribute(a_input_color); //a_output_color a_output_color = nAttr.createColor("output_color", "output_color"); nAttr.setUsedAsColor(true); nAttr.setStorable(false); addAttribute(a_output_color); //a_env_or_file a_env_or_file = eAttr.create("env_or_file", "env_or_file", 0); eAttr.addField("OCIO Environment Variable", 0); eAttr.addField("Custom Path", 1); eAttr.setStorable(true); addAttribute(a_env_or_file); //a_last_env_or_file a_last_env_or_file = nAttr.create("last_env_or_file", "last_env_or_file", MFnNumericData::kInt, 0); nAttr.setHidden(true); nAttr.setStorable(true); addAttribute(a_last_env_or_file); //a_config_file_path a_config_file_path = tAttr.create("config_file_path", "config_file_path", MFnData::kString); tAttr.setUsedAsFilename(true); tAttr.setStorable(true); addAttribute(a_config_file_path); //a_last_config_file_path a_last_config_file_path = tAttr.create("last_config_file_path", "last_config_file_path", MFnData::kString); tAttr.setHidden(true); tAttr.setStorable(true); addAttribute(a_last_config_file_path); //a_operation a_operation = eAttr.create("operation", "operation", 0); eAttr.addField("Log to Lin", 0); eAttr.addField("Lin to Log", 1); addAttribute(a_operation); //a_last_operation a_last_operation = nAttr.create("last_operation", "last_operation", MFnNumericData::kInt, 0); nAttr.setHidden(true); nAttr.setStorable(true); addAttribute(a_last_operation); //Attribute affects attributeAffects(a_input_color, a_output_color); attributeAffects(a_env_or_file, a_output_color); attributeAffects(a_config_file_path, a_output_color); attributeAffects(a_operation, a_output_color); return MStatus::kSuccess; }
MStatus rigidBodyNode::initialize() { MStatus status; MFnMessageAttribute fnMsgAttr; MFnNumericAttribute fnNumericAttr; MFnMatrixAttribute fnMatrixAttr; MFnTypedAttribute typedAttr; ia_collisionShape = fnMsgAttr.create("inCollisionShape", "incs", &status); MCHECKSTATUS(status, "creating inCollisionShape attribute") status = addAttribute(ia_collisionShape); MCHECKSTATUS(status, "adding inCollisionShape attribute") ia_solver = fnMsgAttr.create("solver", "solv", &status); MCHECKSTATUS(status, "creating solver attribute") status = addAttribute(ia_solver); MCHECKSTATUS(status, "adding solver attribute") ia_mass = fnNumericAttr.create("mass", "ma", MFnNumericData::kDouble, 1.0, &status); MCHECKSTATUS(status, "creating mass attribute") fnNumericAttr.setKeyable(true); status = addAttribute(ia_mass); MCHECKSTATUS(status, "adding mass attribute") ia_restitution = fnNumericAttr.create("restitution", "rst", MFnNumericData::kDouble, 0.1, &status); MCHECKSTATUS(status, "creating restitution attribute") fnNumericAttr.setKeyable(true); status = addAttribute(ia_restitution); MCHECKSTATUS(status, "adding restitution attribute") ia_friction = fnNumericAttr.create("friction", "fc", MFnNumericData::kDouble, 0.5, &status); MCHECKSTATUS(status, "creating friction attribute") fnNumericAttr.setKeyable(true); status = addAttribute(ia_friction); MCHECKSTATUS(status, "adding friction attribute") ia_linearDamping = fnNumericAttr.create("linearDamping", "ld", MFnNumericData::kDouble, 0.3, &status); MCHECKSTATUS(status, "creating linearDamping attribute") fnNumericAttr.setKeyable(true); status = addAttribute(ia_linearDamping); MCHECKSTATUS(status, "adding linearDamping attribute") ia_angularDamping = fnNumericAttr.create("angularDamping", "ad", MFnNumericData::kDouble, 0.3, &status); MCHECKSTATUS(status, "creating angularDamping attribute") fnNumericAttr.setKeyable(true); status = addAttribute(ia_angularDamping); MCHECKSTATUS(status, "adding angularDamping attribute") ia_initialPosition = fnNumericAttr.createPoint("initialPosition", "inpo", &status); MCHECKSTATUS(status, "creating initialPosition attribute") status = addAttribute(ia_initialPosition); MCHECKSTATUS(status, "adding initialPosition attribute") ia_initialRotation = fnNumericAttr.createPoint("initialRotation", "inro", &status); MCHECKSTATUS(status, "creating initialRotation attribute") status = addAttribute(ia_initialRotation); MCHECKSTATUS(status, "adding initialRotation attribute") ia_initialVelocity = fnNumericAttr.createPoint("initialVelocity", "inve", &status); MCHECKSTATUS(status, "creating initialVelocity attribute") status = addAttribute(ia_initialVelocity); MCHECKSTATUS(status, "adding initialVelocity attribute") ia_initialSpin = fnNumericAttr.createPoint("initialSpin", "insp", &status); MCHECKSTATUS(status, "creating initialSpin attribute") status = addAttribute(ia_initialSpin); MCHECKSTATUS(status, "adding initialSpin attribute") ia_externalForce = fnNumericAttr.createPoint("externalForce", "exfo", &status); MCHECKSTATUS(status, "creating externalForce attribute") status = addAttribute(ia_externalForce); MCHECKSTATUS(status, "adding externalForce attribute") ia_externalTorque = fnNumericAttr.createPoint("externalTorque", "exto", &status); MCHECKSTATUS(status, "creating externalTorque attribute") status = addAttribute(ia_externalTorque); MCHECKSTATUS(status, "adding externalTorque attribute") ca_rigidBody = fnNumericAttr.create("ca_rigidBody", "carb", MFnNumericData::kBoolean, 0, &status); MCHECKSTATUS(status, "creating ca_rigidBody attribute") fnNumericAttr.setConnectable(false); fnNumericAttr.setHidden(true); fnNumericAttr.setStorable(false); fnNumericAttr.setKeyable(false); status = addAttribute(ca_rigidBody); MCHECKSTATUS(status, "adding ca_rigidBody attribute") ca_rigidBodyParam = fnNumericAttr.create("ca_rigidBodyParam", "carbp", MFnNumericData::kBoolean, 0, &status); MCHECKSTATUS(status, "creating ca_rigidBodyParam attribute") fnNumericAttr.setConnectable(false); fnNumericAttr.setHidden(true); fnNumericAttr.setStorable(false); fnNumericAttr.setKeyable(false); status = addAttribute(ca_rigidBodyParam); MCHECKSTATUS(status, "adding ca_rigidBodyParam attribute") ca_solver = fnNumericAttr.create("ca_solver", "caso", MFnNumericData::kBoolean, 0, &status); MCHECKSTATUS(status, "creating ca_solver attribute") fnNumericAttr.setConnectable(false); fnNumericAttr.setHidden(true); fnNumericAttr.setStorable(false); fnNumericAttr.setKeyable(false); status = addAttribute(ca_solver); MCHECKSTATUS(status, "adding ca_solver attribute") oa_contactCount = fnNumericAttr.create("contactCount", "contactCount", MFnNumericData::kInt, 0, &status); MCHECKSTATUS(status, "creating oa_contactCount attribute") fnNumericAttr.setConnectable(true); fnNumericAttr.setHidden(true); fnNumericAttr.setStorable(false); fnNumericAttr.setKeyable(false); status = addAttribute(oa_contactCount); MCHECKSTATUS(status, "adding oa_contactCount attribute"); MFnStringArrayData stringArrayData; oa_contactName = typedAttr.create("contactName", "contactName", MFnData::kStringArray, stringArrayData.create(), &status); MCHECKSTATUS(status, "creating oa_contactName attribute") typedAttr.setHidden(true); status = addAttribute(oa_contactName); MCHECKSTATUS(status, "adding oa_contactName attribute"); oa_contactPosition = typedAttr.create("contactPosition", "contactPosition", MFnVectorArrayData::kVectorArray, &status); MCHECKSTATUS(status, "creating oa_contactPosition attribute") typedAttr.setHidden(true); status = addAttribute(oa_contactPosition); MCHECKSTATUS(status, "adding oa_contactPosition attribute"); status = attributeAffects(ia_mass, ca_rigidBody); MCHECKSTATUS(status, "adding attributeAffects(ia_mass, ca_rigidBodyParam)") status = attributeAffects(ia_collisionShape, ca_rigidBody); MCHECKSTATUS(status, "adding attributeAffects(ia_collisionShape, ca_rigidBody)") status = attributeAffects(ia_collisionShape, ca_rigidBodyParam); MCHECKSTATUS(status, "adding attributeAffects(ia_collisionShape, ca_rigidBodyParam)") status = attributeAffects(ia_mass, ca_rigidBodyParam); MCHECKSTATUS(status, "adding attributeAffects(ia_mass, ca_rigidBodyParam)") status = attributeAffects(ia_restitution, ca_rigidBodyParam); MCHECKSTATUS(status, "adding attributeAffects(ia_restitution, ca_rigidBodyParam)") status = attributeAffects(ia_friction, ca_rigidBodyParam); MCHECKSTATUS(status, "adding attributeAffects(ia_friction, ca_rigidBodyParam)") status = attributeAffects(ia_linearDamping, ca_rigidBodyParam); MCHECKSTATUS(status, "adding attributeAffects(ia_linearDamping, ca_rigidBodyParam)") status = attributeAffects(ia_angularDamping, ca_rigidBodyParam); MCHECKSTATUS(status, "adding attributeAffects(ia_angularDamping, ca_rigidBodyParam)") status = attributeAffects(ia_initialPosition, ca_rigidBodyParam); MCHECKSTATUS(status, "adding attributeAffects(ia_initialPosition, ca_rigidBodyParam)") status = attributeAffects(ia_solver, ca_solver); MCHECKSTATUS(status, "adding attributeAffects(ia_solver, ca_solver)") return MS::kSuccess; }
MStatus VmIslandNode::initialize() { fprintf( stderr, "VmIslandNode::initialize()...\n" ); MStatus status; //Seed attribute { MFnNumericAttribute numericAttrFn; ia_seed = numericAttrFn.create( "seed", "sD", MFnNumericData::kLong, 0, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setMin( 0 ); numericAttrFn.setMax( 1000 ); numericAttrFn.setDefault ( 0 ); status = addAttribute( ia_seed ); CHECK_MSTATUS( status ); } //Roughness attribute { MFnNumericAttribute numericAttrFn; ia_roughness = numericAttrFn.create( "roughness", "rG", MFnNumericData::kFloat, 0, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setMin( 0 ); numericAttrFn.setMax( 1 ); numericAttrFn.setDefault ( 0.75 ); status = addAttribute( ia_roughness ); CHECK_MSTATUS( status ); } //Plane Height attribute { MFnNumericAttribute numericAttrFn; ia_planeHeight = numericAttrFn.create( "planeHeight", "pH", MFnNumericData::kLong, 0, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setMin( 0 ); numericAttrFn.setMax( 2000 ); numericAttrFn.setDefault ( 5 ); status = addAttribute( ia_planeHeight ); CHECK_MSTATUS( status ); } //Plane smoothing attribute { MFnNumericAttribute numericAttrFn; ia_smooth = numericAttrFn.create( "smoothingStrength", "sS", MFnNumericData::kLong, 0, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setMin( 0 ); numericAttrFn.setMax( 6 ); numericAttrFn.setDefault ( 1 ); status = addAttribute( ia_smooth ); CHECK_MSTATUS( status ); } //Plane resolution attribute { MFnNumericAttribute numericAttrFn; ia_resolution = numericAttrFn.create( "mayaResolution", "mR", MFnNumericData::kLong, 0, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setMin( 1 ); numericAttrFn.setMax( 10 ); numericAttrFn.setDefault ( 1 ); status = addAttribute( ia_resolution ); CHECK_MSTATUS( status ); } //Renderman resolution attribute { MFnNumericAttribute numericAttrFn; ia_rmanResolution = numericAttrFn.create( "rendermanResolution", "rR", MFnNumericData::kLong, 0, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setMin( 1 ); numericAttrFn.setMax( 10 ); numericAttrFn.setDefault ( 6 ); status = addAttribute( ia_rmanResolution ); CHECK_MSTATUS( status ); } //Plane size attribute { MFnNumericAttribute numericAttrFn; ia_planeSize = numericAttrFn.create( "planeSizeScale", "pS", MFnNumericData::kLong, 0, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setMin( 1 ); numericAttrFn.setMax( 200 ); numericAttrFn.setDefault ( 20 ); status = addAttribute( ia_planeSize ); CHECK_MSTATUS( status ); } //Plane size attribute { MFnNumericAttribute numericAttrFn; ia_gridSize = numericAttrFn.create( "gridSize", "gS", MFnNumericData::kLong, 0, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setMin( 1 ); numericAttrFn.setMax( 10 ); numericAttrFn.setDefault ( 1 ); status = addAttribute( ia_gridSize ); CHECK_MSTATUS( status ); } //Grass multiplier - Affects how many instances are spawned { MFnNumericAttribute numericAttrFn; ia_grassMultiplier = numericAttrFn.create( "grassInstanceMultiplier", "gM", MFnNumericData::kLong, 0, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setMin( 1 ); numericAttrFn.setMax( 100 ); numericAttrFn.setDefault ( 1 ); status = addAttribute( ia_grassMultiplier ); CHECK_MSTATUS( status ); } //Grass multiplier - Affects how many instances are spawned { MFnNumericAttribute numericAttrFn; ia_baseWidth = numericAttrFn.create( "grassBaseWidth", "bW", MFnNumericData::kFloat, 0, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setMin( 0.01f ); numericAttrFn.setMax( 2.0f ); numericAttrFn.setDefault ( 0.6f ); status = addAttribute( ia_baseWidth ); CHECK_MSTATUS( status ); } //Grass segment length - Length of segment pieces { MFnNumericAttribute numericAttrFn; ia_grassSegmentLength = numericAttrFn.create( "grassSegmentLength", "gSL", MFnNumericData::kFloat, 0, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setMin( 0.001f ); numericAttrFn.setMax( 10.0f ); numericAttrFn.setDefault ( 1.0f ); status = addAttribute( ia_grassSegmentLength ); CHECK_MSTATUS( status ); } //Number of segments per piece of grass { MFnNumericAttribute numericAttrFn; ia_grassNumSegments = numericAttrFn.create( "numberOfGrassSegments", "nGS", MFnNumericData::kLong, 0, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setMin( 3 ); numericAttrFn.setMax( 20 ); numericAttrFn.setDefault ( 5 ); status = addAttribute( ia_grassNumSegments ); CHECK_MSTATUS( status ); } //Initial grass bend direction { MFnNumericAttribute numericAttrFn; ia_windDirection = numericAttrFn.createPoint( "windDirection", "wDir"); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setDefault(1.0f, 0.0f, 1.0f); status = addAttribute( ia_windDirection ); CHECK_MSTATUS( status ); } //Grass bend factor { MFnNumericAttribute numericAttrFn; ia_grassBendAmount = numericAttrFn.create( "grassBendFactor", "gBF", MFnNumericData::kFloat, 0, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setMin( 0.0f ); numericAttrFn.setMax( 1.0f ); numericAttrFn.setDefault ( 0.0f ); status = addAttribute( ia_grassBendAmount ); CHECK_MSTATUS( status ); } //Wind strength { MFnNumericAttribute numericAttrFn; ia_windSpread = numericAttrFn.create( "windSpread", "wS", MFnNumericData::kFloat, 0, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setMin( 0.01f ); numericAttrFn.setMax( 10.0f ); numericAttrFn.setDefault ( 5.0f ); status = addAttribute( ia_windSpread ); CHECK_MSTATUS( status ); } //Initial grass bend direction { MFnNumericAttribute numericAttrFn; ia_grassBaseColour1 = numericAttrFn.createColor( "grassBaseColour1", "bCol1"); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setDefault(0.0f,0.251f,0.167f); status = addAttribute( ia_grassBaseColour1 ); CHECK_MSTATUS( status ); } //Initial grass bend direction { MFnNumericAttribute numericAttrFn; ia_grassTipColour1 = numericAttrFn.createColor( "grassTipColour1", "tCol1"); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setDefault(0.395f,0.551f,0.257f); status = addAttribute( ia_grassTipColour1 ); CHECK_MSTATUS( status ); } //Initial grass bend direction { MFnNumericAttribute numericAttrFn; ia_grassBaseColour2 = numericAttrFn.createColor( "grassBaseColour2", "bCol2"); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setDefault(0.275f,0.243f,0.043f); status = addAttribute( ia_grassBaseColour2 ); CHECK_MSTATUS( status ); } //Initial grass bend direction { MFnNumericAttribute numericAttrFn; ia_grassTipColour2 = numericAttrFn.createColor( "grassTipColour2", "tCol2"); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( true ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setDefault(0.611f,0.587f,0.257f); status = addAttribute( ia_grassTipColour2 ); CHECK_MSTATUS( status ); } //Clock attribute. Passes maya frame counter into node { MFnNumericAttribute numericAttrFn; ia_clock = numericAttrFn.create( "clock", "clk", MFnNumericData::kLong, false, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( false ); numericAttrFn.setKeyable( true ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( false ); numericAttrFn.setMin( 0 ); numericAttrFn.setDefault( 0 ); status = addAttribute( ia_clock ); CHECK_MSTATUS( status ); } // "drawStyle" // // How we should draw in Maya. // // We will use this value in our Maya plug-in, but we // will NOT use it in Renderman. Note elsewhere that // this value will not be sent to Renderman, nor will // it have any effect on RIB generation. // // We think of this as an input attribute - hence the // prefix "ia_" for "input attribute". { MFnEnumAttribute enumAttrFn; ia_drawStyle = enumAttrFn.create( "drawStyle", "ds", 1, & status ); CHECK_MSTATUS( status ); enumAttrFn.setReadable( true ); enumAttrFn.setWritable( true ); enumAttrFn.setStorable( true ); enumAttrFn.setKeyable( true ); enumAttrFn.setConnectable( true ); enumAttrFn.setHidden( false ); enumAttrFn.addField( "Bounds", 0 ); enumAttrFn.addField( "Sub bounds", 1 ); enumAttrFn.addField( "Geometry", 2 ); enumAttrFn.addField( "Terrain slope normals", 3 ); enumAttrFn.addField( "Point instances", 4 ); enumAttrFn.addField( "Wind Velocity", 5 ); enumAttrFn.addField( "All", 6 ); enumAttrFn.setDefault(3); status = addAttribute( ia_drawStyle ); CHECK_MSTATUS( status ); } // "update" // // A 'dummy' attribute, and a powerful one. Although // the value of this attribute is actually meaningless, // when we ask for it we trigger an important computation // processs. // // We think of this as an input attribute - hence the // prefix "oa_" for "computation attribute". This signifies // that we don't really care about it's final value, but // that we know it's going to compute a lot of stuff. { MFnNumericAttribute numericAttrFn; oa_update = numericAttrFn.create( "update", "upd", MFnNumericData::kBoolean, false, & status ); CHECK_MSTATUS( status ); numericAttrFn.setReadable( true ); numericAttrFn.setWritable( true ); numericAttrFn.setStorable( false ); numericAttrFn.setKeyable( false ); numericAttrFn.setConnectable( true ); numericAttrFn.setHidden( true ); status = addAttribute( oa_update ); CHECK_MSTATUS( status ); } // "rib" // // A string which contains all the attributes, and that // we need to have (and indeed will see again) on the // Renderman side of things. // // We think of this as an output attribute - hence the // prefix "oa_" for "output attribute". The value // computed for this attribute (the string) is important, // an is used by whatever is asking for it. { MFnTypedAttribute typedAttrFn; oa_rib = typedAttrFn.create( "rib", "rb", MFnData::kString, MObject::kNullObj, & status ); CHECK_MSTATUS( status ); typedAttrFn.setReadable( true ); typedAttrFn.setWritable( true ); typedAttrFn.setStorable( false ); typedAttrFn.setKeyable( false ); typedAttrFn.setConnectable( true ); typedAttrFn.setHidden( true ); status = addAttribute( oa_rib ); CHECK_MSTATUS( status ); } // This section tells Maya what attribute effects // which attribute. When input attributes change, // make the attributes they effect "dirty". That // means that, when Maya asks for a dirty attribute, // it will need to be computed and "cleaned". // // Changing an effecting "input" attribute does not // trigger a computation of it's effected "output" // attribute. It just tells Maya that - if the effected // attribute is ever asked for, it will have to call // the compute method to calculate it. // // For complex relationships between attributes, // an attributeEffects() call must exist for each // relationship. If A effects B, and B effects C, // then we will need to make two attributeEffects() // calls - one for A effecting B and one for B // effecting C. Maya will not figure out that, if A // effects B, and B effets C, then A must effect C. // // Below we see that most "input" attributes effect // both our internal update and the rib generation // the same way in each case. But it's not always // exactly the same like this. // // Notice also that ia_drawStyle does not effect // any of the attributes. It's something that's just // used in the draw method. attributeAffects( ia_seed, oa_update ); attributeAffects( ia_seed, oa_rib ); attributeAffects( ia_roughness, oa_update ); attributeAffects( ia_roughness, oa_rib ); attributeAffects( ia_smooth, oa_update ); attributeAffects( ia_smooth, oa_rib ); attributeAffects( ia_planeHeight, oa_update ); attributeAffects( ia_planeHeight, oa_rib ); attributeAffects( ia_resolution, oa_update ); attributeAffects( ia_rmanResolution, oa_rib ); attributeAffects( ia_planeSize, oa_update ); attributeAffects( ia_planeSize, oa_rib ); attributeAffects( ia_gridSize, oa_update ); attributeAffects( ia_gridSize, oa_rib ); attributeAffects( ia_grassMultiplier, oa_update ); attributeAffects( ia_grassMultiplier, oa_rib ); attributeAffects( ia_baseWidth, oa_update ); attributeAffects( ia_baseWidth, oa_rib ); attributeAffects( ia_grassSegmentLength, oa_update ); attributeAffects( ia_grassSegmentLength, oa_rib ); attributeAffects( ia_grassNumSegments, oa_update ); attributeAffects( ia_grassNumSegments, oa_rib ); attributeAffects( ia_grassBendAmount, oa_update ); attributeAffects( ia_grassBendAmount, oa_rib ); attributeAffects( ia_windDirection, oa_update ); attributeAffects( ia_windDirection, oa_rib ); attributeAffects( ia_windSpread, oa_update ); attributeAffects( ia_windSpread, oa_rib ); attributeAffects( ia_clock, oa_update ); attributeAffects( ia_clock, oa_rib ); attributeAffects( ia_grassBaseColour1, oa_update); attributeAffects( ia_grassBaseColour1, oa_rib); attributeAffects( ia_grassTipColour1, oa_update); attributeAffects( ia_grassTipColour1, oa_rib); attributeAffects( ia_grassBaseColour2, oa_update); attributeAffects( ia_grassBaseColour2, oa_rib); attributeAffects( ia_grassTipColour2, oa_update); attributeAffects( ia_grassTipColour2, oa_rib); fprintf( stderr, "VmIslandNode::initialize() done\n" ); 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; }