MStatus curvedArrows::initialize() { MFnNumericAttribute nAttr; aTheColor = nAttr.createColor( "theColor", "tc" ); nAttr.setDefault( 0.1, 0.1, 0.8 ); nAttr.setKeyable( true ); nAttr.setReadable( true ); nAttr.setWritable( true ); nAttr.setStorable( true ); aTransparency = nAttr.create( "transparency", "t", MFnNumericData::kFloat ); nAttr.setDefault( 0.5 ); nAttr.setKeyable( true ); nAttr.setReadable( true ); nAttr.setWritable( true ); nAttr.setStorable( true ); aEnableTransparencySort = nAttr.create( "transparencySort", "ts", MFnNumericData::kBoolean ); nAttr.setDefault( true ); nAttr.setKeyable( true ); nAttr.setReadable( true ); nAttr.setWritable( true ); nAttr.setStorable( true ); aEnableDrawLast = nAttr.create( "drawLast", "dL", MFnNumericData::kBoolean ); nAttr.setDefault( false ); nAttr.setKeyable( true ); nAttr.setReadable( true ); nAttr.setWritable( true ); nAttr.setStorable( true ); MStatus stat1, stat2, stat3, stat4; stat1 = addAttribute( aTheColor ); stat2 = addAttribute( aEnableTransparencySort ); stat3 = addAttribute( aEnableDrawLast ); stat4 = addAttribute( aTransparency ); if ( !stat1 || !stat2 || !stat3 || !stat4) { stat1.perror("addAttribute"); stat2.perror("addAttribute"); stat3.perror("addAttribute"); stat4.perror("addAttribute"); return MS::kFailure; } return MS::kSuccess; }
// // DESCRIPTION: /////////////////////////////////////////////////////// MStatus DispNode::initialize() { MFnNumericAttribute nAttr; // Inputs aColor = nAttr.createColor( "color", "c" ); CHECK_MSTATUS(nAttr.setKeyable(true)); CHECK_MSTATUS(nAttr.setStorable(true)); CHECK_MSTATUS(nAttr.setDefault(1.0f, 1.0f, 1.0f)); aInputValue = nAttr.create( "factor", "f", MFnNumericData::kFloat); CHECK_MSTATUS(nAttr.setKeyable(true)); CHECK_MSTATUS(nAttr.setStorable(true)); CHECK_MSTATUS(nAttr.setDefault(1.0f)); // Outputs aOutColor = nAttr.createColor( "outColor", "oc" ); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(false)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); aOutTransparency = nAttr.createColor( "outTransparency", "ot" ); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(false)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); aOutDisplacement = nAttr.create( "displacement", "od", MFnNumericData::kFloat); CHECK_MSTATUS(nAttr.setStorable(false)); CHECK_MSTATUS(nAttr.setHidden(false)); CHECK_MSTATUS(nAttr.setReadable(true)); CHECK_MSTATUS(nAttr.setWritable(false)); CHECK_MSTATUS(addAttribute(aColor)); CHECK_MSTATUS(addAttribute(aInputValue)); CHECK_MSTATUS(addAttribute(aOutColor)); CHECK_MSTATUS(addAttribute(aOutTransparency)); CHECK_MSTATUS(addAttribute(aOutDisplacement)); CHECK_MSTATUS(attributeAffects (aColor, aOutColor)); CHECK_MSTATUS(attributeAffects (aColor, aOutDisplacement)); return MS::kSuccess; }
MStatus VolumePushCollider::initialize() { MFnNumericAttribute nAttr; MFnMatrixAttribute mAttr; // inCollider aInCollider = mAttr.create("inCollider", "col"); mAttr.setArray(true); CHECK_MSTATUS(addAttribute(aInCollider)); // inVolume aInVolume = mAttr.create("inVolume", "vol"); mAttr.setArray(true); CHECK_MSTATUS(addAttribute(aInVolume)); // output aOutput = nAttr.create("output", "out", MFnNumericData::kDouble, 0.0); nAttr.setArray(true); nAttr.setReadable(true); nAttr.setWritable(true); nAttr.setHidden(true); CHECK_MSTATUS(addAttribute(aOutput)); attributeAffects(aInCollider, aOutput); attributeAffects(aInVolume, aOutput); return MS::kSuccess; }
MStatus MocapMesh::initialize() { MStatus stat; MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; in_inMesh = tAttr.create("inMesh", "im",MFnData::kMesh); tAttr.setKeyable(true); tAttr.setStorable(true); tAttr.setReadable(true); tAttr.setWritable(true); stat = addAttribute(in_inMesh); if(!stat) { stat.perror("adding inMesh"); return stat; } out_message = nAttr.create("test", "test", MFnNumericData::kDouble, 0.0); nAttr.setKeyable(false); nAttr.setStorable(false); nAttr.setWritable(false); nAttr.setReadable(true); stat = addAttribute(out_message); if(!stat) { stat.perror("adding test"); return stat; } stat = attributeAffects(in_inMesh,out_message); if(!stat) { stat.perror("attributeAffects"); return stat; } return MS::kSuccess; }
MStatus BCIViz::initialize() { MFnNumericAttribute numFn; MFnMatrixAttribute matAttr; MStatus stat; ainput = matAttr.create( "input", "in", MFnMatrixAttribute::kDouble ); matAttr.setStorable(false); matAttr.setWritable(true); matAttr.setConnectable(true); addAttribute(ainput); atargets = matAttr.create( "target", "tgt", MFnMatrixAttribute::kDouble ); matAttr.setStorable(false); matAttr.setWritable(true); matAttr.setArray(true); matAttr.setConnectable(true); addAttribute(atargets); outValue = numFn.create( "outValue", "ov", MFnNumericData::kDouble ); numFn.setStorable(false); numFn.setWritable(false); numFn.setReadable(true); numFn.setArray(true); numFn.setUsesArrayDataBuilder( true ); addAttribute(outValue); attributeAffects(ainput, outValue); attributeAffects(atargets, outValue); return MS::kSuccess; }
MStatus weightList::initialize() { MStatus status; MFnNumericAttribute numAtt; aBias = numAtt.create( "bias", "b", MFnNumericData::kFloat); addAttribute(aBias); aWeights = numAtt.create("weights", "w", MFnNumericData::kFloat, -1000.0, &status); numAtt.setKeyable(true); numAtt.setArray(true); numAtt.setReadable(true); numAtt.setUsesArrayDataBuilder(true); // setIndexMatters() will only affect array attributes with setReadable set to false, // i.e. destination attributes. We have set the default value to an unlikely value // to guarantee an entry is created regardless of its value. // numAtt.setIndexMatters(true); addAttribute(aWeights); MFnCompoundAttribute cmpAttr; aWeightsList = cmpAttr.create("weightsList", "wl", &status); cmpAttr.setArray(true); cmpAttr.addChild(aWeights); cmpAttr.setReadable(true); cmpAttr.setUsesArrayDataBuilder(true); // cmpAttr.setIndexMatters(true); addAttribute(aWeightsList); attributeAffects(aBias, aWeightsList); return MStatus::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; }
// INIT ========================================= MStatus gear_uToPercentage::initialize() { MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MStatus stat; // Curve curve = tAttr.create("curve", "crv", MFnData::kNurbsCurve); stat = addAttribute( curve ); if (!stat) {stat.perror("addAttribute"); return stat;} // Sliders normalizedU = nAttr.create("normalizedU", "n", MFnNumericData::kBoolean, false); nAttr.setStorable(true); nAttr.setKeyable(true); stat = addAttribute( normalizedU ); if (!stat) {stat.perror("addAttribute"); return stat;} u = nAttr.create("u", "u", MFnNumericData::kFloat, .5, 0); nAttr.setStorable(true); nAttr.setKeyable(true); stat = addAttribute( u ); if (!stat) {stat.perror("addAttribute"); return stat;} steps = nAttr.create("steps", "s", MFnNumericData::kShort, 40); nAttr.setStorable(true); nAttr.setKeyable(true); stat = addAttribute( steps ); if (!stat) {stat.perror("addAttribute"); return stat;} // Outputs percentage = nAttr.create( "percentage", "p", MFnNumericData::kFloat, 0 ); nAttr.setWritable(false); nAttr.setStorable(false); nAttr.setReadable(true); nAttr.setKeyable(false); stat = addAttribute( percentage ); if (!stat) {stat.perror("addAttribute"); return stat;} // Connections stat = attributeAffects ( curve, percentage ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( steps, percentage ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( u, percentage ); if (!stat) {stat.perror("attributeAffects"); return stat;} stat = attributeAffects ( normalizedU, percentage ); if (!stat) {stat.perror("attributeAffects"); return stat;} return MS::kSuccess; }
MStatus DynamicEnum::initialize() { MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; MFnStringData sData; MStatus status; // Status will be used to hold the MStatus value // returned by each api function call. It is important // to check the status returned by a call to aid in // debugging. Failed API calls can result in subtle // errors that can be difficult to track down, you may // wish to use the CHECK_MSTATUS macro for any API // call where you do not need to provide your own // error handling. // // Attribute Initialization: aFilePath = tAttr.create( "filepath", "file", MFnData::kString, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( tAttr.setKeyable( true ) ); CHECK_MSTATUS( tAttr.setStorable( true ) ); CHECK_MSTATUS( tAttr.setDefault( sData.create("") ) ); aGridName = tAttr.create( "grid", "grd", MFnData::kString, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( tAttr.setKeyable( true ) ); CHECK_MSTATUS( tAttr.setStorable( true ) ); CHECK_MSTATUS( tAttr.setDefault( sData.create("") ) ); aOutColor = nAttr.createColor( "outColor", "oc", &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setHidden( false ) ); CHECK_MSTATUS( nAttr.setReadable( true ) ); CHECK_MSTATUS( nAttr.setWritable( false ) ); // Next we will add the attributes we have defined to the node // CHECK_MSTATUS( addAttribute( aFilePath ) ); CHECK_MSTATUS( addAttribute( aGridName ) ); CHECK_MSTATUS( addAttribute( aOutColor ) ); // The attributeAffects() method is used to indicate when the input // attribute affects the output attribute. This knowledge allows Maya // to optimize dependencies in the graph in more complex nodes where // there may be several inputs and outputs, but not all the inputs // affect all the outputs. // CHECK_MSTATUS( attributeAffects( aFilePath, aOutColor ) ); CHECK_MSTATUS( attributeAffects( aGridName, aOutColor ) ); return( MS::kSuccess ); }
MStatus ik2Bsolver::initialize() { MFnNumericAttribute numattr; arestLength1 = numattr.create("restLength1", "rsl1", MFnNumericData::kDouble, 16.0); numattr.setMin(1.0); numattr.setKeyable(true); numattr.setReadable(true); numattr.setConnectable(true); addAttribute(arestLength1); arestLength2 = numattr.create("restLength2", "rsl2", MFnNumericData::kDouble, 16.0); numattr.setMin(1.0); numattr.setKeyable(true); numattr.setReadable(true); numattr.setConnectable(true); addAttribute(arestLength2); asoftDistance = numattr.create("softDistance", "sftd", MFnNumericData::kDouble, 1.0); numattr.setMin(0.01); numattr.setKeyable(true); numattr.setReadable(true); numattr.setConnectable(true); numattr.setStorable(true); addAttribute(asoftDistance); amaxStretching = numattr.create("maxStretching", "mstc", MFnNumericData::kDouble, 4.0); numattr.setMin(0.0); numattr.setKeyable(true); numattr.setReadable(true); numattr.setConnectable(true); numattr.setStorable(true); addAttribute(amaxStretching); attributeAffects(asoftDistance, ik2Bsolver::message); return MS::kSuccess; }
MStatus TestDeformer::initialize() { MFnNumericAttribute numericAttr; MFnTypedAttribute polyMeshAttr; MFnEnumAttribute enumAttr; MStatus status; // Status will be used to hold the MStatus value // vertSnapInput driver_mesh = polyMeshAttr.create( "vertSnapInput", "vsnpin", MFnData::kMesh, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( polyMeshAttr.setStorable( false ) ); CHECK_MSTATUS( polyMeshAttr.setArray(true) ); CHECK_MSTATUS( polyMeshAttr.setConnectable( true ) ); CHECK_MSTATUS( addAttribute(driver_mesh) ); CHECK_MSTATUS( attributeAffects(driver_mesh, outputGeom) ); // initialize is used to mark this node's state initialized_data = enumAttr.create( "initialize", "inl", 0/*default*/, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( enumAttr.addField( "Off", 0) ); CHECK_MSTATUS( enumAttr.addField( "Re-Set Bind", 1) ); CHECK_MSTATUS( enumAttr.addField( "Bound", 2) ); CHECK_MSTATUS( enumAttr.setKeyable(true) ); CHECK_MSTATUS( enumAttr.setStorable(true) ); CHECK_MSTATUS( enumAttr.setReadable(true) ); CHECK_MSTATUS( enumAttr.setWritable(true) ); CHECK_MSTATUS( enumAttr.setDefault(0) ); CHECK_MSTATUS( addAttribute( initialized_data ) ); CHECK_MSTATUS( attributeAffects( initialized_data, outputGeom ) ); // hold the vertex index mapping vert_map = numericAttr.create( "vtxIndexMap", "vtximp", MFnNumericData::kLong, 0/*default*/, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( numericAttr.setKeyable(false) ); CHECK_MSTATUS( numericAttr.setArray(true) ); CHECK_MSTATUS( numericAttr.setStorable(true) ); CHECK_MSTATUS( numericAttr.setReadable(true) ); CHECK_MSTATUS( numericAttr.setWritable(true) ); CHECK_MSTATUS( addAttribute( vert_map ) ); CHECK_MSTATUS( attributeAffects( vert_map, outputGeom ) ); CHECK_MSTATUS( MGlobal::executePythonCommand("import maya.cmds; maya.cmds.makePaintable('"+TestDeformer::cTypeName()+"', 'weights', attrType='multiFloat')") ); return( MS::kSuccess ); }
// The initialize routine is called after the node has been created. // It sets up the input and output attributes and adds them to the // node. Finally the dependencies are arranged so that when the // inputs change Maya knowns to call compute to recalculate the output // value. // MStatus stringFormat::initialize() { MFnNumericAttribute numAttr; MFnTypedAttribute typedAttr; MFnStringData stringData; MStatus stat; MStatus stat2; // Setup the input attributes // attrFormat = typedAttr.create("format", "f", MFnData::kString, stringData.create(&stat2), &stat); CHECK_MSTATUS( stat2 ); CHECK_MSTATUS( stat ); CHECK_MSTATUS( typedAttr.setStorable( true ) ); CHECK_MSTATUS( typedAttr.setKeyable( true ) ); attrValues = numAttr.create("values", "v", MFnNumericData::kDouble, 0, &stat); CHECK_MSTATUS( stat ); CHECK_MSTATUS( numAttr.setArray( true ) ); CHECK_MSTATUS( numAttr.setReadable( false ) ); CHECK_MSTATUS( numAttr.setIndexMatters( true ) ); CHECK_MSTATUS( numAttr.setStorable( true ) ); CHECK_MSTATUS( numAttr.setKeyable( true ) ); attrOutput = typedAttr.create( "output", "o", MFnData::kString, stringData.create(&stat2), &stat); CHECK_MSTATUS( stat2 ); CHECK_MSTATUS( stat ); CHECK_MSTATUS( typedAttr.setWritable( false ) ); CHECK_MSTATUS( typedAttr.setStorable( false ) ); // Add the attributes to the node // CHECK_MSTATUS( addAttribute( attrFormat ) ); CHECK_MSTATUS( addAttribute( attrValues ) ); CHECK_MSTATUS( addAttribute( attrOutput ) ); // Set the attribute dependencies // CHECK_MSTATUS( attributeAffects( attrFormat, attrOutput ) ); CHECK_MSTATUS( attributeAffects( attrValues, attrOutput ) ); return MS::kSuccess; }
MStatus ParameterisedHolder<B>::initialize() { MStatus s; MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; aParameterisedClassName = tAttr.create( "className", "clas", MFnData::kString ); tAttr.setReadable(true); tAttr.setWritable(true); tAttr.setStorable(true); tAttr.setConnectable(false); tAttr.setHidden(true); s = B::addAttribute( aParameterisedClassName ); assert(s); aParameterisedVersion = nAttr.create("version", "ver", MFnNumericData::kInt, 1, &s ); assert(s); nAttr.setReadable(true); nAttr.setWritable(true); nAttr.setStorable(true); nAttr.setConnectable(false); nAttr.setHidden(true); s = B::addAttribute( aParameterisedVersion ); assert(s); aParameterisedSearchPathEnvVar = tAttr.create("searchPathEnvVar", "spev", MFnData::kString ); tAttr.setReadable(true); tAttr.setWritable(true); tAttr.setStorable(true); tAttr.setConnectable(false); tAttr.setHidden(true); s = B::addAttribute( aParameterisedSearchPathEnvVar ); assert(s); MPxManipContainer::addToManipConnectTable( id ); return MS::kSuccess; }
MStatus dynExprField::initialize() // // Descriptions: // Initialize the node, attributes. // { MStatus status; MFnNumericAttribute numAttr; // create the field basic attributes. // mDirection = numAttr.createPoint("direction","dir"); numAttr.setDefault( 0.0, 1.0, 0.0 ); numAttr.setKeyable(true); numAttr.setStorable(true); numAttr.setReadable(true); numAttr.setWritable(true); status = addAttribute( mDirection ); attributeAffects(mDirection, mOutputForce); return( MS::kSuccess ); }
//--------------------------------------------------- // Creates a typed attribute. Used for maya "notes" attributes. MObject DagHelper::createAttribute ( const MObject& node, const char* attributeName, const char* attributeShortName, MFnNumericData::Type type, const char *value ) { // Before creating a new attribute: verify that an old one doesn't already exist MStatus status; MObject attribute; MFnDependencyNode nodeFn ( node ); MPlug plug = nodeFn.findPlug ( attributeShortName, status ); if ( status != MStatus::kSuccess ) { MFnNumericAttribute attr; MStatus status; attribute = attr.create ( attributeName,attributeShortName,type,0,&status ); if ( status != MStatus::kSuccess ) return MObject::kNullObj; attr.setStorable ( true ); attr.setKeyable ( false ); attr.setCached ( true ); attr.setReadable ( true ); attr.setWritable ( true ); status = nodeFn.addAttribute ( attribute, MFnDependencyNode::kLocalDynamicAttr ); if ( status != MStatus::kSuccess ) return MObject::kNullObj; plug = nodeFn.findPlug ( attribute, &status ); if ( status != MStatus::kSuccess ) return MObject::kNullObj; } status = plug.setValue ( value ); if ( status != MStatus::kSuccess ) return MObject::kNullObj; return attribute; }
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; }
// // DESCRIPTION: /////////////////////////////////////////////////////// MStatus clearcoat::initialize() { MFnNumericAttribute nAttr; MFnCompoundAttribute cAttr; aIndex = nAttr.create( "index", "ix", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(true) ); CHECK_MSTATUS ( nAttr.setDefault(1.8f) ); CHECK_MSTATUS ( nAttr.setSoftMin(1.0f) ); CHECK_MSTATUS ( nAttr.setSoftMax(5.0f) ); aScale = nAttr.create( "scale", "s", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(true) ); CHECK_MSTATUS ( nAttr.setDefault(1.55f) ); CHECK_MSTATUS ( nAttr.setSoftMin(0.0f) ); CHECK_MSTATUS ( nAttr.setSoftMax(5.0f) ); aBias = nAttr.create( "bias", "b", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(true) ); CHECK_MSTATUS ( nAttr.setDefault(-0.1f) ); CHECK_MSTATUS ( nAttr.setSoftMin(-1.0f) ); CHECK_MSTATUS ( nAttr.setSoftMax( 1.0f) ); aNormalCameraX = nAttr.create( "normalCameraX", "nx", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setDefault(1.0f) ); aNormalCameraY = nAttr.create( "normalCameraY", "ny", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false)); CHECK_MSTATUS ( nAttr.setDefault(1.0f) ); aNormalCameraZ = nAttr.create( "normalCameraZ", "nz", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setDefault(1.0f) ); aNormalCamera = nAttr.create( "normalCamera","n", aNormalCameraX, aNormalCameraY, aNormalCameraZ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f)); CHECK_MSTATUS ( nAttr.setHidden(true) ); aRayDirectionX = nAttr.create( "rayDirectionX", "rx", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setDefault(1.0f) ); aRayDirectionY = nAttr.create( "rayDirectionY", "ry", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false)); CHECK_MSTATUS ( nAttr.setDefault(1.0f)); aRayDirectionZ = nAttr.create( "rayDirectionZ", "rz", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setDefault(1.0f) ); aRayDirection = nAttr.create( "rayDirection","r", aRayDirectionX, aRayDirectionY, aRayDirectionZ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); // Outputs aOutValue = nAttr.create( "outValue", "ov", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setHidden(false) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS ( addAttribute(aIndex)); CHECK_MSTATUS ( addAttribute(aScale) ); CHECK_MSTATUS ( addAttribute(aBias) ); // compound attribute - only need to add parent CHECK_MSTATUS ( addAttribute(aNormalCamera) ); // compound attribute - only need to add parent CHECK_MSTATUS ( addAttribute(aRayDirection) ); CHECK_MSTATUS ( addAttribute(aOutValue) ); CHECK_MSTATUS ( attributeAffects (aIndex, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aScale, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aBias, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aNormalCameraX, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aNormalCameraY, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aNormalCameraZ, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aNormalCamera, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aRayDirectionX, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aRayDirectionY, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aRayDirectionZ, aOutValue) ); CHECK_MSTATUS ( attributeAffects (aRayDirection, aOutValue) ); return MS::kSuccess; }
MStatus snapDeformer::initialize() { MStatus stat; MFnNumericAttribute FnNumeric; MFnNumericAttribute FnNumericA; MFnTypedAttribute FnTyped; MFnEnumAttribute FnEnum; //weight weight = FnNumeric.create("weight", "we", MFnNumericData::kFloat); FnNumeric.setKeyable(true); FnNumeric.setStorable(true); FnNumeric.setReadable(true); FnNumeric.setWritable(true); FnNumeric.setDefault( 1.0 ); addAttribute( weight ); ///space target space = FnEnum.create("space", "sp", 0); FnEnum.addField("world",0); FnEnum.addField("object",1); FnEnum.setStorable(true); FnEnum.setKeyable(true); addAttribute(space); ///space source spaceSource = FnEnum.create("spaceSource", "sps", 0); FnEnum.addField("world",0); FnEnum.addField("object",1); FnEnum.setStorable(true); FnEnum.setKeyable(true); addAttribute(spaceSource); //pointlist pointList = FnNumericA.create("pointList", "pl", MFnNumericData::kInt); FnNumericA.setArray( true ); FnNumericA.setKeyable(false); FnNumericA.setStorable(true); FnNumericA.setReadable(true); FnNumericA.setWritable(true); FnNumericA.setIndexMatters(true); addAttribute( pointList ); //snapMesh snapMesh = FnTyped.create("snapMesh", "sm", MFnData::kMesh); FnTyped.setArray( false ); FnTyped.setReadable(true); FnTyped.setWritable(true); addAttribute( snapMesh ); attributeAffects(snapMesh, outputGeom); attributeAffects(pointList, outputGeom); attributeAffects(space, outputGeom); attributeAffects(spaceSource, outputGeom); attributeAffects(weight, outputGeom); return stat; }
MStatus pointOnSubd::initialize() // // Description: // This method is called to create and initialize all of the attributes // and attribute dependencies for this node type. This is only called // once when the node type is registered with Maya. // // Return Values: // MS::kSuccess // MS::kFailure // { MStatus stat; MFnTypedAttribute subdAttr; aSubd = subdAttr.create( "subd", "s", MFnSubdData::kSubdSurface, &stat ); McheckErr( stat, "cannot create pointOnSubd::aSubd" ); subdAttr.setStorable(true); subdAttr.setKeyable(false); subdAttr.setReadable( true ); subdAttr.setWritable( true ); subdAttr.setCached( false ); stat = addAttribute( pointOnSubd::aSubd ); McheckErr( stat, "cannot add pointOnSubd::aSubd" ); MFnNumericAttribute faceFirstAttr; aFaceFirst = faceFirstAttr.create( "faceFirst", "ff", MFnNumericData::kLong, 0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aFaceFirst" ); faceFirstAttr.setStorable(true); faceFirstAttr.setKeyable(true); faceFirstAttr.setSoftMin( 0.0 ); faceFirstAttr.setReadable( true ); faceFirstAttr.setWritable( true ); faceFirstAttr.setCached( false ); stat = addAttribute( pointOnSubd::aFaceFirst ); McheckErr( stat, "cannot add pointOnSubd::aFaceFirst" ); MFnNumericAttribute faceSecondAttr; aFaceSecond = faceSecondAttr.create( "faceSecond", "fs", MFnNumericData::kLong, 0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aFaceSecond" ); faceSecondAttr.setStorable(true); faceSecondAttr.setKeyable(true); faceSecondAttr.setSoftMin( 0.0 ); faceSecondAttr.setReadable( true ); faceSecondAttr.setWritable( true ); faceSecondAttr.setCached( false ); stat = addAttribute( pointOnSubd::aFaceSecond ); McheckErr( stat, "cannot add pointOnSubd::aFaceSecond" ); MFnNumericAttribute uAttr; aU = uAttr.create( "uValue", "u", MFnNumericData::kDouble, 0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aU" ); uAttr.setStorable(true); uAttr.setKeyable(true); uAttr.setSoftMin( 0.0 ); uAttr.setSoftMax( 1.0 ); uAttr.setReadable( true ); uAttr.setWritable( true ); uAttr.setCached( false ); stat = addAttribute( aU ); McheckErr( stat, "cannot add pointOnSubd::aU" ); MFnNumericAttribute vAttr; aV = vAttr.create( "vValue", "v", MFnNumericData::kDouble, 0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aV" ); vAttr.setStorable(true); vAttr.setKeyable(true); vAttr.setSoftMin( 0.0 ); vAttr.setSoftMax( 1.0 ); vAttr.setReadable( true ); vAttr.setWritable( true ); vAttr.setCached( false ); stat = addAttribute( aV ); McheckErr( stat, "cannot add pointOnSubd::aV" ); MFnNumericAttribute relAttr; aRelativeUV = relAttr.create( "relative", "rel", MFnNumericData::kBoolean, 0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aRelativeUV" ); relAttr.setStorable(true); relAttr.setKeyable(true); relAttr.setSoftMin( 0.0 ); relAttr.setSoftMax( 1.0 ); relAttr.setReadable( true ); relAttr.setWritable( true ); relAttr.setCached( false ); stat = addAttribute( pointOnSubd::aRelativeUV ); McheckErr( stat, "cannot add pointOnSubd::aRelativeUV" ); MFnNumericAttribute pointXAttr; aPointX = pointXAttr.create( "pointX", "px", MFnNumericData::kDouble, 0.0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aPointX" ); pointXAttr.setWritable(false); pointXAttr.setStorable(false); pointXAttr.setReadable( true ); pointXAttr.setCached( true ); stat = addAttribute( aPointX ); McheckErr( stat, "cannot add pointOnSubd::aPointX" ); MFnNumericAttribute pointYAttr; aPointY = pointYAttr.create( "pointY", "py", MFnNumericData::kDouble, 0.0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aPointY" ); pointYAttr.setWritable(false); pointYAttr.setStorable(false); pointYAttr.setReadable( true ); pointYAttr.setCached( true ); stat = addAttribute( aPointY ); McheckErr( stat, "cannot add pointOnSubd::aPointY" ); MFnNumericAttribute pointZAttr; aPointZ = pointZAttr.create( "pointZ", "pz", MFnNumericData::kDouble, 0.0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aPointZ" ); pointZAttr.setWritable(false); pointZAttr.setStorable(false); pointZAttr.setReadable( true ); pointZAttr.setCached( true ); stat = addAttribute( aPointZ ); McheckErr( stat, "cannot add pointOnSubd::aPointZ" ); MFnNumericAttribute pointAttr; aPoint = pointAttr.create( "point", "p", aPointX, aPointY, aPointZ, &stat); McheckErr( stat, "cannot create pointOnSubd::aPoint" ); pointAttr.setWritable(false); pointAttr.setStorable(false); pointAttr.setReadable( true ); pointAttr.setCached( true ); stat = addAttribute( aPoint ); McheckErr( stat, "cannot add pointOnSubd::aPoint" ); MFnNumericAttribute normalXAttr; aNormalX = normalXAttr.create( "normalX", "nx", MFnNumericData::kDouble, 0.0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aNormal" ); normalXAttr.setWritable(false); normalXAttr.setStorable(false); normalXAttr.setReadable( true ); normalXAttr.setCached( true ); stat = addAttribute( aNormalX ); McheckErr( stat, "cannot add pointOnSubd::aNormalX" ); MFnNumericAttribute normalYAttr; aNormalY = normalYAttr.create( "normalY", "ny", MFnNumericData::kDouble, 0.0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aNormal" ); normalYAttr.setWritable(false); normalYAttr.setStorable(false); normalYAttr.setReadable( true ); normalYAttr.setCached( true ); stat = addAttribute( aNormalY ); McheckErr( stat, "cannot add pointOnSubd::aNormalY" ); MFnNumericAttribute normalZAttr; aNormalZ = normalZAttr.create( "normalZ", "nz", MFnNumericData::kDouble, 0.0, &stat ); McheckErr( stat, "cannot create pointOnSubd::aNormal" ); normalZAttr.setWritable(false); normalZAttr.setStorable(false); normalZAttr.setReadable( true ); normalZAttr.setCached( true ); stat = addAttribute( aNormalZ ); McheckErr( stat, "cannot add pointOnSubd::aNormalZ" ); MFnNumericAttribute normalAttr; aNormal = normalAttr.create("normal","n",aNormalX,aNormalY,aNormalZ,&stat); McheckErr( stat, "cannot create pointOnSubd::aNormal" ); normalAttr.setWritable(false); normalAttr.setStorable(false); normalAttr.setReadable( true ); normalAttr.setCached( true ); stat = addAttribute( aNormal ); McheckErr( stat, "cannot add pointOnSubd::aNormal" ); // Set up a dependency between the input and the output. This will cause // the output to be marked dirty when the input changes. The output will // then be recomputed the next time the value of the output is requested. // stat = attributeAffects( aSubd, aPoint ); stat = attributeAffects( aSubd, aPointX ); stat = attributeAffects( aSubd, aPointY ); stat = attributeAffects( aSubd, aPointZ ); stat = attributeAffects( aSubd, aNormal ); stat = attributeAffects( aSubd, aNormalX ); stat = attributeAffects( aSubd, aNormalY ); stat = attributeAffects( aSubd, aNormalZ ); stat = attributeAffects( aFaceFirst, aPoint ); stat = attributeAffects( aFaceFirst, aPointX ); stat = attributeAffects( aFaceFirst, aPointY ); stat = attributeAffects( aFaceFirst, aPointZ ); stat = attributeAffects( aFaceFirst, aNormal ); stat = attributeAffects( aFaceFirst, aNormalX ); stat = attributeAffects( aFaceFirst, aNormalY ); stat = attributeAffects( aFaceFirst, aNormalZ ); stat = attributeAffects( aFaceSecond, aPoint ); stat = attributeAffects( aFaceSecond, aPointX ); stat = attributeAffects( aFaceSecond, aPointY ); stat = attributeAffects( aFaceSecond, aPointZ ); stat = attributeAffects( aFaceSecond, aNormal ); stat = attributeAffects( aFaceSecond, aNormalX ); stat = attributeAffects( aFaceSecond, aNormalY ); stat = attributeAffects( aFaceSecond, aNormalZ ); stat = attributeAffects( aU, aPoint ); stat = attributeAffects( aU, aPointX ); stat = attributeAffects( aU, aPointY ); stat = attributeAffects( aU, aPointZ ); stat = attributeAffects( aU, aNormal ); stat = attributeAffects( aU, aNormalX ); stat = attributeAffects( aU, aNormalY ); stat = attributeAffects( aU, aNormalZ ); stat = attributeAffects( aV, aPoint ); stat = attributeAffects( aV, aPointX ); stat = attributeAffects( aV, aPointY ); stat = attributeAffects( aV, aPointZ ); stat = attributeAffects( aV, aNormal ); stat = attributeAffects( aV, aNormalX ); stat = attributeAffects( aV, aNormalY ); stat = attributeAffects( aV, aNormalZ ); stat = attributeAffects( aRelativeUV, aPoint ); stat = attributeAffects( aRelativeUV, aPointX ); stat = attributeAffects( aRelativeUV, aPointY ); stat = attributeAffects( aRelativeUV, aPointZ ); stat = attributeAffects( aRelativeUV, aNormal ); stat = attributeAffects( aRelativeUV, aNormalX ); stat = attributeAffects( aRelativeUV, aNormalY ); stat = attributeAffects( aRelativeUV, aNormalZ ); return MS::kSuccess; }
MStatus Layered::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. // baseShader = nAttr.createColor("baseShader", "baseShader"); CHECK_MSTATUS(addAttribute(baseShader)); layerWeight = nAttr.create("layerWeight", "layerWeight", MFnNumericData::kFloat, 0, &status); nAttr.setArray(true); CHECK_MSTATUS(addAttribute(layerWeight)); layerTexture = mAttr.create("layerTexture", "layerTexture"); mAttr.setArray(true); CHECK_MSTATUS(addAttribute(layerTexture)); layerShader = nAttr.createColor("layerShader", "layerShader"); nAttr.setArray(true); CHECK_MSTATUS(addAttribute(layerShader)); outColor = nAttr.createColor("outColor", "outColor"); CHECK_MSTATUS(addAttribute(outColor)); //---------------------------- automatically created attributes start ------------------------------------ //---------------------------- automatically created attributes end ------------------------------------ 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)); 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(outColor)); CHECK_MSTATUS(addAttribute(aOutTransparency)); CHECK_MSTATUS(addAttribute(aNormalCamera)); // Only add the parent of the compound CHECK_MSTATUS(addAttribute(aLightData)); CHECK_MSTATUS(attributeAffects(layerTexture, outColor)); CHECK_MSTATUS(attributeAffects(layerWeight, outColor)); CHECK_MSTATUS(attributeAffects(aTranslucenceCoeff, outColor)); CHECK_MSTATUS(attributeAffects(aDiffuseReflectivity, outColor)); CHECK_MSTATUS(attributeAffects(aColor, outColor)); CHECK_MSTATUS(attributeAffects(aInTransparency, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aInTransparency, outColor)); CHECK_MSTATUS(attributeAffects(aIncandescence, outColor)); CHECK_MSTATUS(attributeAffects(aLightIntensityR, outColor)); CHECK_MSTATUS(attributeAffects(aLightIntensityB, outColor)); CHECK_MSTATUS(attributeAffects(aLightIntensityG, outColor)); CHECK_MSTATUS(attributeAffects(aLightIntensity, outColor)); CHECK_MSTATUS(attributeAffects(aNormalCameraX, outColor)); CHECK_MSTATUS(attributeAffects(aNormalCameraY, outColor)); CHECK_MSTATUS(attributeAffects(aNormalCameraZ, outColor)); CHECK_MSTATUS(attributeAffects(aNormalCamera, outColor)); CHECK_MSTATUS(attributeAffects(aLightDirectionX, outColor)); CHECK_MSTATUS(attributeAffects(aLightDirectionY, outColor)); CHECK_MSTATUS(attributeAffects(aLightDirectionZ, outColor)); CHECK_MSTATUS(attributeAffects(aLightDirection, outColor)); CHECK_MSTATUS(attributeAffects(aLightAmbient, outColor)); CHECK_MSTATUS(attributeAffects(aLightSpecular, outColor)); CHECK_MSTATUS(attributeAffects(aLightDiffuse, outColor)); CHECK_MSTATUS(attributeAffects(aLightShadowFraction, outColor)); CHECK_MSTATUS(attributeAffects(aPreShadowIntensity, outColor)); CHECK_MSTATUS(attributeAffects(aLightBlindData, outColor)); CHECK_MSTATUS(attributeAffects(aLightData, outColor)); return( MS::kSuccess ); }
MStatus slopeShaderNode::initialize() // // Description: // Initializes the attributes for this node. // { MFnNumericAttribute nAttr; MFnMatrixAttribute nMAttr; MFnTypedAttribute nTAttr; MFnGenericAttribute nGAttr; // Input Attributes // aAngle = nAttr.create( "angle", "ang", MFnNumericData::kFloat); nAttr.setDefault(30.0f); nAttr.setMin(0.0f); nAttr.setMax(100.0f); nAttr.setKeyable(true); nAttr.setStorable(true); nAttr.setReadable(true); nAttr.setWritable(true); aColor1 = nAttr.createColor( "walkableColor", "w" ); nAttr.setDefault(0.0f, 1.0f, 0.0f); nAttr.setKeyable(true); nAttr.setStorable(true); nAttr.setUsedAsColor(true); nAttr.setReadable(true); nAttr.setWritable(true); aColor2 = nAttr.createColor( "nonWalkableColor", "nw" ); nAttr.setDefault(1.0f, 0.0f, 0.0f); nAttr.setKeyable(true); nAttr.setStorable(true); nAttr.setUsedAsColor(true); nAttr.setReadable(true); nAttr.setWritable(true); // Surface Normal supplied by the render sampler // aTriangleNormalCamera = nAttr.createPoint( "triangleNormalCamera", "n" ); nAttr.setStorable(false); nAttr.setHidden(true); nAttr.setReadable(true); nAttr.setWritable(true); //View matrix from the camera into world space // aMatrixEyeToWorld = nMAttr.create( "matrixEyeToWorld", "mew", MFnMatrixAttribute::kFloat ); nAttr.setHidden(true); nMAttr.setWritable(true); // Output Attributes // aOutColor = nAttr.createColor( "outColor", "oc" ); nAttr.setStorable(false); nAttr.setHidden(false); nAttr.setReadable(true); nAttr.setWritable(false); //dummy plug for forcing evaluation // aDirtyShaderAttr = nGAttr.create( "dirtyShaderPlug", "dsp"); nGAttr.setArray(true); nGAttr.setHidden(false); nGAttr.setUsesArrayDataBuilder(true); nGAttr.setReadable(false); nGAttr.setStorable(true); nGAttr.setIndexMatters(false); nGAttr.addAccept(MFnData::kMesh); //Add attribues addAttribute(aAngle); addAttribute(aColor1); addAttribute(aColor2); addAttribute(aTriangleNormalCamera); addAttribute(aOutColor); addAttribute(aMatrixEyeToWorld); addAttribute(aDirtyShaderAttr); attributeAffects (aAngle, aOutColor); attributeAffects (aColor1, aOutColor); attributeAffects (aColor2, aOutColor); attributeAffects (aTriangleNormalCamera, aOutColor); attributeAffects (aDirtyShaderAttr, aOutColor); return MS::kSuccess; }
MStatus closestPointOnCurveNode::initialize() { // CREATE AND ADD ".inCurve" ATTRIBUTE: MFnTypedAttribute inCurveAttrFn; aInCurve = inCurveAttrFn.create("inCurve", "ic", MFnData::kNurbsCurve); inCurveAttrFn.setStorable(true); inCurveAttrFn.setKeyable(false); inCurveAttrFn.setReadable(true); inCurveAttrFn.setWritable(true); inCurveAttrFn.setCached(false); addAttribute(aInCurve); // CREATE AND ADD ".inPositionX" ATTRIBUTE: MFnNumericAttribute inPositionXAttrFn; aInPositionX = inPositionXAttrFn.create("inPositionX", "ipx", MFnNumericData::kDouble, 0.0); inPositionXAttrFn.setStorable(true); inPositionXAttrFn.setKeyable(true); inPositionXAttrFn.setReadable(true); inPositionXAttrFn.setWritable(true); addAttribute(aInPositionX); // CREATE AND ADD ".inPositionY" ATTRIBUTE: MFnNumericAttribute inPositionYAttrFn; aInPositionY = inPositionYAttrFn.create("inPositionY", "ipy", MFnNumericData::kDouble, 0.0); inPositionYAttrFn.setStorable(true); inPositionYAttrFn.setKeyable(true); inPositionYAttrFn.setReadable(true); inPositionYAttrFn.setWritable(true); addAttribute(aInPositionY); // CREATE AND ADD ".inPositionZ" ATTRIBUTE: MFnNumericAttribute inPositionZAttrFn; aInPositionZ = inPositionZAttrFn.create("inPositionZ", "ipz", MFnNumericData::kDouble, 0.0); inPositionZAttrFn.setStorable(true); inPositionZAttrFn.setKeyable(true); inPositionZAttrFn.setReadable(true); inPositionZAttrFn.setWritable(true); addAttribute(aInPositionZ); // CREATE AND ADD ".inPosition" ATTRIBUTE: MFnNumericAttribute inPositionAttrFn; aInPosition = inPositionAttrFn.create("inPosition", "ip", aInPositionX, aInPositionY, aInPositionZ); inPositionAttrFn.setStorable(true); inPositionAttrFn.setKeyable(true); inPositionAttrFn.setReadable(true); inPositionAttrFn.setWritable(true); addAttribute(aInPosition); // CREATE AND ADD ".positionX" ATTRIBUTE: MFnNumericAttribute pointXAttrFn; aPositionX = pointXAttrFn.create("positionX", "px", MFnNumericData::kDouble, 0.0); pointXAttrFn.setStorable(false); pointXAttrFn.setKeyable(false); pointXAttrFn.setReadable(true); pointXAttrFn.setWritable(false); addAttribute(aPositionX); // CREATE AND ADD ".positionY" ATTRIBUTE: MFnNumericAttribute pointYAttrFn; aPositionY = pointYAttrFn.create("positionY", "py", MFnNumericData::kDouble, 0.0); pointYAttrFn.setStorable(false); pointYAttrFn.setKeyable(false); pointYAttrFn.setReadable(true); pointYAttrFn.setWritable(false); addAttribute(aPositionY); // CREATE AND ADD ".positionZ" ATTRIBUTE: MFnNumericAttribute pointZAttrFn; aPositionZ = pointZAttrFn.create("positionZ", "pz", MFnNumericData::kDouble, 0.0); pointZAttrFn.setStorable(false); pointZAttrFn.setKeyable(false); pointZAttrFn.setReadable(true); pointZAttrFn.setWritable(false); addAttribute(aPositionZ); // CREATE AND ADD ".position" ATTRIBUTE: MFnNumericAttribute pointAttrFn; aPosition = pointAttrFn.create("position", "p", aPositionX, aPositionY, aPositionZ); pointAttrFn.setStorable(false); pointAttrFn.setKeyable(false); pointAttrFn.setReadable(true); pointAttrFn.setWritable(false); addAttribute(aPosition); // CREATE AND ADD ".normalX" ATTRIBUTE: MFnNumericAttribute normalXAttrFn; aNormalX = normalXAttrFn.create("normalX", "nx", MFnNumericData::kDouble, 0.0); normalXAttrFn.setStorable(false); normalXAttrFn.setKeyable(false); normalXAttrFn.setReadable(true); normalXAttrFn.setWritable(false); addAttribute(aNormalX); // CREATE AND ADD ".normalY" ATTRIBUTE: MFnNumericAttribute normalYAttrFn; aNormalY = normalYAttrFn.create("normalY", "ny", MFnNumericData::kDouble, 0.0); normalYAttrFn.setStorable(false); normalYAttrFn.setKeyable(false); normalYAttrFn.setReadable(true); normalYAttrFn.setWritable(false); addAttribute(aNormalY); // CREATE AND ADD ".normalZ" ATTRIBUTE: MFnNumericAttribute normalZAttrFn; aNormalZ = normalZAttrFn.create("normalZ", "nz", MFnNumericData::kDouble, 0.0); normalZAttrFn.setStorable(false); normalZAttrFn.setKeyable(false); normalZAttrFn.setReadable(true); normalZAttrFn.setWritable(false); addAttribute(aNormalZ); // CREATE AND ADD ".normal" ATTRIBUTE: MFnNumericAttribute normalAttrFn; aNormal = normalAttrFn.create("normal", "n", aNormalX, aNormalY, aNormalZ); normalAttrFn.setStorable(false); normalAttrFn.setKeyable(false); normalAttrFn.setReadable(true); normalAttrFn.setWritable(false); addAttribute(aNormal); // CREATE AND ADD ".tangentX" ATTRIBUTE: MFnNumericAttribute tangentXAttrFn; aTangentX = tangentXAttrFn.create("tangentX", "tx", MFnNumericData::kDouble, 0.0); tangentXAttrFn.setStorable(false); tangentXAttrFn.setKeyable(false); tangentXAttrFn.setReadable(true); tangentXAttrFn.setWritable(false); addAttribute(aTangentX); // CREATE AND ADD ".tangentY" ATTRIBUTE: MFnNumericAttribute tangentYAttrFn; aTangentY = tangentYAttrFn.create("tangentY", "ty", MFnNumericData::kDouble, 0.0); tangentYAttrFn.setStorable(false); tangentYAttrFn.setKeyable(false); tangentYAttrFn.setReadable(true); tangentYAttrFn.setWritable(false); addAttribute(aTangentY); // CREATE AND ADD ".tangentZ" ATTRIBUTE: MFnNumericAttribute tangentZAttrFn; aTangentZ = tangentZAttrFn.create("tangentZ", "tz", MFnNumericData::kDouble, 0.0); tangentZAttrFn.setStorable(false); tangentZAttrFn.setKeyable(false); tangentZAttrFn.setReadable(true); tangentZAttrFn.setWritable(false); addAttribute(aTangentZ); // CREATE AND ADD ".tangent" ATTRIBUTE: MFnNumericAttribute tangentAttrFn; aTangent = tangentAttrFn.create("tangent", "t", aTangentX, aTangentY, aTangentZ); tangentAttrFn.setStorable(false); tangentAttrFn.setKeyable(false); tangentAttrFn.setReadable(true); tangentAttrFn.setWritable(false); addAttribute(aTangent); // CREATE AND ADD ".parameU" ATTRIBUTE: MFnNumericAttribute paramUAttrFn; aParamU = paramUAttrFn.create("paramU", "u", MFnNumericData::kDouble, 0.0); paramUAttrFn.setStorable(false); paramUAttrFn.setKeyable(false); paramUAttrFn.setReadable(true); paramUAttrFn.setWritable(false); addAttribute(aParamU); // CREATE AND ADD ".distance" ATTRIBUTE: MFnNumericAttribute distanceAttrFn; aDistance = distanceAttrFn.create("distance", "d", MFnNumericData::kDouble, 0.0); distanceAttrFn.setStorable(false); distanceAttrFn.setKeyable(false); distanceAttrFn.setReadable(true); distanceAttrFn.setWritable(false); addAttribute(aDistance); // DEPENDENCY RELATIONS FOR ".inCurve": attributeAffects(aInCurve, aPosition); attributeAffects(aInCurve, aPositionX); attributeAffects(aInCurve, aPositionY); attributeAffects(aInCurve, aPositionZ); attributeAffects(aInCurve, aNormal); attributeAffects(aInCurve, aNormalX); attributeAffects(aInCurve, aNormalY); attributeAffects(aInCurve, aNormalZ); attributeAffects(aInCurve, aTangent); attributeAffects(aInCurve, aTangentX); attributeAffects(aInCurve, aTangentY); attributeAffects(aInCurve, aTangentZ); attributeAffects(aInCurve, aParamU); attributeAffects(aInCurve, aDistance); // DEPENDENCY RELATIONS FOR ".inPosition": attributeAffects(aInPosition, aPosition); attributeAffects(aInPosition, aPositionX); attributeAffects(aInPosition, aPositionY); attributeAffects(aInPosition, aPositionZ); attributeAffects(aInPosition, aNormal); attributeAffects(aInPosition, aNormalX); attributeAffects(aInPosition, aNormalY); attributeAffects(aInPosition, aNormalZ); attributeAffects(aInPosition, aTangent); attributeAffects(aInPosition, aTangentX); attributeAffects(aInPosition, aTangentY); attributeAffects(aInPosition, aTangentZ); attributeAffects(aInPosition, aParamU); attributeAffects(aInPosition, aDistance); // DEPENDENCY RELATIONS FOR ".inPositionX": attributeAffects(aInPositionX, aPosition); attributeAffects(aInPositionX, aPositionX); attributeAffects(aInPositionX, aPositionY); attributeAffects(aInPositionX, aPositionZ); attributeAffects(aInPositionX, aNormal); attributeAffects(aInPositionX, aNormalX); attributeAffects(aInPositionX, aNormalY); attributeAffects(aInPositionX, aNormalZ); attributeAffects(aInPositionX, aTangent); attributeAffects(aInPositionX, aTangentX); attributeAffects(aInPositionX, aTangentY); attributeAffects(aInPositionX, aTangentZ); attributeAffects(aInPositionX, aParamU); attributeAffects(aInPositionX, aDistance); // DEPENDENCY RELATIONS FOR ".inPositionY": attributeAffects(aInPositionY, aPosition); attributeAffects(aInPositionY, aPositionX); attributeAffects(aInPositionY, aPositionY); attributeAffects(aInPositionY, aPositionZ); attributeAffects(aInPositionY, aNormal); attributeAffects(aInPositionY, aNormalX); attributeAffects(aInPositionY, aNormalY); attributeAffects(aInPositionY, aNormalZ); attributeAffects(aInPositionY, aTangent); attributeAffects(aInPositionY, aTangentX); attributeAffects(aInPositionY, aTangentY); attributeAffects(aInPositionY, aTangentZ); attributeAffects(aInPositionY, aParamU); attributeAffects(aInPositionY, aDistance); // DEPENDENCY RELATIONS FOR ".inPositionZ": attributeAffects(aInPositionZ, aPosition); attributeAffects(aInPositionZ, aPositionX); attributeAffects(aInPositionZ, aPositionY); attributeAffects(aInPositionZ, aPositionZ); attributeAffects(aInPositionZ, aNormal); attributeAffects(aInPositionZ, aNormalX); attributeAffects(aInPositionZ, aNormalY); attributeAffects(aInPositionZ, aNormalZ); attributeAffects(aInPositionZ, aTangent); attributeAffects(aInPositionZ, aTangentX); attributeAffects(aInPositionZ, aTangentY); attributeAffects(aInPositionZ, aTangentZ); attributeAffects(aInPositionZ, aParamU); attributeAffects(aInPositionZ, aDistance); return MS::kSuccess; }
// 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 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 ); }
// initializes attribute information // call by MAYA when this plug-in was loded. // MStatus anisotropicShaderNode::initialize() { MFnNumericAttribute nAttr; MFnLightDataAttribute lAttr; MFnMatrixAttribute mAttr; aMatrixOToW = mAttr.create( "matrixObjectToWorld", "mow", MFnMatrixAttribute::kFloat ); CHECK_MSTATUS( mAttr.setStorable( false ) ); CHECK_MSTATUS( mAttr.setHidden( true ) ); aMatrixWToC = mAttr.create( "matrixWorldToEye", "mwc", MFnMatrixAttribute::kFloat ); CHECK_MSTATUS( mAttr.setStorable( false ) ); CHECK_MSTATUS( mAttr.setHidden( true ) ); aDiffuseReflectivity = nAttr.create( "diffuseReflectivity", "drfl", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setDefault(0.8f) ); CHECK_MSTATUS( nAttr.setMin(0.0f) ); CHECK_MSTATUS( nAttr.setMax(1.0f) ); aColor = nAttr.createColor( "color", "c" ); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setDefault(0.0f, 0.58824f, 0.644f) ); aNormalCamera = nAttr.createPoint( "normalCamera", "n" ); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setHidden(true) ); aLightDirection = nAttr.createPoint( "lightDirection", "ld"); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightIntensity = nAttr.createColor( "lightIntensity", "li" ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightAmbient = nAttr.create( "lightAmbient", "la", MFnNumericData::kBoolean); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightDiffuse = nAttr.create( "lightDiffuse", "ldf", MFnNumericData::kBoolean); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightSpecular = nAttr.create( "lightSpecular", "ls", MFnNumericData::kBoolean); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightShadowFraction = nAttr.create( "lightShadowFraction", "lsf", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aPreShadowIntensity = nAttr.create( "preShadowIntensity", "psi", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightBlindData = nAttr.createAddr( "lightBlindData", "lbld"); 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); 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, 0.0f, 1.0f, NULL) ); aSpecularCoeff = nAttr.create( "specularCoeff", "scf", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setMin(0.0f) ); CHECK_MSTATUS( nAttr.setMax(1.0f) ); CHECK_MSTATUS( nAttr.setDefault(0.8f) ); aPointCamera = nAttr.createPoint( "pointCamera", "pc" ); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setHidden(true) ); // input transparency aInTransparency = nAttr.createColor( "transparency", "it" ); MAKE_INPUT(nAttr); // ray direction aRayDirection = nAttr.createPoint( "rayDirection", "rd" ); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setHidden(true) ); // specular color aSpecColor = nAttr.createColor( "specularColor","sc" ); CHECK_MSTATUS( nAttr.setDefault( .5, .5, .5 ) ); MAKE_INPUT(nAttr); // anisotropic parameters // aRoughness1 = nAttr.create( "roughness1", "rn1", MFnNumericData::kFloat); CHECK_MSTATUS( nAttr.setMin(0.0f) ); CHECK_MSTATUS( nAttr.setMax(1.0f) ); CHECK_MSTATUS( nAttr.setDefault(0.2f) ); aRoughness2 = nAttr.create( "roughness2", "rn2", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setMin(0.0f) ); CHECK_MSTATUS( nAttr.setMax(1.0f) ); CHECK_MSTATUS( nAttr.setDefault(0.4f) ); aAxesVector = nAttr.createPoint( "axesVector", "av" ); MAKE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setDefault( 0.0f, 1.0f, 0.0f ) ); // output color aOutColor = nAttr.createColor( "outColor", "oc" ); MAKE_OUTPUT(nAttr); // output transparency aOutTransparency = nAttr.createColor( "outTransparency", "ot" ); MAKE_OUTPUT(nAttr); setAttribute(); return MS::kSuccess; }
MStatus geometrySurfaceConstraint::initialize() { MFnNumericAttribute nAttr; MStatus status; // constraint attributes { // Geometry: mesh, readable, not writable, delete on disconnect MFnTypedAttribute typedAttrNotWritable; geometrySurfaceConstraint::constraintGeometry = typedAttrNotWritable.create( "constraintGeometry", "cg", MFnData::kMesh, &status ); if (!status) { status.perror("typedAttrNotWritable.create:cgeom"); return status;} status = typedAttrNotWritable.setReadable(true); if (!status) { status.perror("typedAttrNotWritable.setReadable:cgeom"); return status;} status = typedAttrNotWritable.setWritable(false); if (!status) { status.perror("typedAttrNotWritable.setWritable:cgeom"); return status;} status = typedAttrNotWritable.setDisconnectBehavior(MFnAttribute::kDelete); if (!status) { status.perror("typedAttrNotWritable.setDisconnectBehavior:cgeom"); return status;} } // Parent inverse matrix: delete on disconnect MFnTypedAttribute typedAttr; geometrySurfaceConstraint::constraintParentInverseMatrix = typedAttr.create( "constraintPim", "ci", MFnData::kMatrix, &status ); if (!status) { status.perror("typedAttr.create:matrix"); return status;} status = typedAttr.setDisconnectBehavior(MFnAttribute::kDelete); if (!status) { status.perror("typedAttr.setDisconnectBehavior:cgeom"); return status;} // Target geometry: mesh, delete on disconnect geometrySurfaceConstraint::targetGeometry = typedAttr.create( "targetGeometry", "tg", MFnData::kMesh, &status ); if (!status) { status.perror("typedAttr.create:tgeom"); return status;} status = typedAttr.setDisconnectBehavior(MFnAttribute::kDelete); if (!status) { status.perror("typedAttr.setDisconnectBehavior:cgeom"); return status;} targetTransform = typedAttr.create( "targetTransform", "ttm", MFnData::kMatrix, &status ); if (!status) { status.perror("typedAttr.create:targetTransform"); return status;} status = typedAttr.setDisconnectBehavior(MFnAttribute::kDelete); if (!status) { status.perror("typedAttr.setDisconnectBehavior:targetTransform"); return status;} // Target weight: double, min 0, default 1.0, keyable, delete on disconnect MFnNumericAttribute typedAttrKeyable; geometrySurfaceConstraint::targetWeight = typedAttrKeyable.create( "weight", "wt", MFnNumericData::kDouble, 1.0, &status ); if (!status) { status.perror("typedAttrKeyable.create:weight"); return status;} status = typedAttrKeyable.setMin( (double) 0 ); if (!status) { status.perror("typedAttrKeyable.setMin"); return status;} status = typedAttrKeyable.setKeyable( true ); if (!status) { status.perror("typedAttrKeyable.setKeyable"); return status;} status = typedAttrKeyable.setDisconnectBehavior(MFnAttribute::kDelete); if (!status) { status.perror("typedAttrKeyable.setDisconnectBehavior:cgeom"); return status;} { // Compound target(geometry,weight): array, delete on disconnect MFnCompoundAttribute compoundAttr; geometrySurfaceConstraint::compoundTarget = compoundAttr.create( "target", "tgt",&status ); if (!status) { status.perror("compoundAttr.create"); return status;} status = compoundAttr.addChild( geometrySurfaceConstraint::targetTransform ); if (!status) { status.perror("compoundAttr.addChild targetTransform"); return status;} status = compoundAttr.addChild( geometrySurfaceConstraint::targetGeometry ); if (!status) { status.perror("compoundAttr.addChild"); return status;} status = compoundAttr.addChild( geometrySurfaceConstraint::targetWeight ); if (!status) { status.perror("compoundAttr.addChild"); return status;} status = compoundAttr.setArray( true ); if (!status) { status.perror("compoundAttr.setArray"); return status;} status = compoundAttr.setDisconnectBehavior(MFnAttribute::kDelete); if (!status) { status.perror("typedAttrKeyable.setDisconnectBehavior:cgeom"); return status;} } MFnNumericAttribute numAttr; constraintTranslateX = numAttr.create( "constraintTranslateX", "ctx", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintTranslateX"); return status; } numAttr.setReadable(true); numAttr.setWritable(false); addAttribute(constraintTranslateX); constraintTranslateY = numAttr.create( "constraintTranslateY", "cty", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintTranslateY"); return status; } numAttr.setReadable(true); numAttr.setWritable(false); addAttribute(constraintTranslateY); constraintTranslateZ = numAttr.create( "constraintTranslateZ", "ctz", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintTranslateY"); return status; } numAttr.setReadable(true); numAttr.setWritable(false); addAttribute(constraintTranslateZ); constraintTargetX = numAttr.create( "constraintTargetX", "ttx", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintTargetX"); return status; } addAttribute(constraintTargetX); constraintTargetY = numAttr.create( "constraintTargetY", "tty", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintTargetY"); return status; } addAttribute(constraintTargetY); constraintTargetZ = numAttr.create( "constraintTargetZ", "ttz", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintTargetZ"); return status; } addAttribute(constraintTargetZ); constraintObjectX = numAttr.create( "constraintObjectX", "otx", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintObjectX"); return status; } addAttribute(constraintObjectX); constraintObjectY = numAttr.create( "constraintObjectY", "oty", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintObjectY"); return status; } addAttribute(constraintObjectY); constraintObjectZ = numAttr.create( "constraintObjectZ", "otz", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintObjectZ"); return status; } addAttribute(constraintObjectZ); targetOffset = numAttr.create("targetOffset", "tgo", MFnNumericData::k3Double, 0.0, &status); if (!status) { status.perror("addAttribute targetOffset"); return status;} addAttribute(targetOffset); targetRestP = numAttr.create("targetRestAt", "tgrt", MFnNumericData::k3Double, 0.0, &status); if (!status) { status.perror("addAttribute targetRestAt"); return status;} addAttribute(targetRestP); status = addAttribute( geometrySurfaceConstraint::constraintParentInverseMatrix ); if (!status) { status.perror("addAttribute"); return status;} status = addAttribute( geometrySurfaceConstraint::constraintGeometry ); if (!status) { status.perror("addAttribute"); return status;} status = addAttribute( geometrySurfaceConstraint::compoundTarget ); if (!status) { status.perror("addAttribute"); return status;} status = attributeAffects( compoundTarget, constraintGeometry ); if (!status) { status.perror("attributeAffects"); return status;} status = attributeAffects( targetTransform, constraintGeometry ); if (!status) { status.perror("attributeAffects"); return status;} status = attributeAffects( targetGeometry, constraintGeometry ); if (!status) { status.perror("attributeAffects"); return status;} status = attributeAffects( targetWeight, constraintGeometry ); if (!status) { status.perror("attributeAffects"); return status;} status = attributeAffects( constraintParentInverseMatrix, constraintGeometry ); if (!status) { status.perror("attributeAffects"); return status;} attributeAffects(targetTransform, constraintTranslateX); attributeAffects(targetTransform, constraintTranslateY); attributeAffects(targetTransform, constraintTranslateZ); return MS::kSuccess; }
MStatus mtmEnvLight::initialize() { MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MFnLightDataAttribute lAttr; MFnEnumAttribute eAttr; MFnMessageAttribute mAttr; MStatus stat; //aColor = nAttr.createColor( "color", "c" ); //CHECK_MSTATUS ( nAttr.setKeyable(true) ); //CHECK_MSTATUS ( nAttr.setStorable(true) ); //CHECK_MSTATUS ( nAttr.setDefault(0.0f, 0.58824f, 0.644f) ); aLightColor = nAttr.createColor( "lightColor", "lightColor" ); CHECK_MSTATUS ( nAttr.setKeyable(true) ); CHECK_MSTATUS ( nAttr.setStorable(true) ); nAttr.setDefault(0.7f, 0.58824f, 0.344f); aShadowColor = nAttr.createColor( "shadowColor", "sc" ); CHECK_MSTATUS ( nAttr.setKeyable(true) ); CHECK_MSTATUS ( nAttr.setStorable(true) ); CHECK_MSTATUS ( nAttr.setDefault(0.0f, 0.0f, 0.0f) ); aPosition = nAttr.createPoint( "position", "pos" ); CHECK_MSTATUS ( nAttr.setKeyable(true) ); CHECK_MSTATUS ( nAttr.setStorable(true) ); aInputDirection = nAttr.createPoint( "inputDirection", "id" ); CHECK_MSTATUS ( nAttr.setKeyable(true) ); CHECK_MSTATUS ( nAttr.setStorable(true) ); CHECK_MSTATUS ( nAttr.setDefault(-1.0f, 0.0f, 0.0f) ); aInputAmbient = nAttr.create( "ambientOn", "an", MFnNumericData::kBoolean); CHECK_MSTATUS ( nAttr.setKeyable(true) ); CHECK_MSTATUS ( nAttr.setStorable(true) ); CHECK_MSTATUS ( nAttr.setHidden(false) ); CHECK_MSTATUS ( nAttr.setDefault(true) ); aInputDiffuse = nAttr.create( "emitDiffuse", "dn", MFnNumericData::kBoolean); CHECK_MSTATUS ( nAttr.setKeyable(true) ); CHECK_MSTATUS ( nAttr.setStorable(true) ); CHECK_MSTATUS ( nAttr.setHidden(false) ); CHECK_MSTATUS ( nAttr.setDefault(true) ); aInputSpecular = nAttr.create( "emitSpecular", "sn", MFnNumericData::kBoolean); CHECK_MSTATUS ( nAttr.setKeyable(true) ); CHECK_MSTATUS ( nAttr.setStorable(true) ); CHECK_MSTATUS ( nAttr.setHidden(false) ); CHECK_MSTATUS ( nAttr.setDefault(true) ); aIntensity = nAttr.create( "intensity", "i", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setKeyable(true) ); CHECK_MSTATUS ( nAttr.setStorable(true) ); CHECK_MSTATUS ( nAttr.setHidden(false) ); CHECK_MSTATUS ( nAttr.setDefault(1.0f) ); samplingquality = nAttr.create( "samplingquality", "samplingquality", MFnNumericData::kFloat, 1.0); envmap = tAttr.create( "envmap", "envmap", MFnNumericData::kString); tAttr.setUsedAsFilename(true); areamap = tAttr.create( "areamap", "areamap", MFnNumericData::kString); tAttr.setUsedAsFilename(true); areafullsphere = nAttr.create( "areafullsphere", "areafullsphere", MFnNumericData::kBoolean, true); envintensity = nAttr.createColor( "envintensity", "envintensity" ); nAttr.setDefault(1.0f, 1.0f, 1.0f); raybackground = nAttr.create( "raybackground", "raybackground", MFnNumericData::kBoolean, false); castshadow = nAttr.create( "castshadow", "castshadow", MFnNumericData::kBoolean, true); envtype = eAttr.create( "envtype", "envtype", 0, &stat); stat = eAttr.addField( "Direct Lighting", 0 ); stat = eAttr.addField( "Ambient Occlusion", 1 ); stat = eAttr.addField( "Full Irradiance", 2 ); stat = eAttr.addField( "Raytrace Background", 3 ); eAttr.setDefault(0); doraysamples = nAttr.create( "doraysamples", "doraysamples", MFnNumericData::kBoolean, false); doadaptive = nAttr.create( "doadaptive", "doadaptive", MFnNumericData::kBoolean, false); domaxdist = nAttr.create( "domaxdist", "domaxdist", MFnNumericData::kBoolean, false); maxdist = nAttr.create( "maxdist", "maxdist", MFnNumericData::kFloat, 10.0); coneangle = nAttr.create( "coneangle", "coneangle", MFnNumericData::kFloat, 45.0); envtint = nAttr.createColor( "envtint", "envtint" ); nAttr.setDefault(1.0f, 1.0f, 1.0f); shadowI = nAttr.create( "shadowI", "shadowI", MFnNumericData::kFloat, 1.0); samples = nAttr.create( "samples", "samples", MFnNumericData::kInt, 32); MFnStringData fnStringData; MObject defaultObjectMask; defaultObjectMask = fnStringData.create( "*" ); objectmask = tAttr.create( "objectmask", "objectmask", MFnNumericData::kString, defaultObjectMask); usePortalGeometry = nAttr.create( "usePortalGeometry", "usePortalGeometry", MFnNumericData::kBoolean, false); portalGeometry = mAttr.create( "portalGeometry", "portalGeometry"); mAttr.setConnectable(true); mAttr.accepts(MFnData::kAny); // Outputs aLightDirection = nAttr.createPoint( "lightDirection", "ld" ); 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, 0.0f, 0.0f) ); aLightIntensity = nAttr.createColor( "lightIntensity", "li" ); 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, 0.5f, 0.2f) ); aLightAmbient = nAttr.create( "lightAmbient", "la", MFnNumericData::kBoolean); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); nAttr.setDefault(true); aLightDiffuse = nAttr.create( "lightDiffuse", "ldf", MFnNumericData::kBoolean); 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); 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) ); aLightShadowFraction = nAttr.create("lightShadowFraction","lsf", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS ( nAttr.setDefault(0.0f) ); aPreShadowIntensity = nAttr.create("preShadowIntensity","psi", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS ( nAttr.setDefault(0.0f) ); aLightBlindData = nAttr.createAddr("lightBlindData","lbld"); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightData = lAttr.create( "lightData", "ltd", aLightDirection, aLightIntensity, aLightAmbient, aLightDiffuse, aLightSpecular, aLightShadowFraction, aPreShadowIntensity, aLightBlindData); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS ( lAttr.setStorable(false) ); CHECK_MSTATUS ( lAttr.setHidden(true) ); lAttr.setDefault(-1.0f, 0.0f, 0.0f, 1.0f, 0.5f, 0.2f, true, true, true, 0.0f, 1.0f, NULL); CHECK_MSTATUS ( addAttribute(coneangle) ); CHECK_MSTATUS ( addAttribute(samples) ); CHECK_MSTATUS ( addAttribute(objectmask) ); CHECK_MSTATUS ( addAttribute(shadowI) ); CHECK_MSTATUS ( addAttribute(envtint) ); CHECK_MSTATUS ( addAttribute(maxdist) ); CHECK_MSTATUS ( addAttribute(domaxdist) ); CHECK_MSTATUS ( addAttribute(doadaptive) ); CHECK_MSTATUS ( addAttribute(doraysamples) ); CHECK_MSTATUS ( addAttribute(envtype) ); CHECK_MSTATUS ( addAttribute(castshadow) ); CHECK_MSTATUS ( addAttribute(raybackground) ); CHECK_MSTATUS ( addAttribute(envintensity) ); CHECK_MSTATUS ( addAttribute(areafullsphere) ); CHECK_MSTATUS ( addAttribute(areamap) ); CHECK_MSTATUS ( addAttribute(envmap) ); CHECK_MSTATUS ( addAttribute(samplingquality) ); CHECK_MSTATUS ( addAttribute(usePortalGeometry) ); CHECK_MSTATUS ( addAttribute(portalGeometry) ); //CHECK_MSTATUS ( addAttribute(aColor) ); CHECK_MSTATUS ( addAttribute(aLightColor) ); CHECK_MSTATUS ( addAttribute(aShadowColor) ); CHECK_MSTATUS ( addAttribute(aPosition) ); CHECK_MSTATUS ( addAttribute(aInputDirection) ); CHECK_MSTATUS ( addAttribute(aInputAmbient) ); CHECK_MSTATUS ( addAttribute(aInputDiffuse) ); CHECK_MSTATUS ( addAttribute(aInputSpecular) ); CHECK_MSTATUS ( addAttribute(aIntensity) ); CHECK_MSTATUS ( addAttribute(aLightData) ); CHECK_MSTATUS ( attributeAffects (aLightIntensity, aLightData) ); CHECK_MSTATUS ( attributeAffects (aLightDirection, aLightData) ); CHECK_MSTATUS ( attributeAffects (aLightAmbient, aLightData) ); CHECK_MSTATUS ( attributeAffects (aLightDiffuse, aLightData) ); CHECK_MSTATUS ( attributeAffects (aLightSpecular, aLightData) ); CHECK_MSTATUS ( attributeAffects (aLightShadowFraction, aLightData) ); CHECK_MSTATUS ( attributeAffects (aPreShadowIntensity, aLightData) ); CHECK_MSTATUS ( attributeAffects (aLightBlindData, aLightData) ); CHECK_MSTATUS ( attributeAffects (aLightData, aLightData) ); //CHECK_MSTATUS ( attributeAffects (aColor, aLightData) ); CHECK_MSTATUS ( attributeAffects (aPosition, aLightData) ); CHECK_MSTATUS ( attributeAffects (aInputDirection, aLightData) ); CHECK_MSTATUS ( attributeAffects (aInputAmbient, aLightData) ); CHECK_MSTATUS ( attributeAffects (aInputDiffuse, aLightData) ); CHECK_MSTATUS ( attributeAffects (aInputSpecular, aLightData) ); CHECK_MSTATUS ( attributeAffects (aIntensity, aLightData) ); return MS::kSuccess; }
bool DXMAnchor::AddAnchor(MObject& site, const MString& longAnchorName, const MString& shortAnchorName, DXMAnchor* anchor) { DXCC_ASSERT( DXMAnchor::GetAnchor(site, shortAnchorName) == NULL ); DXCC_ASSERT(anchor != NULL); DXCC_ASSERT(anchor->GetSite().isNull()); DXCC_ASSERT(anchor->GetPoint().length() == 0); DXCC_ASSERT(longAnchorName.length() > 0); DXCC_ASSERT(shortAnchorName.length() > 0); DXCC_ASSERT(!site.isNull()); MFnDependencyNode depNode(site); MString name= depNode.name(); #ifdef DEBUG anchor->Name= name.asChar(); #endif if( g_DebugBasic ) { DXCC_DPFA_REPORT("%s", name.asChar()); } //this attribute may exist if you had asked for this node to be duplicated or instanced :( if( depNode.attribute( shortAnchorName ).isNull() ) { MFnNumericAttribute numeric; MObject anchorAttrib= numeric.create(longAnchorName, shortAnchorName, MFnNumericData::kInt, 0); numeric.setReadable(false); numeric.setWritable(false); numeric.setConnectable(false); numeric.setStorable(false); numeric.setCached(true); numeric.setArray(false); numeric.setKeyable(false); numeric.setHidden(true); numeric.setUsedAsColor(false); numeric.setIndeterminant(true); numeric.setRenderSource(false); numeric.setInternal(false); DXCC_ASSERT(!anchorAttrib.isNull()); DXCHECK_MSTATUS( depNode.addAttribute(anchorAttrib) ); } MPlug anchorPlug= depNode.findPlug( shortAnchorName ); DXCC_ASSERT(!anchorPlug.isNull()); anchorPlug.setValue( *reinterpret_cast<int*>(&anchor) ); anchor->AnchorSite= site; anchor->AnchorPoint= shortAnchorName; // anchor->NodeDestroyedCID= MNodeMessage::addNodeDestroyedCallback(site, DXMAnchor::DispatchNodeDestroyed, anchor); // anchor->AboutToDeleteCID= MNodeMessage::addNodeAboutToDeleteCallback(site, DXMAnchor::DispatchAboutToDelete, anchor); anchor->OnPostAddAnchor(longAnchorName, shortAnchorName); return true; }
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 ); }
// // DESCRIPTION: /////////////////////////////////////////////////////// MStatus PhongNode::initialize() { MFnNumericAttribute nAttr; MFnLightDataAttribute lAttr; aTranslucenceCoeff = nAttr.create("translucenceCoeff", "tc", MFnNumericData::kFloat); MAKE_INPUT(nAttr); aDiffuseReflectivity = nAttr.create("diffuseReflectivity", "drfl", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS ( nAttr.setDefault(0.8f) ); aColor = nAttr.createColor( "color", "c" ); MAKE_INPUT(nAttr); CHECK_MSTATUS ( nAttr.setDefault(0.0f, 0.58824f, 0.644f) ); aIncandescence = nAttr.createColor( "incandescence", "ic" ); MAKE_INPUT(nAttr); aOutColor = nAttr.createColor( "outColor", "oc" ); MAKE_OUTPUT(nAttr); aPointCamera = nAttr.createPoint( "pointCamera", "pc" ); MAKE_INPUT(nAttr); CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); aPower = nAttr.create( "power", "pow", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS ( nAttr.setMin(0.0f) ); CHECK_MSTATUS ( nAttr.setMax(200.0f) ); CHECK_MSTATUS ( nAttr.setDefault(10.0f) ); aSpecularity = nAttr.create( "specularity", "spc", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS ( nAttr.setMin(0.0f) ); CHECK_MSTATUS ( nAttr.setMax(1.0f) ) ; CHECK_MSTATUS ( nAttr.setDefault(0.5f) ); aReflectGain = nAttr.create( "reflectionGain", "rg", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS ( nAttr.setMin(0.0f) ); CHECK_MSTATUS ( nAttr.setMax(1.0f) ); CHECK_MSTATUS ( nAttr.setDefault(0.5f) ); aNormalCamera = nAttr.createPoint( "normalCamera", "n" ); MAKE_INPUT(nAttr); CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); aTriangleNormalCamera = nAttr.createPoint( "triangleNormalCamera", "tn" ); MAKE_INPUT(nAttr); CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f)); CHECK_MSTATUS ( nAttr.setHidden(true)); aLightDirection = nAttr.createPoint( "lightDirection", "ld" ); 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) ); aLightIntensity = nAttr.createColor( "lightIntensity", "li" ); 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) ); aLightAmbient = nAttr.create( "lightAmbient", "la", MFnNumericData::kBoolean); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); aLightDiffuse = nAttr.create( "lightDiffuse", "ldf", MFnNumericData::kBoolean); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightSpecular = nAttr.create( "lightSpecular", "ls", MFnNumericData::kBoolean); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightShadowFraction = nAttr.create("lightShadowFraction", "lsf", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aPreShadowIntensity = nAttr.create("preShadowIntensity", "psi", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(false) ); aLightBlindData = nAttr.createAddr("lightBlindData", "lbld"); 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); 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, 0.0f, 1.0f, NULL) ); // rayOrigin MObject RayX = nAttr.create( "rayOx", "rxo", MFnNumericData::kFloat, 0.0 ); MObject RayY = nAttr.create( "rayOy", "ryo", MFnNumericData::kFloat, 0.0 ); MObject RayZ = nAttr.create( "rayOz", "rzo", MFnNumericData::kFloat, 0.0 ); aRayOrigin = nAttr.create( "rayOrigin", "rog", RayX, RayY, RayZ ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(false) ); // rayDirection RayX = nAttr.create( "rayDirectionX", "rdx", MFnNumericData::kFloat, 1.0 ); RayY = nAttr.create( "rayDirectionY", "rdy", MFnNumericData::kFloat, 0.0 ); RayZ = nAttr.create( "rayDirectionZ", "rdz", MFnNumericData::kFloat, 0.0 ); aRayDirection = nAttr.create( "rayDirection", "rad", RayX, RayY, RayZ ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(false) ); // objectId aObjectId = nAttr.createAddr( "objectId", "oi" ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(false) ); // raySampler aRaySampler = nAttr.createAddr("raySampler", "rtr"); CHECK_MSTATUS ( nAttr.setStorable(false)); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(false) ); // rayDepth aRayDepth = nAttr.create( "rayDepth", "rd", MFnNumericData::kShort, 0.0 ); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS (nAttr.setHidden(true) ) ; CHECK_MSTATUS ( nAttr.setReadable(false) ); CHECK_MSTATUS ( addAttribute(aTranslucenceCoeff) ); CHECK_MSTATUS ( addAttribute(aDiffuseReflectivity) ); CHECK_MSTATUS ( addAttribute(aColor) ); CHECK_MSTATUS ( addAttribute(aIncandescence) ); CHECK_MSTATUS ( addAttribute(aPointCamera) ); CHECK_MSTATUS ( addAttribute(aNormalCamera) ); CHECK_MSTATUS ( addAttribute(aTriangleNormalCamera) ); CHECK_MSTATUS ( addAttribute(aLightData) ); CHECK_MSTATUS ( addAttribute(aPower) ); CHECK_MSTATUS ( addAttribute(aSpecularity) ); CHECK_MSTATUS ( addAttribute(aOutColor) ); CHECK_MSTATUS ( addAttribute(aRayOrigin) ); CHECK_MSTATUS ( addAttribute(aRayDirection) ); CHECK_MSTATUS ( addAttribute(aObjectId) ); CHECK_MSTATUS ( addAttribute(aRaySampler) ); CHECK_MSTATUS ( addAttribute(aRayDepth) ); CHECK_MSTATUS ( addAttribute(aReflectGain) ); CHECK_MSTATUS ( attributeAffects (aTranslucenceCoeff, aOutColor)); CHECK_MSTATUS ( attributeAffects (aDiffuseReflectivity, aOutColor)); CHECK_MSTATUS ( attributeAffects (aLightIntensity, aOutColor)); CHECK_MSTATUS ( attributeAffects (aIncandescence, aOutColor)); CHECK_MSTATUS ( attributeAffects (aPointCamera, aOutColor)); CHECK_MSTATUS ( attributeAffects (aNormalCamera, aOutColor)); CHECK_MSTATUS ( attributeAffects (aTriangleNormalCamera, aOutColor)); CHECK_MSTATUS ( attributeAffects (aLightData, aOutColor)); CHECK_MSTATUS ( attributeAffects (aLightAmbient, aOutColor)); CHECK_MSTATUS ( attributeAffects (aLightSpecular, aOutColor)); CHECK_MSTATUS ( attributeAffects (aLightDiffuse, aOutColor)); CHECK_MSTATUS ( attributeAffects (aLightDirection, aOutColor)); CHECK_MSTATUS ( attributeAffects (aLightShadowFraction, aOutColor)); CHECK_MSTATUS ( attributeAffects (aPreShadowIntensity, aOutColor)); CHECK_MSTATUS ( attributeAffects (aLightBlindData, aOutColor)); CHECK_MSTATUS ( attributeAffects (aPower, aOutColor)); CHECK_MSTATUS ( attributeAffects (aSpecularity, aOutColor)); CHECK_MSTATUS ( attributeAffects (aColor, aOutColor)); CHECK_MSTATUS ( attributeAffects (aRayOrigin,aOutColor)); CHECK_MSTATUS ( attributeAffects (aRayDirection,aOutColor)); CHECK_MSTATUS ( attributeAffects (aObjectId,aOutColor)); CHECK_MSTATUS ( attributeAffects (aRaySampler,aOutColor)); CHECK_MSTATUS ( attributeAffects (aRayDepth,aOutColor)); CHECK_MSTATUS ( attributeAffects (aReflectGain,aOutColor) ); return MS::kSuccess; }