MStatus bruiseMapNode::initialize() { MStatus status; MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; aBias = nAttr.create("bias", "bs", MFnNumericData::kFloat, 0.1f, &status); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable(true)); CHECK_MSTATUS( nAttr.setKeyable(true)); CHECK_MSTATUS( nAttr.setMin(0.f)); amapsize = nAttr.create( "mapsize", "mapsize", MFnNumericData::kInt, 1024 ); nAttr.setStorable(false); nAttr.setKeyable(false); addAttribute( amapsize ); auvset = tAttr.create("uvset", "uv", MFnData::kString, MObject::kNullObj, &status); CHECK_MSTATUS( status ); CHECK_MSTATUS( tAttr.setStorable(true)); CHECK_MSTATUS( tAttr.setKeyable(false)); tAttr.setCached( true ); tAttr.setInternal( true ); zWorks::createMatrixAttr(aworldSpace, "worldSpace", "ws"); aoutput = nAttr.create( "outval", "ov", MFnNumericData::kInt, 1 ); nAttr.setStorable(false); nAttr.setWritable(false); nAttr.setKeyable(false); addAttribute( aoutput ); zWorks::createTypedAttr(agrowth, MString("growMesh"), MString("gm"), MFnData::kMesh); zCheckStatus(addAttribute(agrowth), "ERROR adding grow mesh"); zWorks::createTypedAttr(aguide, MString("guideMesh"), MString("gdm"), MFnData::kMesh); zCheckStatus(addAttribute(aguide), "ERROR adding grow mesh"); astartframe = nAttr.create( "startFrame", "sf", MFnNumericData::kInt, 1 ); nAttr.setStorable(true); nAttr.setKeyable(true); addAttribute( astartframe ); zWorks::createTimeAttr(acurrenttime, MString("currentTime"), MString("ct"), 1.0); zCheckStatus(addAttribute(acurrenttime), "ERROR adding time"); asavemap = nAttr.create( "saveMap", "sm", MFnNumericData::kInt, 0); nAttr.setStorable(false); nAttr.setKeyable(true); addAttribute(asavemap); CHECK_MSTATUS( addAttribute(aBias)); CHECK_MSTATUS( addAttribute(auvset)); addAttribute(aworldSpace); attributeAffects( aBias, aoutput ); attributeAffects( amapsize, aoutput ); attributeAffects( agrowth, aoutput ); attributeAffects( astartframe, aoutput ); attributeAffects( acurrenttime, aoutput ); attributeAffects( aguide, aoutput ); attributeAffects( asavemap, aoutput ); return MS::kSuccess; }
MStatus liqDisplacementNode::initialize() { MFnTypedAttribute tAttr; MFnStringData tDefault; MFnNumericAttribute nAttr; MFnMessageAttribute mAttr; MFnEnumAttribute eAttr; MStatus status; // Create input attributes aRmanShader = tAttr.create( MString("rmanShader"), MString("rms"), MFnData::kString, aRmanShader, &status ); MAKE_INPUT(tAttr); aRmanShaderLong = tAttr.create( MString("rmanShaderLong"), MString("rml"), MFnData::kString, aRmanShaderLong, &status ); MAKE_INPUT(tAttr); aRmanShaderLif = tAttr.create( MString("rmanShaderLif"), MString("lif"), MFnData::kString, aRmanShaderLif, &status ); MAKE_INPUT(tAttr); aRmanParams = tAttr.create( MString("rmanParams"), MString("rpr"), MFnData::kStringArray, aRmanParams, &status ); MAKE_INPUT(tAttr); aRmanDetails = tAttr.create( MString("rmanDetails"), MString("rdt"), MFnData::kStringArray, aRmanDetails, &status ); MAKE_INPUT(tAttr); aRmanTypes = tAttr.create( MString("rmanTypes"), MString("rty"), MFnData::kStringArray, aRmanTypes, &status ); MAKE_INPUT(tAttr); aRmanDefaults = tAttr.create( MString("rmanDefaults"), MString("rdf"), MFnData::kStringArray, aRmanDefaults, &status ); MAKE_INPUT(tAttr); aRmanArraySizes = tAttr.create( MString("rmanArraySizes"), MString("ras"), MFnData::kIntArray, aRmanArraySizes, &status ); MAKE_INPUT(tAttr); aRmanLifCmds = tAttr.create( MString("rmanLifCmds"), MString("rlc"), MFnData::kStringArray, aRmanLifCmds, &status ); MAKE_INPUT(tAttr); aPreviewPrimitive = eAttr.create( "previewPrimitive", "pvp", 7, &status ); eAttr.addField( "Sphere", 0 ); eAttr.addField( "Cube", 1 ); eAttr.addField( "Cylinder", 2 ); eAttr.addField( "Torus", 3 ); eAttr.addField( "Plane", 4 ); eAttr.addField( "Teapot", 5 ); eAttr.addField( "Custom", 6 ); eAttr.addField( "(globals)",7 ); MAKE_NONKEYABLE_INPUT(eAttr); CHECK_MSTATUS(eAttr.setConnectable(false)); aPreviewCustomPrimitive = tAttr.create( MString("previewCustomPrimitive"), MString("pcp"), MFnData::kString, aPreviewCustomPrimitive, &status ); MAKE_INPUT(tAttr); aPreviewCustomBackplane = tAttr.create( MString("previewCustomBackplane"), MString("pcb"), MFnData::kString, aPreviewCustomBackplane, &status ); MAKE_INPUT(tAttr); aPreviewObjectSize = nAttr.create("previewObjectSize", "pos", MFnNumericData::kDouble, 1.0, &status); MAKE_NONKEYABLE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setConnectable(false)); aPreviewPixelSamples = nAttr.create("previewPixelSamples", "pxs", MFnNumericData::kInt, 3, &status); MAKE_NONKEYABLE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setConnectable(false)); aPreviewShadingRate = nAttr.create("previewShadingRate", "psr", MFnNumericData::kDouble, 1.0, &status); MAKE_NONKEYABLE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setConnectable(false)); aPreviewBackplane = nAttr.create("previewBackplane", "pbp", MFnNumericData::kBoolean, true, &status); MAKE_NONKEYABLE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setConnectable(false)); aShaderSpace = tAttr.create( MString("shaderSpace"), MString("ssp"), MFnData::kString, aShaderSpace, &status ); MAKE_INPUT(tAttr); aDisplacementBound = nAttr.create("displacementBound", "db", MFnNumericData::kDouble, 0.0, &status); MAKE_INPUT(nAttr); MObject defaultSpaceObj = tDefault.create( MString("shader"), &status); aDisplacementBoundSpace = tAttr.create( MString("displacementBoundSpace"), MString("dbs"), MFnData::kString, defaultSpaceObj, &status ); MAKE_INPUT(tAttr); aOutputInShadow = nAttr.create("outputInShadow", "ois", MFnNumericData::kBoolean, 0.0, &status); MAKE_NONKEYABLE_INPUT(nAttr); // refreshPreview must be true to allow refresh aRefreshPreview = nAttr.create("refreshPreview", "rfp", MFnNumericData::kBoolean, 0.0, &status); MAKE_NONKEYABLE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setHidden(true)); // Create output attributes aDisplacement = nAttr.create("displacement", "d", MFnNumericData::kFloat, 0.0, &status); MAKE_OUTPUT(nAttr); aOutColor = nAttr.createColor("outColor", "oc"); MAKE_OUTPUT(nAttr); aAssignedObjects = mAttr.create("liqAssignedObjects", "ao"); MAKE_OUTPUT(mAttr); CHECK_MSTATUS(addAttribute(aRmanShader)); CHECK_MSTATUS(addAttribute(aRmanShaderLong)); CHECK_MSTATUS(addAttribute(aRmanShaderLif)); CHECK_MSTATUS(addAttribute(aRmanParams)); CHECK_MSTATUS(addAttribute(aRmanDetails)); CHECK_MSTATUS(addAttribute(aRmanTypes)); CHECK_MSTATUS(addAttribute(aRmanDefaults)); CHECK_MSTATUS(addAttribute(aRmanArraySizes)); CHECK_MSTATUS(addAttribute(aRmanLifCmds)); CHECK_MSTATUS(addAttribute(aPreviewPrimitive)); CHECK_MSTATUS(addAttribute(aPreviewCustomPrimitive)); CHECK_MSTATUS(addAttribute(aPreviewCustomBackplane)); CHECK_MSTATUS(addAttribute(aPreviewObjectSize)); CHECK_MSTATUS(addAttribute(aPreviewPixelSamples)); CHECK_MSTATUS(addAttribute(aPreviewShadingRate)); CHECK_MSTATUS(addAttribute(aPreviewBackplane)); CHECK_MSTATUS(addAttribute(aShaderSpace)); CHECK_MSTATUS(addAttribute(aDisplacementBound)); CHECK_MSTATUS(addAttribute(aDisplacementBoundSpace)); CHECK_MSTATUS(addAttribute(aOutputInShadow)); CHECK_MSTATUS(addAttribute(aRefreshPreview)); CHECK_MSTATUS(addAttribute(aAssignedObjects)); CHECK_MSTATUS(addAttribute(aDisplacement)); CHECK_MSTATUS(addAttribute(aOutColor)); CHECK_MSTATUS(attributeAffects(aRmanShaderLong, aDisplacement)); CHECK_MSTATUS(attributeAffects(aRmanShaderLif, aDisplacement)); return MS::kSuccess; }
void defineAttributes() { addAttribute("test", 5, "5,6,8"); }
/************************************************ Function: extractRequestActionToAOS Parameters: const xacml_request_t request Description: This function extracts the Action information details from the request and puts that into the EEF AOS. Return: 0 : good !0 : bad ************************************************/ int extractRequestActionToAOS (const xacml_request_t request) { int rc; size_t i; size_t count; const char * attribute_id; const char * data_type; const char * issuer; const char * value; /*char * logstr = "extractRequestActionToAOS";*/ aos_context_t* aos_context = NULL; aos_attribute_t* aos_attribute = NULL; rc = xacml_request_get_action_attribute_count(request, &count); if (count > 0) { rewindContexts(); if((aos_context = getNextContext(ACTION, NULL)) == NULL){ if((aos_context = createContext (ACTION)) == NULL){ return 1; } } /* aos_context should be set now */ } for (i = 0 ; i < count; i++) { attribute_id = NULL; data_type = NULL; issuer = NULL; value = NULL; rc = xacml_request_get_action_attribute( request, i, &attribute_id, &data_type, &issuer, &value); /* EEF AOS magic */ /*fprintf (stderr, "aos_set_string (\"%s\", \"%s\")\n", attribute_id, (char *) value);*/ /* aos_set_string (attribute_id, (char *) value); */ if (aos_context){ if((aos_attribute = createAttribute())){ setAttributeId (aos_attribute, attribute_id); setAttributeIssuer(aos_attribute, issuer); setAttributeType (aos_attribute, data_type); setAttributeValue (aos_attribute, value, strlen(value) + 1); addAttribute(aos_context, aos_attribute); } } } if(aos_context){ addContext (aos_context); } return 0; }
MStatus transCircle::initialize() { MFnNumericAttribute nAttr; MStatus stat; input = nAttr.create( "input", "in", MFnNumericData::kDouble, 0.0 ); nAttr.setStorable(true); inputTranslateX = nAttr.create( "inputTranslateX", "itX", MFnNumericData::kDouble, 0.0 ); nAttr.setStorable(true); inputTranslateY = nAttr.create( "inputTranslateY", "itY", MFnNumericData::kDouble, 0.0 ); nAttr.setStorable(true); inputTranslateZ = nAttr.create( "inputTranslateZ", "itZ", MFnNumericData::kDouble, 0.0 ); nAttr.setStorable(true); inputTranslate = nAttr.create( "inputTranslate", "it", inputTranslateX, inputTranslateY, inputTranslateZ ); nAttr.setStorable(true); nAttr.setDefault(0.0,0.0,0.0); outputTranslateX = nAttr.create( "outputTranslateX", "otX", MFnNumericData::kDouble, 0.0 ); nAttr.setWritable(false); nAttr.setStorable(true); outputTranslateY = nAttr.create( "outputTranslateY", "otY", MFnNumericData::kDouble, 0.0 ); nAttr.setWritable(false); nAttr.setStorable(true); outputTranslateZ = nAttr.create( "outputTranslateZ", "otZ", MFnNumericData::kDouble, 0.0 ); nAttr.setWritable(false); nAttr.setStorable(true); outputTranslate = nAttr.create( "outputTranslate", "ot", outputTranslateX, outputTranslateY, outputTranslateZ ); nAttr.setWritable(false); nAttr.setStorable(true); nAttr.setDefault(0.0,0.0,0.0); scale = nAttr.create( "scale", "sc", MFnNumericData::kDouble, 10.0 ); nAttr.setStorable(true); frames = nAttr.create( "frames", "fr", MFnNumericData::kDouble, 48.0 ); nAttr.setStorable(true); stat = addAttribute( inputTranslate ); if (!stat) { stat.perror("addAttribute"); return stat; } stat = addAttribute( input ); if (!stat) { stat.perror("addAttribute"); return stat; } stat = addAttribute( scale ); if (!stat) { stat.perror("addAttribute"); return stat; } stat = addAttribute( frames ); if (!stat) { stat.perror("addAttribute"); return stat; } stat = addAttribute( outputTranslate ); if (!stat) { stat.perror("addAttribute"); return stat; } stat = attributeAffects( inputTranslateX, outputTranslateX ); if (!stat) { stat.perror("attributeAffects"); return stat; } stat = attributeAffects( inputTranslateY, outputTranslateY ); if (!stat) { stat.perror("attributeAffects"); return stat; } stat = attributeAffects( inputTranslateZ, outputTranslateZ ); if (!stat) { stat.perror("attributeAffects"); return stat; } stat = attributeAffects( inputTranslate, outputTranslateX ); if (!stat) { stat.perror("attributeAffects"); return stat; } stat = attributeAffects( inputTranslate, outputTranslateY ); if (!stat) { stat.perror("attributeAffects"); return stat; } stat = attributeAffects( inputTranslate, outputTranslateZ ); if (!stat) { stat.perror("attributeAffects"); return stat; } stat = attributeAffects( inputTranslate, outputTranslate ); if (!stat) { stat.perror("attributeAffects"); return stat; } stat = attributeAffects( input, outputTranslateX ); if (!stat) { stat.perror("attributeAffects"); return stat; } stat = attributeAffects( input, outputTranslateY ); if (!stat) { stat.perror("attributeAffects"); return stat; } stat = attributeAffects( scale, outputTranslateX ); if (!stat) { stat.perror("attributeAffects"); return stat; } stat = attributeAffects( scale, outputTranslateY ); if (!stat) { stat.perror("attributeAffects"); return stat; } stat = attributeAffects( frames, outputTranslateX ); if (!stat) { stat.perror("attributeAffects"); return stat; } stat = attributeAffects( frames, outputTranslateY ); if (!stat) { stat.perror("attributeAffects"); return stat; } return MS::kSuccess; }
// // DESCRIPTION: MStatus marble::initialize() { MFnNumericAttribute nAttr; MFnTypedAttribute tAttr; MFnGenericAttribute gAttr; MFnEnumAttribute eAttr; MFnMessageAttribute mAttr; MStatus status; outColor = nAttr.createColor("outColor", "outColor"); MAKE_OUTPUT(nAttr); CHECK_MSTATUS(addAttribute( outColor )); //---------------------------- automatically created attributes start ------------------------------------ scale = nAttr.create("scale", "scale", MFnNumericData::kFloat, 1); MAKE_INPUT(nAttr); CHECK_MSTATUS(addAttribute( scale )); octaves = nAttr.create("octaves", "octaves", MFnNumericData::kInt, 8); MAKE_INPUT(nAttr); CHECK_MSTATUS(addAttribute( octaves )); coordinates = eAttr.create("coordinates", "coordinates", 0, &status); status = eAttr.addField( "global", 0 ); status = eAttr.addField( "local", 1 ); status = eAttr.addField( "global normal", 2 ); status = eAttr.addField( "localnormal", 3 ); status = eAttr.addField( "uv", 4 ); MAKE_INPUT(eAttr); CHECK_MSTATUS(addAttribute( coordinates )); roughness = nAttr.create("roughness", "roughness", MFnNumericData::kFloat, 0.5); MAKE_INPUT(nAttr); CHECK_MSTATUS(addAttribute( roughness )); MObject rotateX = nAttr.create("rotateX", "rotatex", MFnNumericData::kDouble, 0.0); MObject rotateY = nAttr.create("rotateY", "rotatey", MFnNumericData::kDouble, 0.0); MObject rotateZ = nAttr.create("rotateZ", "rotatez", MFnNumericData::kDouble, 0.0); rotate = nAttr.create("rotate", "rotate", rotateX, rotateY, rotateZ); MAKE_INPUT(nAttr); nAttr.setDefault(0,0,0); CHECK_MSTATUS(addAttribute( rotate )); variation = nAttr.create("variation", "variation", MFnNumericData::kFloat, 0.2); MAKE_INPUT(nAttr); CHECK_MSTATUS(addAttribute( variation )); MObject translateX = nAttr.create("translateX", "translatex", MFnNumericData::kDouble, 0.0); MObject translateY = nAttr.create("translateY", "translatey", MFnNumericData::kDouble, 0.0); MObject translateZ = nAttr.create("translateZ", "translatez", MFnNumericData::kDouble, 0.0); translate = nAttr.create("translate", "translate", translateX, translateY, translateZ); MAKE_INPUT(nAttr); nAttr.setDefault(0,0,0); CHECK_MSTATUS(addAttribute( translate )); luxOutColor = nAttr.createColor("luxOutColor", "luxOutColor"); MAKE_OUTPUT(nAttr); CHECK_MSTATUS(addAttribute( luxOutColor )); CHECK_MSTATUS ( attributeAffects( scale, luxOutColor)); CHECK_MSTATUS ( attributeAffects( scale, outColor)); //---------------------------- automatically created attributes end ------------------------------------ return MS::kSuccess; }
/************************************************ Function: extractRequestResourceToAOS Parameters: const xacml_request_t request Description: This function extracts the Action information details from the request and puts that into the EEF AOS Return: 0 : good !0 : bad ************************************************/ int extractRequestResourceToAOS (const xacml_request_t request) { int rc; size_t i; size_t j; size_t count; const char * attribute_id; const char * data_type; const char * issuer; const char * value; xacml_resource_attribute_t resource_attribute = NULL; size_t resource_attr_count = 0; /*const char * logstr = "extractRequestResourceToAOS";*/ aos_context_t* aos_context = NULL; aos_attribute_t* aos_attribute = NULL; rc = xacml_request_get_resource_attribute_count(request, &resource_attr_count); for (i = 0 ; i < resource_attr_count; i++) { rc = xacml_request_get_resource_attribute( request, i, &resource_attribute); if (resource_attribute) { rc = xacml_resource_attribute_get_count( resource_attribute, &count); if((aos_context = createContext (RESOURCE)) == NULL){ return 1; } /* aos_context should be set now */ for (j = 0; j < count; j++) { attribute_id = NULL; data_type = NULL; issuer = NULL; value = NULL; rc = xacml_resource_attribute_get_attribute( resource_attribute, j, &attribute_id, &data_type, &issuer, &value); /* EEF AOS magic */ /*fprintf (stderr, "aos_set_string (\"%s\", \"%s\")\n", attribute_id, (char *) value);*/ /* aos_set_string (attribute_id, (char *) value); */ if (aos_context){ if((aos_attribute = createAttribute())){ setAttributeId (aos_attribute, attribute_id); setAttributeIssuer(aos_attribute, issuer); setAttributeType (aos_attribute, data_type); setAttributeValue (aos_attribute, value, strlen(value) + 1); addAttribute(aos_context, aos_attribute); aos_attribute = NULL; } } } if(aos_context){ addContext (aos_context); aos_context = NULL; } } } return 0; }
// add some additional inputs MStatus HRBFSkinCluster::initialize() { std::cout << "called initialize" << std::endl; MFnNumericAttribute numAttr; MFnTypedAttribute typedAttr; //MFnCompoundAttribute cmpdAttr; MStatus returnStatus; HRBFSkinCluster::rebuildHRBF = numAttr.create("RebuildHRBF", "rbld", MFnNumericData::kInt, 0, &returnStatus); McheckErr(returnStatus, "ERROR creating rbld attribute\n"); returnStatus = addAttribute(HRBFSkinCluster::rebuildHRBF); McheckErr(returnStatus, "ERROR adding rbld attribute\n"); HRBFSkinCluster::exportComposition = numAttr.create("ExportComp", "exprtC", MFnNumericData::kInt, 0, &returnStatus); McheckErr(returnStatus, "ERROR creating exprtC attribute\n"); returnStatus = addAttribute(HRBFSkinCluster::exportComposition); McheckErr(returnStatus, "ERROR adding exprtC attribute\n"); HRBFSkinCluster::exportHRBFSamples = typedAttr.create("ExportHRBFs", "exprtS", MFnNumericData::kString, &returnStatus); McheckErr(returnStatus, "ERROR creating exprtS attribute\n"); returnStatus = addAttribute(HRBFSkinCluster::exportHRBFSamples); McheckErr(returnStatus, "ERROR adding exprtS attribute\n"); HRBFSkinCluster::exportHRBFValues = typedAttr.create("ExportHRBFv", "exprtV", MFnNumericData::kString, &returnStatus); McheckErr(returnStatus, "ERROR creating exprtV attribute\n"); returnStatus = addAttribute(HRBFSkinCluster::exportHRBFValues); McheckErr(returnStatus, "ERROR adding exprtV attribute\n"); HRBFSkinCluster::useDQ = numAttr.create("UseDualQuaternions", "useDQ", MFnNumericData::kInt, 0, &returnStatus); McheckErr(returnStatus, "ERROR creating useDQ attribute\n"); returnStatus = addAttribute(HRBFSkinCluster::useDQ); McheckErr(returnStatus, "ERROR adding useDQ attribute\n"); HRBFSkinCluster::useHRBF = numAttr.create("UseHRBFCorrection", "useHRBF", MFnNumericData::kInt, 0, &returnStatus); McheckErr(returnStatus, "ERROR creating useHRBF attribute\n"); returnStatus = addAttribute(HRBFSkinCluster::useHRBF); McheckErr(returnStatus, "ERROR adding useHRBF attribute\n"); HRBFSkinCluster::checkHRBFAt = numAttr.create("checkHRBFAt", "chkHRBF", MFnNumericData::k3Double, 0, &returnStatus); McheckErr(returnStatus, "ERROR creating checkHRBFAt attribute\n"); returnStatus = addAttribute(HRBFSkinCluster::checkHRBFAt); McheckErr(returnStatus, "ERROR adding checkHRBFAt attribute\n"); // hierarchy information // http://download.autodesk.com/us/maya/2011help/API/weight_list_node_8cpp-example.html#a15 HRBFSkinCluster::jointParentIdcs = numAttr.create("parentJointIDCS", "pJIDCS", MFnNumericData::kInt, 0, &returnStatus); McheckErr(returnStatus, "ERROR creating pIDCS attribute\n"); numAttr.setArray(true); returnStatus = addAttribute(HRBFSkinCluster::jointParentIdcs); McheckErr(returnStatus, "ERROR adding pIDCS attribute\n"); // joint names HRBFSkinCluster::jointNames = typedAttr.create("jointNames", "jNms", MFnData::kString, &returnStatus); McheckErr(returnStatus, "ERROR creating pIDCS attribute\n"); typedAttr.setArray(true); returnStatus = addAttribute(HRBFSkinCluster::jointNames); McheckErr(returnStatus, "ERROR adding jNms attribute\n"); // set up affects returnStatus = attributeAffects(HRBFSkinCluster::rebuildHRBF, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with rebuildHRBF\n"); returnStatus = attributeAffects(HRBFSkinCluster::exportComposition, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with exportComposition\n"); returnStatus = attributeAffects(HRBFSkinCluster::exportHRBFSamples, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with exportHRBFSamples\n"); returnStatus = attributeAffects(HRBFSkinCluster::exportHRBFValues, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with exportHRBFValues\n"); returnStatus = attributeAffects(HRBFSkinCluster::useDQ, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with useDQ\n"); returnStatus = attributeAffects(HRBFSkinCluster::useHRBF, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with useHRBF\n"); returnStatus = attributeAffects(HRBFSkinCluster::jointParentIdcs, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with jointParentIdcs\n"); returnStatus = attributeAffects(HRBFSkinCluster::checkHRBFAt, HRBFSkinCluster::outputGeom); McheckErr(returnStatus, "ERROR in attributeAffects with checkHRBFAt\n"); return returnStatus; }
MStatus CoronaSurface::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 ------------------------------------ emissionExponent = nAttr.create("emissionExponent", "emissionExponent", MFnNumericData::kFloat, 0.0); CHECK_MSTATUS(addAttribute( emissionExponent )); fresnelIor = nAttr.create("fresnelIor", "fresnelIor", MFnNumericData::kFloat, 1.0); CHECK_MSTATUS(addAttribute( fresnelIor )); roundCornersSamples = nAttr.create("roundCornersSamples", "roundCornersSamples", MFnNumericData::kInt, 10); CHECK_MSTATUS(addAttribute( roundCornersSamples )); emissionSharpnessFake = nAttr.create("emissionSharpnessFake", "emissionSharpnessFake", MFnNumericData::kBoolean, false); CHECK_MSTATUS(addAttribute( emissionSharpnessFake )); attenuationColor = nAttr.createColor("attenuationColor", "attenuationColor"); nAttr.setDefault(0,0,0); CHECK_MSTATUS(addAttribute( attenuationColor )); glassMode = eAttr.create("glassMode", "glassMode", 0, &status); status = eAttr.addField( "OneSided", 0 ); status = eAttr.addField( "TwoSided", 1 ); status = eAttr.addField( "Hybrid", 2 ); CHECK_MSTATUS(addAttribute( glassMode )); reflectivity = nAttr.createColor("reflectivity", "reflectivity"); nAttr.setDefault(0,0,0); CHECK_MSTATUS(addAttribute( reflectivity )); translucency = nAttr.createColor("translucency", "translucency"); nAttr.setDefault(0,0,0); CHECK_MSTATUS(addAttribute( translucency )); volumeEmissionColor = nAttr.createColor("volumeEmissionColor", "volumeEmissionColor"); nAttr.setDefault(0,0,0); CHECK_MSTATUS(addAttribute( volumeEmissionColor )); anisotropyRotation = nAttr.create("anisotropyRotation", "anisotropyRotation", MFnNumericData::kFloat, 0.0); CHECK_MSTATUS(addAttribute( anisotropyRotation )); reflectionGlossiness = nAttr.create("reflectionGlossiness", "reflectionGlossiness", MFnNumericData::kFloat, 1.0); CHECK_MSTATUS(addAttribute( reflectionGlossiness )); volumeEmissionDist = nAttr.create("volumeEmissionDist", "volumeEmissionDist", MFnNumericData::kFloat, 0.0); CHECK_MSTATUS(addAttribute( volumeEmissionDist )); roundCornersRadius = nAttr.create("roundCornersRadius", "roundCornersRadius", MFnNumericData::kFloat, 0.0); CHECK_MSTATUS(addAttribute( roundCornersRadius )); refractionGlossiness = nAttr.create("refractionGlossiness", "refractionGlossiness", MFnNumericData::kFloat, 1.0); CHECK_MSTATUS(addAttribute( refractionGlossiness )); diffuse = nAttr.createColor("diffuse", "diffuse"); nAttr.setDefault(0.7,0.7,0.7); CHECK_MSTATUS(addAttribute( diffuse )); refractivity = nAttr.createColor("refractivity", "refractivity"); nAttr.setDefault(0,0,0); CHECK_MSTATUS(addAttribute( refractivity )); brdfType = eAttr.create("brdfType", "brdfType", 0, &status); status = eAttr.addField( "Phong", 0 ); status = eAttr.addField( "Ward", 1 ); status = eAttr.addField( "Ashikmin", 2 ); status = eAttr.addField( "Fake Ward", 3 ); CHECK_MSTATUS(addAttribute( brdfType )); emissionColor = nAttr.createColor("emissionColor", "emissionColor"); nAttr.setDefault(0,0,0); CHECK_MSTATUS(addAttribute( emissionColor )); anisotropy = nAttr.create("anisotropy", "anisotropy", MFnNumericData::kFloat, 0.5); CHECK_MSTATUS(addAttribute( anisotropy )); refractionIndex = nAttr.create("refractionIndex", "refractionIndex", MFnNumericData::kFloat, 1.2); CHECK_MSTATUS(addAttribute( refractionIndex )); emissionDisableSampling = nAttr.create("emissionDisableSampling", "emissionDisableSampling", MFnNumericData::kBoolean, false); CHECK_MSTATUS(addAttribute( emissionDisableSampling )); attenuationDist = nAttr.create("attenuationDist", "attenuationDist", MFnNumericData::kFloat, 0.0); CHECK_MSTATUS(addAttribute( attenuationDist )); //---------------------------- 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 ); }
MStatus AlembicNode::initialize() { MStatus status; MFnUnitAttribute uAttr; MFnTypedAttribute tAttr, tAttr2; MFnNumericAttribute nAttr; MFnGenericAttribute gAttr; MFnEnumAttribute eAttr; // add the input attributes: time, file, sequence time mTimeAttr = uAttr.create("time", "tm", MFnUnitAttribute::kTime, 0.0); status = uAttr.setStorable(true); status = addAttribute(mTimeAttr); // input file name MFnStringData fileFnStringData; MObject fileNameDefaultObject = fileFnStringData.create(""); mAbcFileNameAttr = tAttr.create("abc_File", "fn", MFnData::kString, fileNameDefaultObject); status = tAttr.setStorable(true); status = tAttr.setUsedAsFilename(true); status = addAttribute(mAbcFileNameAttr); // input layer file names MFnStringArrayData fileFnStringArrayData; MStringArray dummyStringArray; MObject layerFileNamesDefaultObject = fileFnStringArrayData.create(dummyStringArray); mAbcLayerFileNamesAttr = tAttr2.create("abc_layerFiles", "fns", MFnData::kStringArray, layerFileNamesDefaultObject); status = tAttr2.setStorable(true); status = tAttr2.setUsedAsFilename(true); status = tAttr2.setKeyable(false); status = tAttr2.setWritable(true); status = addAttribute(mAbcLayerFileNamesAttr); // playback speed mSpeedAttr = nAttr.create("speed", "sp", MFnNumericData::kDouble, 1.0, &status); status = nAttr.setWritable(true); status = nAttr.setStorable(true); status = nAttr.setKeyable(true); status = addAttribute(mSpeedAttr); // frame offset mOffsetAttr = nAttr.create("offset", "of", MFnNumericData::kDouble, 0, &status); status = nAttr.setWritable(true); status = nAttr.setStorable(true); status = nAttr.setKeyable(true); status = addAttribute(mOffsetAttr); // cycle type mCycleTypeAttr = eAttr.create("cycleType", "ct", 0, &status ); status = eAttr.addField("Hold", PLAYTYPE_HOLD); status = eAttr.addField("Loop", PLAYTYPE_LOOP); status = eAttr.addField("Reverse", PLAYTYPE_REVERSE); status = eAttr.addField("Bounce", PLAYTYPE_BOUNCE); status = eAttr.setWritable(true); status = eAttr.setStorable(true); status = eAttr.setKeyable(true); status = addAttribute(mCycleTypeAttr); // Regex Filter // This is a hidden variable to preserve a regexIncludefilter string // into a .ma file. mIncludeFilterAttr = tAttr.create("regexIncludeFilter", "ift", MFnData::kString); status = tAttr.setStorable(true); status = tAttr.setHidden(true); status = addAttribute(mIncludeFilterAttr); // Regex Filter // This is a hidden variable to preserve a regexExcludefilter string // into a .ma file. mExcludeFilterAttr = tAttr.create("regexExcludeFilter", "eft", MFnData::kString); status = tAttr.setStorable(true); status = tAttr.setHidden(true); status = addAttribute(mExcludeFilterAttr); // sequence min and max in frames mStartFrameAttr = nAttr.create("startFrame", "sf", MFnNumericData::kDouble, 0, &status); status = nAttr.setWritable(false); status = nAttr.setStorable(true); status = addAttribute(mStartFrameAttr); mEndFrameAttr = nAttr.create("endFrame", "ef", MFnNumericData::kDouble, 0, &status); status = nAttr.setWritable(false); status = nAttr.setStorable(true); status = addAttribute(mEndFrameAttr); // add the output attributes // sampled subD mesh MFnMeshData fnMeshData; MObject meshDefaultObject = fnMeshData.create(&status); mOutSubDArrayAttr = tAttr.create("outSubDMesh", "osubd", MFnData::kMesh, meshDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutSubDArrayAttr); // sampled poly mesh mOutPolyArrayAttr = tAttr.create("outPolyMesh", "opoly", MFnData::kMesh, meshDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutPolyArrayAttr); // sampled nurbs surface MFnNurbsSurfaceData fnNSData; MObject nsDefaultObject = fnNSData.create(&status); mOutNurbsSurfaceArrayAttr = tAttr.create("outNSurface", "ons", MFnData::kNurbsSurface, nsDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutNurbsSurfaceArrayAttr); // sampled nurbs curve group MFnNurbsCurveData fnNCData; MObject ncDefaultObject = fnNCData.create(&status); mOutNurbsCurveGrpArrayAttr = tAttr.create("outNCurveGrp", "onc", MFnData::kNurbsCurve, ncDefaultObject); status = tAttr.setStorable(false); status = tAttr.setWritable(false); status = tAttr.setKeyable(false); status = tAttr.setArray(true); status = tAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutNurbsCurveGrpArrayAttr); // sampled locator mOutLocatorPosScaleArrayAttr = nAttr.create("outLoc", "olo", MFnNumericData::kDouble, 0.0, &status); status = nAttr.setStorable(false); status = nAttr.setWritable(false); status = nAttr.setArray(true); status = nAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutLocatorPosScaleArrayAttr); // sampled transform operations mOutTransOpArrayAttr = nAttr.create("transOp", "to", MFnNumericData::kDouble, 0.0, &status); status = nAttr.setStorable(false); status = nAttr.setWritable(false); status = nAttr.setArray(true); status = nAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutTransOpArrayAttr); // sampled camera // assume the boolean variables cannot be keyed mOutCameraArrayAttr = nAttr.create("outCamera", "ocam", MFnNumericData::kDouble, 0.0, &status); status = nAttr.setStorable(false); status = nAttr.setWritable(false); status = nAttr.setArray(true); status = nAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutCameraArrayAttr); // sampled custom-attributes mOutPropArrayAttr = gAttr.create("prop", "pr", &status); status = gAttr.addNumericDataAccept(MFnNumericData::kBoolean); status = gAttr.addNumericDataAccept(MFnNumericData::kByte); status = gAttr.addNumericDataAccept(MFnNumericData::kShort); status = gAttr.addNumericDataAccept(MFnNumericData::k2Short); status = gAttr.addNumericDataAccept(MFnNumericData::k3Short); status = gAttr.addNumericDataAccept(MFnNumericData::kInt); status = gAttr.addNumericDataAccept(MFnNumericData::k2Int); status = gAttr.addNumericDataAccept(MFnNumericData::k3Int); status = gAttr.addNumericDataAccept(MFnNumericData::kFloat); status = gAttr.addNumericDataAccept(MFnNumericData::k2Float); status = gAttr.addNumericDataAccept(MFnNumericData::k3Float); status = gAttr.addNumericDataAccept(MFnNumericData::kDouble); status = gAttr.addNumericDataAccept(MFnNumericData::k2Double); status = gAttr.addNumericDataAccept(MFnNumericData::k3Double); status = gAttr.addNumericDataAccept(MFnNumericData::k4Double); status = gAttr.addDataAccept(MFnData::kString); status = gAttr.addDataAccept(MFnData::kIntArray); status = gAttr.addDataAccept(MFnData::kDoubleArray); status = gAttr.addDataAccept(MFnData::kVectorArray); status = gAttr.addDataAccept(MFnData::kPointArray); status = gAttr.setWritable(false); status = gAttr.setKeyable(false); status = gAttr.setArray(true); status = gAttr.setUsesArrayDataBuilder(true); status = addAttribute(mOutPropArrayAttr); // set up affection relationships status = attributeAffects(mTimeAttr, mOutSubDArrayAttr); status = attributeAffects(mTimeAttr, mOutPolyArrayAttr); status = attributeAffects(mTimeAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mTimeAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mTimeAttr, mOutTransOpArrayAttr); status = attributeAffects(mTimeAttr, mOutCameraArrayAttr); status = attributeAffects(mTimeAttr, mOutPropArrayAttr); status = attributeAffects(mTimeAttr, mOutLocatorPosScaleArrayAttr); status = attributeAffects(mSpeedAttr, mOutSubDArrayAttr); status = attributeAffects(mSpeedAttr, mOutPolyArrayAttr); status = attributeAffects(mSpeedAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mSpeedAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mSpeedAttr, mOutTransOpArrayAttr); status = attributeAffects(mSpeedAttr, mOutCameraArrayAttr); status = attributeAffects(mSpeedAttr, mOutPropArrayAttr); status = attributeAffects(mSpeedAttr, mOutLocatorPosScaleArrayAttr); status = attributeAffects(mOffsetAttr, mOutSubDArrayAttr); status = attributeAffects(mOffsetAttr, mOutPolyArrayAttr); status = attributeAffects(mOffsetAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mOffsetAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mOffsetAttr, mOutTransOpArrayAttr); status = attributeAffects(mOffsetAttr, mOutCameraArrayAttr); status = attributeAffects(mOffsetAttr, mOutPropArrayAttr); status = attributeAffects(mOffsetAttr, mOutLocatorPosScaleArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutSubDArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutPolyArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutNurbsSurfaceArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutNurbsCurveGrpArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutTransOpArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutCameraArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutPropArrayAttr); status = attributeAffects(mCycleTypeAttr, mOutLocatorPosScaleArrayAttr); MGlobal::executeCommand( UITemplateMELScriptStr ); return status; }
MStatus liqSurfaceNode::initialize() { MFnTypedAttribute tAttr; MFnStringData tDefault; MFnNumericAttribute nAttr; MFnEnumAttribute eAttr; MFnLightDataAttribute lAttr; MStatus status; // Create input attributes aRmanShader = tAttr.create( MString("rmanShader"), MString("rms"), MFnData::kString, aRmanShader, &status ); MAKE_INPUT(tAttr); aRmanShaderType = tAttr.create( MString("rmanShaderType"), MString("rst"), MFnData::kString, aRmanShaderType, &status ); MAKE_INPUT(tAttr); aRmanShaderLong = tAttr.create( MString("rmanShaderLong"), MString("rml"), MFnData::kString, aRmanShaderLong, &status ); MAKE_INPUT(tAttr); aRmanShaderLif = tAttr.create( MString("rmanShaderLif"), MString("lif"), MFnData::kString, aRmanShaderLif, &status ); MAKE_INPUT(tAttr); aRmanParams = tAttr.create( MString("rmanParams"), MString("rpr"), MFnData::kStringArray, aRmanParams, &status ); MAKE_INPUT(tAttr); aRmanDetails = tAttr.create( MString("rmanDetails"), MString("rdt"), MFnData::kStringArray, aRmanDetails, &status ); MAKE_INPUT(tAttr); aRmanTypes = tAttr.create( MString("rmanTypes"), MString("rty"), MFnData::kStringArray, aRmanTypes, &status ); MAKE_INPUT(tAttr); aRmanDefaults = tAttr.create( MString("rmanDefaults"), MString("rdf"), MFnData::kStringArray, aRmanDefaults, &status ); MAKE_INPUT(tAttr); aRmanArraySizes = tAttr.create( MString("rmanArraySizes"), MString("ras"), MFnData::kIntArray, aRmanArraySizes, &status ); MAKE_INPUT(tAttr); aRmanLifCmds = tAttr.create( MString("rmanLifCmds"), MString("rlc"), MFnData::kStringArray, aRmanLifCmds, &status ); MAKE_INPUT(tAttr); aRmanMethods = tAttr.create( MString("rmanMethods"), MString("rmt"), MFnData::kStringArray, aRmanMethods, &status ); MAKE_INPUT(tAttr); aRmanIsOutput = tAttr.create( MString("rmanIsOutput"), MString("rio"), MFnData::kIntArray, aRmanIsOutput, &status ); MAKE_INPUT(tAttr); aRmanAccept = tAttr.create( MString("rmanAccept"), MString("rma"), MFnData::kStringArray, aRmanAccept, &status ); MAKE_INPUT(tAttr); aPreviewPrimitive = eAttr.create( "previewPrimitive", "pvp", 7, &status ); eAttr.addField( "Sphere", 0 ); eAttr.addField( "Cube", 1 ); eAttr.addField( "Cylinder", 2 ); eAttr.addField( "Torus", 3 ); eAttr.addField( "Plane", 4 ); eAttr.addField( "Teapot", 5 ); eAttr.addField( "Custom", 6 ); eAttr.addField( "(globals)",7 ); MAKE_NONKEYABLE_INPUT(eAttr); CHECK_MSTATUS(eAttr.setConnectable(false ) ); aPreviewCustomPrimitive = tAttr.create( MString("previewCustomPrimitive"), MString("pcp"), MFnData::kString, aPreviewCustomPrimitive, &status ); MAKE_INPUT(tAttr); aPreviewCustomBackplane = tAttr.create( MString("previewCustomBackplane"), MString("pcb"), MFnData::kString, aPreviewCustomBackplane, &status ); MAKE_INPUT(tAttr); aPreviewCustomLightRig = tAttr.create( MString("previewCustomLights"), MString("pcl"), MFnData::kString, aPreviewCustomLightRig, &status ); MAKE_INPUT(tAttr); aPreviewObjectSize = nAttr.create("previewObjectSize", "pos", MFnNumericData::kDouble, 1.0, &status); MAKE_NONKEYABLE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setConnectable(false ) ); aPreviewShadingRate = nAttr.create("previewShadingRate", "psr", MFnNumericData::kDouble, 1.0, &status); MAKE_NONKEYABLE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setConnectable(false ) ); aPreviewBackplane = nAttr.create("previewBackplane", "pbp", MFnNumericData::kBoolean, true, &status); MAKE_NONKEYABLE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setConnectable(false ) ); aPreviewIntensity = nAttr.create("previewIntensity", "pi", MFnNumericData::kDouble, 1.0, &status); MAKE_NONKEYABLE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setConnectable(false ) ); aGLPreviewTexture = nAttr.createColor("GLPreviewTexture", "gpt"); nAttr.setDefault( -1.0, -1.0, -1.0 ); nAttr.setDisconnectBehavior( MFnAttribute::kReset ); MAKE_INPUT(nAttr); aColor = nAttr.createColor("color", "cs"); nAttr.setDefault( 1.0, 1.0, 1.0 ); nAttr.setDisconnectBehavior( MFnAttribute::kReset ); MAKE_INPUT(nAttr); aOpacity = nAttr.createColor("opacity", "os"); nAttr.setDefault( 1.0, 1.0, 1.0 ); MAKE_INPUT(nAttr); aTransparency = nAttr.createColor("transparency", "ts"); // Needed by Maya for Open Gl preview in "5" mode, invert opacity in compute nAttr.setDefault( 0.0, 0.0, 0.0 ); MAKE_INPUT(nAttr); aShaderSpace = tAttr.create( MString("shaderSpace"), MString("ssp"), MFnData::kString, aShaderSpace, &status ); MAKE_INPUT(tAttr); aDisplacementBound = nAttr.create("displacementBound", "db", MFnNumericData::kDouble, 0.0, &status); MAKE_INPUT(nAttr); MObject defaultSpaceObj = tDefault.create( MString("shader"), &status); aDisplacementBoundSpace = tAttr.create( MString("displacementBoundSpace"), MString("dbs"), MFnData::kString, defaultSpaceObj, &status ); MAKE_INPUT(tAttr); aOutputInShadow = nAttr.create("outputInShadow", "ois", MFnNumericData::kBoolean, 0.0, &status); MAKE_NONKEYABLE_INPUT(nAttr); aVisiblePoints = nAttr.create( "useVisiblePoints", "uvp", MFnNumericData::kBoolean, false, &status ); MAKE_NONKEYABLE_INPUT(nAttr); CHECK_MSTATUS( nAttr.setConnectable(false ) ); // resolution attribute for maya's hardware renderer aResolution = nAttr.create("resolution", "res", MFnNumericData::kInt, 32, &status); CHECK_MSTATUS(nAttr.setStorable( true ) ); CHECK_MSTATUS(nAttr.setReadable( true ) ); CHECK_MSTATUS(nAttr.setWritable( true ) ); CHECK_MSTATUS(nAttr.setHidden( true ) ); // refreshPreview must be true to allow refresh aRefreshPreview = nAttr.create("refreshPreview", "rfp", MFnNumericData::kBoolean, 0.0, &status); MAKE_NONKEYABLE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setHidden(true ) ); // dynamic shader attr //aCi = nAttr.createColor("Ci", "ci"); //nAttr.setDefault( 1.0, 1.0, 1.0 ); //MAKE_INPUT(nAttr); //aOi = nAttr.createColor("Oi", "oi"); //nAttr.setDefault( 1.0, 1.0, 1.0 ); //MAKE_INPUT(nAttr); // create attributes for maya renderer // lambertian control aMayaIgnoreLights = nAttr.create("mayaIgnoreLights", "mil", MFnNumericData::kBoolean, 0.0, &status); MAKE_INPUT(nAttr); aMayaKa = nAttr.create("mayaKa", "mka", MFnNumericData::kFloat, 0.2, &status); MAKE_INPUT(nAttr); aMayaKd = nAttr.create("mayaKd", "mkd", MFnNumericData::kFloat, 0.8, &status); MAKE_INPUT(nAttr); // 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( 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( 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( 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( 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( 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( 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( 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( 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( 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( 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( 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.setReadable( true ) ); CHECK_MSTATUS( nAttr.setWritable( true ) ); 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( false ) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); #if MAYA_API_VERSION >= 800 aLightBlindData = nAttr.createAddr( "lightBlindData", "lbld", 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable( false ) ); CHECK_MSTATUS( nAttr.setHidden( true ) ); CHECK_MSTATUS( nAttr.setReadable( false ) ); CHECK_MSTATUS( nAttr.setDefault( (void*) 0 ) ); #else aLightBlindData = nAttr.create( "lightBlindData", "lbld", MFnNumericData::kLong, 0, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable( false ) ); CHECK_MSTATUS( nAttr.setHidden( true ) ); CHECK_MSTATUS( nAttr.setReadable( false ) ); CHECK_MSTATUS( nAttr.setDefault( 0 ) ); #endif 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, 0 ) ); aEvaluateAtEveryFrame = nAttr.create("evaluateAtEveryFrame", "def", MFnNumericData::kBoolean, 0.0, &status); MAKE_NONKEYABLE_INPUT(nAttr); aPreviewGamma = nAttr.create( "previewGamma", "pg", MFnNumericData::kFloat, 1, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setHidden( true ) ); CHECK_MSTATUS( nAttr.setReadable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); // Create output attributes aOutColor = nAttr.createColor("outColor", "oc"); MAKE_OUTPUT(nAttr); aOutTransparency = nAttr.createColor("outTransparency", "ot"); MAKE_OUTPUT(nAttr); CHECK_MSTATUS( addAttribute( aRmanShader ) ); CHECK_MSTATUS( addAttribute( aRmanShaderType ) ); CHECK_MSTATUS( addAttribute( aRmanShaderLong ) ); CHECK_MSTATUS( addAttribute( aRmanShaderLif ) ); CHECK_MSTATUS( addAttribute( aRmanParams ) ); CHECK_MSTATUS( addAttribute( aRmanDetails ) ); CHECK_MSTATUS( addAttribute( aRmanTypes ) ); CHECK_MSTATUS( addAttribute( aRmanDefaults ) ); CHECK_MSTATUS( addAttribute( aRmanArraySizes ) ); CHECK_MSTATUS( addAttribute( aRmanLifCmds ) ); CHECK_MSTATUS( addAttribute(aRmanMethods) ); CHECK_MSTATUS( addAttribute(aRmanIsOutput) ); CHECK_MSTATUS( addAttribute( aRmanAccept) ); CHECK_MSTATUS( addAttribute( aPreviewPrimitive ) ); CHECK_MSTATUS( addAttribute( aPreviewCustomPrimitive ) ); CHECK_MSTATUS( addAttribute( aPreviewCustomBackplane ) ); CHECK_MSTATUS( addAttribute( aPreviewCustomLightRig ) ); CHECK_MSTATUS( addAttribute( aPreviewObjectSize ) ); CHECK_MSTATUS( addAttribute( aPreviewShadingRate ) ); CHECK_MSTATUS( addAttribute( aPreviewBackplane ) ); CHECK_MSTATUS( addAttribute( aPreviewIntensity ) ); CHECK_MSTATUS( addAttribute(aGLPreviewTexture)); //CHECK_MSTATUS( addAttribute( aCi ) ); //CHECK_MSTATUS( addAttribute( aOi ) ); CHECK_MSTATUS( addAttribute( aColor ) ); CHECK_MSTATUS( addAttribute( aTransparency ) ); CHECK_MSTATUS( addAttribute( aOpacity ) ); CHECK_MSTATUS( addAttribute( aShaderSpace ) ); CHECK_MSTATUS( addAttribute( aDisplacementBound ) ); CHECK_MSTATUS( addAttribute( aDisplacementBoundSpace ) ); CHECK_MSTATUS( addAttribute( aOutputInShadow ) ); CHECK_MSTATUS( addAttribute( aVisiblePoints ) ); CHECK_MSTATUS( addAttribute( aResolution ) ); CHECK_MSTATUS( addAttribute( aRefreshPreview ) ); CHECK_MSTATUS( addAttribute( aMayaIgnoreLights ) ); CHECK_MSTATUS( addAttribute( aMayaKa ) ); CHECK_MSTATUS( addAttribute( aMayaKd ) ); CHECK_MSTATUS( addAttribute( aNormalCamera ) ); CHECK_MSTATUS( addAttribute( aLightData ) ); CHECK_MSTATUS( addAttribute( aEvaluateAtEveryFrame ) ); CHECK_MSTATUS( addAttribute( aPreviewGamma ) ); CHECK_MSTATUS( addAttribute( aOutColor ) ); CHECK_MSTATUS( addAttribute( aOutTransparency ) ); CHECK_MSTATUS(attributeAffects( aGLPreviewTexture, aOutColor )); CHECK_MSTATUS(attributeAffects( aColor, aOutColor ) ); CHECK_MSTATUS(attributeAffects( aOpacity, aOutColor ) ); CHECK_MSTATUS(attributeAffects( aMayaIgnoreLights, aOutColor ) ); CHECK_MSTATUS(attributeAffects( aMayaKa, aOutColor ) ); CHECK_MSTATUS(attributeAffects( aMayaKd, 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 ) ); CHECK_MSTATUS(attributeAffects( aOpacity, aOutTransparency ) ); return MS::kSuccess; }
void DCM_ATTRIBUTE_GROUP_CLASS::merge(DCM_ATTRIBUTE_GROUP_CLASS *mergeDicomObject_ptr) // DESCRIPTION : Merge the given dicom object into "this". // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : The merge attributes can overwrite "this" attributes. //<<=========================================================================== { // check if we are trying to merge this into this if (mergeDicomObject_ptr == this) { if (loggerM_ptr) { loggerM_ptr->text(LOG_DEBUG, 1, "Trying to merge into same object - doing nothing"); } // don't do anything return; } // merge given object into this // clean up any attribute if (loggerM_ptr) { loggerM_ptr->text(LOG_DEBUG, 1, "Merge attribute count: %d", mergeDicomObject_ptr->GetNrAttributes()); } while (mergeDicomObject_ptr->GetNrAttributes()) { // get next merge attribute and remove it from source DCM_ATTRIBUTE_CLASS *mergeAttribute_ptr = mergeDicomObject_ptr->GetAttribute(0); mergeDicomObject_ptr->DeleteAttributeIndex(0); if (loggerM_ptr) { loggerM_ptr->text(LOG_DEBUG, 1, "Merge attribute is (%04X,%04X)", mergeAttribute_ptr->GetGroup(), mergeAttribute_ptr->GetElement()); } if(!mergeAttribute_ptr->IsPresent()) { DeleteAttribute(mergeAttribute_ptr->GetMappedGroup(), mergeAttribute_ptr->GetMappedElement()); continue; } DCM_ATTRIBUTE_CLASS *attribute_ptr = GetMappedAttribute(mergeAttribute_ptr->GetMappedGroup(), mergeAttribute_ptr->GetMappedElement(), true); if (attribute_ptr != NULL) { if (loggerM_ptr) { loggerM_ptr->text(LOG_DEBUG, 1, "GetMappedAttribute returns (%04X,%04X)", attribute_ptr->GetGroup(), attribute_ptr->GetElement()); } // check VR of the merge attribute for SQ if (mergeAttribute_ptr->GetVR() == ATTR_VR_SQ) { if (loggerM_ptr) { loggerM_ptr->text(LOG_DEBUG, 1, "Merge attribute (%04X,%04X) is SQ", mergeAttribute_ptr->GetGroup(), mergeAttribute_ptr->GetElement()); } // check VR of matching attribute in destination if (attribute_ptr->GetVR() != ATTR_VR_SQ) { if (loggerM_ptr) { loggerM_ptr->text(LOG_DEBUG, 1, "Destination attribute (%04X,%04X) is not SQ", attribute_ptr->GetGroup(), attribute_ptr->GetElement()); loggerM_ptr->text(LOG_DEBUG, 1, "Replacing destination attribute by merge SQ attribute - (%04X,%04X)", mergeAttribute_ptr->GetGroup(), mergeAttribute_ptr->GetElement()); } // source to destination VRs are different // overwrite destination with source DeleteMappedAttributeIndex(mergeAttribute_ptr->GetMappedGroup(), mergeAttribute_ptr->GetMappedElement()); // copy merge attribute to destination addAttribute(mergeAttribute_ptr); } else // destination attribute is a SQ { if (loggerM_ptr) { loggerM_ptr->text(LOG_DEBUG, 1, "Destination attribute (%04X,%04X) is SQ", attribute_ptr->GetGroup(), attribute_ptr->GetElement()); } // check if destination SQ is empty if (attribute_ptr->GetNrValues() == 0) { loggerM_ptr->text(LOG_DEBUG, 1, "Destination attribute has no items"); // check if there are items in the source if (mergeAttribute_ptr->GetNrValues() != 0) { // allocate new SQ value for destination DCM_VALUE_SQ_CLASS *sqValue_ptr = new DCM_VALUE_SQ_CLASS(UNDEFINED_LENGTH); // add SQ value to destination attribute_ptr->addSqValue(sqValue_ptr); // copy items from source to destination sqValue_ptr->merge(mergeAttribute_ptr); } } else if (attribute_ptr->GetNrValues() == 1) { // sequence contains items DCM_VALUE_SQ_CLASS *sqValue_ptr = (DCM_VALUE_SQ_CLASS*) attribute_ptr->GetValue(0); // copy items from source to destination sqValue_ptr->merge(mergeAttribute_ptr); } } } else { // delete original attribute DeleteMappedAttributeIndex(mergeAttribute_ptr->GetMappedGroup(), mergeAttribute_ptr->GetMappedElement()); // copy merge attribute from source to destination addAttribute(mergeAttribute_ptr); if (loggerM_ptr) { loggerM_ptr->text(LOG_DEBUG, 1, "Replacing destination attribute by merge attribute - (%04X,%04X)", mergeAttribute_ptr->GetGroup(), mergeAttribute_ptr->GetElement()); } } } else { // no matching attribute found in destination // simply copy merge attribute from source is destination addAttribute(mergeAttribute_ptr); if (loggerM_ptr) { loggerM_ptr->text(LOG_DEBUG, 1, "Adding attribute for first time - (%04X,%04X)", mergeAttribute_ptr->GetGroup(), mergeAttribute_ptr->GetElement()); } } } }
void DCM_ATTRIBUTE_GROUP_CLASS::addGroupLengths() // DESCRIPTION : Method to add the Group Length attributes to the // DICOM object. They are initially filled in with a zero // length. The actual lengths need to be computed when // when the sequence lengths are known. // PRECONDITIONS : // POSTCONDITIONS : // EXCEPTIONS : // NOTES : //<<=========================================================================== { UINT32 thisGroup = 0xFFFF; // sort attributes before adding group lengths SortAttributes(); // run through all Attributes - they may not have been sorted yet for (int i = 0; i < GetNrAttributes(); i++) { DCM_ATTRIBUTE_CLASS *attribute_ptr = GetAttribute(i); if (attribute_ptr->GetGroup() != thisGroup) { // we are in a new group and must check to see if a group length should be added if (attribute_ptr->GetElement() != LENGTH_ELEMENT) { // set the Group Length value UINT32 length = 0; DCM_VALUE_UL_CLASS *value_ptr = new DCM_VALUE_UL_CLASS(); value_ptr->Set(length); // allocate the Group Length attribute DCM_ATTRIBUTE_CLASS *groupLengthAttribute_ptr = new DCM_ATTRIBUTE_CLASS(attribute_ptr->GetGroup(), LENGTH_ELEMENT); groupLengthAttribute_ptr->SetVR(ATTR_VR_UL); // make Group Length mandatory to ensure it is encoded groupLengthAttribute_ptr->SetType(ATTR_TYPE_1); // set EnsureEvenAttributeValueLength groupLengthAttribute_ptr->setEnsureEvenAttributeValueLength(ensureEvenAttributeValueLengthM); // add Value to Attribute groupLengthAttribute_ptr->AddValue(value_ptr); // add Attribute to Object addAttribute(groupLengthAttribute_ptr); } else { // check if a value has been defined if (attribute_ptr->GetNrValues() == 0) { // set the Group Length value UINT32 length = 0; DCM_VALUE_UL_CLASS *value_ptr = new DCM_VALUE_UL_CLASS; value_ptr->Set(length); // make Group Length mandatory to ensure it is encoded attribute_ptr->SetType(ATTR_TYPE_1); // add Value to Attribute attribute_ptr->AddValue(value_ptr); } } thisGroup = attribute_ptr->GetGroup(); } // recurse through the sequence items if (attribute_ptr->GetVR() == ATTR_VR_SQ) { // only interested if one SQ value available if (attribute_ptr->GetNrValues() == 1) { // get SQ value DCM_VALUE_SQ_CLASS *sqValue_ptr = static_cast<DCM_VALUE_SQ_CLASS*>(attribute_ptr->GetValue(0)); // set the group lengths sqValue_ptr->addGroupLengths(); } } } // having added the Group Length - we must sort the object again SortAttributes(); }
MStatus ropeGenerator::initialize() { MStatus stat; MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MRampAttribute rAttr; inCurve = tAttr.create( "inCurve", "inCurve", MFnData::kNurbsCurve ); tAttr.setHidden( true); divisions = nAttr.create( "divisions", "divisions", MFnNumericData::kInt, 15 ); nAttr.setMin( 2 ); nAttr.setSoftMax( 100 ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); createRope = nAttr.create( "createRope", "createRope", MFnNumericData::kBoolean, false ); nAttr.setWritable( true ); nAttr.setStorable( true ); nAttr.setKeyable( true ); ropesCount = nAttr.create( "ropesCount", "ropesCount", MFnNumericData::kInt, 5 ); nAttr.setMin( 3 ); nAttr.setSoftMax( 10 ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); pointsPerRope = nAttr.create( "pointsPerRope", "pointsPerRope", MFnNumericData::kInt, 6 ); nAttr.setMin( 3 ); nAttr.setSoftMax( 15 ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); ropesStrength = nAttr.create( "ropesStrength", "ropesStrength", MFnNumericData::kFloat, 1.0f ); nAttr.setMin( 0.0 ); nAttr.setMax( 1.0 ); nAttr.setWritable( true ); nAttr.setStorable( true ); nAttr.setKeyable( true ); pointsCount = nAttr.create( "pointsCount", "pointsCount", MFnNumericData::kInt, 5 ); nAttr.setMin(3); nAttr.setSoftMax( 20 ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); radius = nAttr.create( "radius", "radius", MFnNumericData::kFloat, 1.0f ); nAttr.setMin( 0.0 ); nAttr.setSoftMax( 30.0 ); nAttr.setKeyable( true ); nAttr.setWritable( true ); nAttr.setStorable( true ); taperRamp = rAttr.createCurveRamp( "tapper", "tapper" ); twist = nAttr.create( "twist", "twist", MFnNumericData::kFloat, 0.0f ); nAttr.setSoftMin( -3600.0 ); nAttr.setSoftMax( 3600.0 ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); twistRamp = rAttr.createCurveRamp( "twistRamp", "twistRamp" ); uvWidth = nAttr.create( "uvWidth", "uvWidth", MFnNumericData::kFloat, 1.0f ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); uvHeight = nAttr.create( "uvHeight", "uvHeight", MFnNumericData::kFloat, 1.0f ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); uvCapSize = nAttr.create( "uvCapSize", "uvCapSize", MFnNumericData::kFloat, 1.0f ); nAttr.setWritable( true ); nAttr.setKeyable( true ); nAttr.setStorable( true ); outMesh = tAttr.create( "outMesh", "outMesh", MFnData::kMesh ); tAttr.setWritable( false ); tAttr.setStorable( false ); stat = addAttribute( inCurve ); if (!stat) { stat.perror("addAttribute inCurve"); return stat;} stat = addAttribute( divisions ); if (!stat) { stat.perror("addAttribute divisions"); return stat;} stat = addAttribute( createRope ); if (!stat) { stat.perror("addAttribute createRope"); return stat;} stat = addAttribute( ropesCount ); if (!stat) { stat.perror("addAttribute ropesCount"); return stat;} stat = addAttribute( pointsPerRope ); if (!stat) { stat.perror("addAttribute pointsPerRope"); return stat;} stat = addAttribute( ropesStrength ); if (!stat) { stat.perror("addAttribute ropesStrength"); return stat;} stat = addAttribute( pointsCount ); if (!stat) { stat.perror("addAttribute pointsCount"); return stat;} stat = addAttribute( radius ); if (!stat) { stat.perror("addAttribute radius"); return stat;} stat = addAttribute( taperRamp ); if (!stat) { stat.perror("addAttribute taperRamp"); return stat;} stat = addAttribute( twist ); if (!stat) { stat.perror("addAttribute twist"); return stat;} stat = addAttribute( twistRamp ); if (!stat) { stat.perror("addAttribute twistRamp"); return stat;} stat = addAttribute( uvWidth ); if (!stat) { stat.perror("addAttribute uvWidth"); return stat;} stat = addAttribute( uvHeight ); if (!stat) { stat.perror("addAttribute uvHeight"); return stat;} stat = addAttribute( uvCapSize ); if (!stat) { stat.perror("addAttribute uvCapSize"); return stat;} stat = addAttribute( outMesh ); if (!stat) { stat.perror("addAttribute outMesh"); return stat;} stat = attributeAffects( inCurve, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( divisions, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( createRope, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( ropesCount, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( pointsPerRope, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( ropesStrength, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( pointsCount, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( radius, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( taperRamp, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( twist, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( twistRamp, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( uvWidth, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( uvHeight, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} stat = attributeAffects( uvCapSize, outMesh ); if (!stat) { stat.perror("attributeAffects"); return stat;} return MS::kSuccess; }
MStatus liqCoShaderNode::initialize() { MFnTypedAttribute tAttr; MFnNumericAttribute nAttr; MFnEnumAttribute eAttr; MStatus status; // Create input attributes aRmanShader = tAttr.create( MString("rmanShader"), MString("rms"), MFnData::kString, aRmanShader, &status ); MAKE_INPUT(tAttr); aRmanShaderType = tAttr.create( MString("rmanShaderType"), MString("rst"), MFnData::kString, aRmanShaderType, &status ); MAKE_INPUT(tAttr); aRmanShaderLong = tAttr.create( MString("rmanShaderLong"), MString("rml"), MFnData::kString, aRmanShaderLong, &status ); MAKE_INPUT(tAttr); aRmanShaderLif = tAttr.create( MString("rmanShaderLif"), MString("lif"), MFnData::kString, aRmanShaderLif, &status ); MAKE_INPUT(tAttr); aRmanParams = tAttr.create( MString("rmanParams"), MString("rpr"), MFnData::kStringArray, aRmanParams, &status ); MAKE_INPUT(tAttr); aRmanDetails = tAttr.create( MString("rmanDetails"), MString("rdt"), MFnData::kStringArray, aRmanDetails, &status ); MAKE_INPUT(tAttr); aRmanTypes = tAttr.create( MString("rmanTypes"), MString("rty"), MFnData::kStringArray, aRmanTypes, &status ); MAKE_INPUT(tAttr); aRmanDefaults = tAttr.create( MString("rmanDefaults"), MString("rdf"), MFnData::kStringArray, aRmanDefaults, &status ); MAKE_INPUT(tAttr); aRmanArraySizes = tAttr.create( MString("rmanArraySizes"), MString("ras"), MFnData::kIntArray, aRmanArraySizes, &status ); MAKE_INPUT(tAttr); aRmanLifCmds = tAttr.create( MString("rmanLifCmds"), MString("rlc"), MFnData::kStringArray, aRmanLifCmds, &status ); MAKE_INPUT(tAttr); aRmanMethods = tAttr.create( MString("rmanMethods"), MString("rmt"), MFnData::kStringArray, aRmanMethods, &status ); MAKE_INPUT(tAttr); aRmanIsOutput = tAttr.create( MString("rmanIsOutput"), MString("rio"), MFnData::kIntArray, aRmanIsOutput, &status ); MAKE_INPUT(tAttr); aRmanAccept = tAttr.create( MString("rmanAccept"), MString("rma"), MFnData::kStringArray, aRmanAccept, &status ); MAKE_INPUT(tAttr); aPreviewPrimitive = eAttr.create( "previewPrimitive", "pvp", 7, &status ); eAttr.addField( "Sphere", 0 ); eAttr.addField( "Cube", 1 ); eAttr.addField( "Cylinder", 2 ); eAttr.addField( "Torus", 3 ); eAttr.addField( "Plane", 4 ); eAttr.addField( "Teapot", 5 ); eAttr.addField( "Custom", 6 ); eAttr.addField( "(globals)",7 ); MAKE_NONKEYABLE_INPUT(eAttr); CHECK_MSTATUS(eAttr.setConnectable(false)); aPreviewCustomPrimitive = tAttr.create( MString("previewCustomPrimitive"), MString("pcp"), MFnData::kString, aPreviewCustomPrimitive, &status ); MAKE_INPUT(tAttr); aPreviewObjectSize = nAttr.create("previewObjectSize", "pos", MFnNumericData::kDouble, 1.0, &status); MAKE_NONKEYABLE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setConnectable(false)); aPreviewShadingRate = nAttr.create("previewShadingRate", "psr", MFnNumericData::kDouble, 1.0, &status); MAKE_NONKEYABLE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setConnectable(false)); aPreviewBackplane = nAttr.create("previewBackplane", "pbp", MFnNumericData::kBoolean, true, &status); MAKE_NONKEYABLE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setConnectable(false)); aShaderSpace = tAttr.create( MString("shaderSpace"), MString("ssp"), MFnData::kString, aShaderSpace, &status ); MAKE_INPUT(tAttr); aOutputInShadow = nAttr.create("outputInShadow", "ois", MFnNumericData::kBoolean, 0.0, &status); MAKE_NONKEYABLE_INPUT(nAttr); // refreshPreview must be true to allow refresh aRefreshPreview = nAttr.create("refreshPreview", "rfp", MFnNumericData::kBoolean, 0.0, &status); MAKE_NONKEYABLE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setHidden(true)); aPreviewGamma = nAttr.create( "previewGamma", "pg", MFnNumericData::kFloat, 1, &status ); CHECK_MSTATUS( status ); CHECK_MSTATUS( nAttr.setStorable( true ) ); CHECK_MSTATUS( nAttr.setHidden( true ) ); CHECK_MSTATUS( nAttr.setReadable( true ) ); CHECK_MSTATUS( nAttr.setDefault( 1.0f ) ); // Create output attributes aOutColor = nAttr.createColor("outColor", "oc"); MAKE_OUTPUT(nAttr); CHECK_MSTATUS(addAttribute(aRmanShader)); CHECK_MSTATUS(addAttribute(aRmanShaderType)); CHECK_MSTATUS(addAttribute(aRmanShaderLong)); CHECK_MSTATUS(addAttribute(aRmanShaderLif)); CHECK_MSTATUS(addAttribute(aRmanParams)); CHECK_MSTATUS(addAttribute(aRmanDetails)); CHECK_MSTATUS(addAttribute(aRmanTypes)); CHECK_MSTATUS(addAttribute(aRmanDefaults)); CHECK_MSTATUS(addAttribute(aRmanArraySizes)); CHECK_MSTATUS(addAttribute(aRmanLifCmds)); CHECK_MSTATUS(addAttribute(aRmanMethods)); CHECK_MSTATUS(addAttribute(aRmanIsOutput)); CHECK_MSTATUS(addAttribute(aRmanAccept)); CHECK_MSTATUS(addAttribute(aPreviewPrimitive)); CHECK_MSTATUS(addAttribute(aPreviewCustomPrimitive)); CHECK_MSTATUS(addAttribute(aPreviewObjectSize)); CHECK_MSTATUS(addAttribute(aPreviewShadingRate)); CHECK_MSTATUS(addAttribute(aPreviewBackplane)); CHECK_MSTATUS(addAttribute(aShaderSpace)); CHECK_MSTATUS(addAttribute(aOutputInShadow)); CHECK_MSTATUS(addAttribute(aRefreshPreview)); CHECK_MSTATUS(addAttribute(aPreviewGamma)); CHECK_MSTATUS(addAttribute(aOutColor)); return MS::kSuccess; }
MStatus MG_vectorGL::initialize() { //Declaring all the needed attribute function sets MFnEnumAttribute enumFn; MFnMatrixAttribute matrixFn; MFnNumericAttribute numFn; MFnCompoundAttribute compA; drawIt =numFn.create("drawIt","drw",MFnNumericData::kBoolean,1); numFn.setKeyable(true); numFn.setStorable(true); addAttribute(drawIt); arrowSize =numFn.create("arrowSize","as",MFnNumericData::kDouble,1); numFn.setKeyable(true); numFn.setStorable(true); addAttribute(arrowSize); fakeOut =numFn.create("fakeOut","fo",MFnNumericData::kBoolean,1); numFn.setKeyable(true); numFn.setStorable(true); addAttribute(fakeOut); upVecX =numFn.create("upVecX","uvx",MFnNumericData::kDouble,0); numFn.setStorable(true); addAttribute(upVecX); upVecY =numFn.create("upVecY","uvy",MFnNumericData::kDouble,1); numFn.setStorable(true); addAttribute(upVecY); upVecZ =numFn.create("upVecZ","uvz",MFnNumericData::kDouble,0); numFn.setStorable(true); addAttribute(upVecZ); upVec= compA.create("upVec","uv" ); compA.addChild(upVecX); compA.addChild(upVecY); compA.addChild(upVecZ); addAttribute(upVec); vecX =numFn.create("vecX","vx",MFnNumericData::kDouble,0); numFn.setStorable(true); addAttribute(vecX); vecY =numFn.create("vecY","vy",MFnNumericData::kDouble,1); numFn.setStorable(true); addAttribute(vecY); vecZ =numFn.create("vecZ","vz",MFnNumericData::kDouble,0); numFn.setStorable(true); addAttribute(vecZ); vecs= compA.create("vecs","vs" ); compA.addChild(vecX); compA.addChild(vecY); compA.addChild(vecZ); compA.setArray(true); addAttribute(vecs); startPointX =numFn.create("startPointX","spx",MFnNumericData::kDouble,0); numFn.setStorable(true); addAttribute(startPointX); startPointY =numFn.create("startPointY","spy",MFnNumericData::kDouble,0); numFn.setStorable(true); addAttribute(startPointY); startPointZ =numFn.create("startPointZ","spz",MFnNumericData::kDouble,0); numFn.setStorable(true); addAttribute(startPointZ); startPoint= compA.create("startPoints","sp" ); compA.addChild(startPointX); compA.addChild(startPointY); compA.addChild(startPointZ); compA.setArray(true); addAttribute(startPoint); attributeAffects(arrowSize , fakeOut); attributeAffects(startPoint , fakeOut); attributeAffects(upVec , fakeOut); attributeAffects(drawIt , fakeOut); attributeAffects(vecs , fakeOut); return MS::kSuccess; }
// Return the attributes of a character and surrounding text. QString QsciAccessibleScintillaBase::attributes(int offset, int *startOffset, int *endOffset) const { QsciScintillaBase *sb = sciWidget(); int position = offsetAsPosition(sb, offset); int style = sb->SendScintilla(QsciScintillaBase::SCI_GETSTYLEAT, position); // Find the start of the text with this style. int start_position = position; int start_text_position = offset; while (start_position > 0) { int before = sb->SendScintilla(QsciScintillaBase::SCI_POSITIONBEFORE, start_position); int s = sb->SendScintilla(QsciScintillaBase::SCI_GETSTYLEAT, before); if (s != style) break; start_position = before; --start_text_position; } *startOffset = start_text_position; // Find the end of the text with this style. int end_position = sb->SendScintilla(QsciScintillaBase::SCI_POSITIONAFTER, position); int end_text_position = offset + 1; int last_position = sb->SendScintilla( QsciScintillaBase::SCI_GETTEXTLENGTH); while (end_position < last_position) { int s = sb->SendScintilla(QsciScintillaBase::SCI_GETSTYLEAT, end_position); if (s != style) break; end_position = sb->SendScintilla(QsciScintillaBase::SCI_POSITIONAFTER, end_position); ++end_text_position; } *endOffset = end_text_position; // Convert the style to attributes. QString attrs; int back = sb->SendScintilla(QsciScintillaBase::SCI_STYLEGETBACK, style); addAttribute(attrs, "background-color", colourAsRGB(back)); int fore = sb->SendScintilla(QsciScintillaBase::SCI_STYLEGETFORE, style); addAttribute(attrs, "color", colourAsRGB(fore)); QFont font = fontForStyle(style); QString family = font.family(); family = family.replace('\\', QLatin1String("\\\\")); family = family.replace(':', QLatin1String("\\:")); family = family.replace(',', QLatin1String("\\,")); family = family.replace('=', QLatin1String("\\=")); family = family.replace(';', QLatin1String("\\;")); family = family.replace('\"', QLatin1String("\\\"")); addAttribute(attrs, "font-familly", QLatin1Char('"') + family + QLatin1Char('"')); int font_size = int(font.pointSize()); addAttribute(attrs, "font-size", QString::fromLatin1("%1pt").arg(font_size)); QFont::Style font_style = font.style(); addAttribute(attrs, "font-style", QString::fromLatin1((font_style == QFont::StyleItalic) ? "italic" : ((font_style == QFont::StyleOblique) ? "oblique": "normal"))); int font_weight = font.weight(); addAttribute(attrs, "font-weight", QString::fromLatin1( (font_weight > QFont::Normal) ? "bold" : "normal")); int underline = sb->SendScintilla(QsciScintillaBase::SCI_STYLEGETUNDERLINE, style); if (underline) addAttribute(attrs, "text-underline-type", QString::fromLatin1("single")); return attrs; }
void Doom3EntityClass::parseFromTokens(parser::DefTokeniser& tokeniser) { // Clear this structure first, we might be "refreshing" ourselves from tokens clear(); // Required open brace (the name has already been parsed by the EClassManager) tokeniser.assertNextToken("{"); // Loop over all of the keys in this entitydef while (true) { const std::string key = tokeniser.nextToken(); if (key == "}") { break; // end of def } const std::string value = tokeniser.nextToken(); // Otherwise, switch on the key name if (key == "model") { setModelPath(os::standardPath(value)); } else if (key == "editor_color") { setColour(value); } else if (key == "editor_light") { if (value == "1") { setIsLight(true); } } else if (key == "spawnclass") { if (value == "idLight") { setIsLight(true); } } else if (boost::algorithm::istarts_with(key, "editor_")) { // "editor_yyy" represents an attribute that may be set on this // entity. Construct a value-less EntityClassAttribute to add to // the class, so that it will show in the entity inspector. // Locate the space in "editor_bool myVariable", starting after "editor_" std::size_t spacePos = key.find(' ', 7); // Only proceed if we have a space (some keys like "editor_displayFolder" don't have spaces) if (spacePos != std::string::npos) { // The part beyond the space is the name of the attribute std::string attName = key.substr(spacePos + 1); // Get the type by trimming the string left and right std::string type = key.substr(7, key.length() - attName.length() - 8); // Ignore editor_setKeyValue if (!attName.empty() && type != "setKeyValue") { // Transform the type into a better format if (type == "var" || type == "string") { type = "text"; } addAttribute(EntityClassAttribute(type, attName, "", value)); } } } // Following key-specific processing, add the keyvalue to the eclass EntityClassAttribute attribute("text", key, value, ""); if (getAttribute(key).type.empty()) { // Type is empty, attribute does not exist, add it. addAttribute(attribute); } else if (getAttribute(key).value.empty() ) { // Attribute type is set, but value is empty, set the value. getAttribute(key).value = value; } else { // Both type and value are not empty, emit a warning globalWarningStream() << "[eclassmgr] attribute " << key << " already set on entityclass " << _name << std::endl; } } // while true // Notify the observers for (Observers::const_iterator i = _observers.begin(); i != _observers.end(); ++i) { (*i)->OnEClassReload(); } }
QgsVectorLayerProperties::QgsVectorLayerProperties( QgsVectorLayer *lyr, QWidget * parent, Qt::WFlags fl ) : QDialog( parent, fl ), layer( lyr ), mRendererDialog( 0 ) { setupUi( this ); connect( buttonBox, SIGNAL( accepted() ), this, SLOT( accept() ) ); connect( buttonBox, SIGNAL( rejected() ), this, SLOT( reject() ) ); connect( buttonBox->button( QDialogButtonBox::Apply ), SIGNAL( clicked() ), this, SLOT( apply() ) ); connect( this, SIGNAL( accepted() ), this, SLOT( apply() ) ); connect( mAddAttributeButton, SIGNAL( clicked() ), this, SLOT( addAttribute() ) ); connect( mDeleteAttributeButton, SIGNAL( clicked() ), this, SLOT( deleteAttribute() ) ); connect( mToggleEditingButton, SIGNAL( clicked() ), this, SLOT( toggleEditing() ) ); connect( this, SIGNAL( toggleEditing( QgsMapLayer* ) ), QgisApp::instance(), SLOT( toggleEditing( QgsMapLayer* ) ) ); connect( layer, SIGNAL( editingStarted() ), this, SLOT( editingToggled() ) ); connect( layer, SIGNAL( editingStopped() ), this, SLOT( editingToggled() ) ); connect( layer, SIGNAL( attributeAdded( int ) ), this, SLOT( attributeAdded( int ) ) ); connect( layer, SIGNAL( attributeDeleted( int ) ), this, SLOT( attributeDeleted( int ) ) ); mAddAttributeButton->setIcon( QgisApp::getThemeIcon( "/mActionNewAttribute.png" ) ); mDeleteAttributeButton->setIcon( QgisApp::getThemeIcon( "/mActionDeleteAttribute.png" ) ); mToggleEditingButton->setIcon( QgisApp::getThemeIcon( "/mActionToggleEditing.png" ) ); // Create the Label dialog tab QVBoxLayout *layout = new QVBoxLayout( labelOptionsFrame ); layout->setMargin( 0 ); labelDialog = new QgsLabelDialog( layer->label(), labelOptionsFrame ); layout->addWidget( labelDialog ); labelOptionsFrame->setLayout( layout ); connect( labelDialog, SIGNAL( labelSourceSet() ), this, SLOT( setLabelCheckBox() ) ); // Create the Actions dialog tab QVBoxLayout *actionLayout = new QVBoxLayout( actionOptionsFrame ); actionLayout->setMargin( 0 ); const QgsFieldMap &fields = layer->pendingFields(); actionDialog = new QgsAttributeActionDialog( layer->actions(), fields, actionOptionsFrame ); actionLayout->addWidget( actionDialog ); reset(); if ( layer->dataProvider() )//enable spatial index button group if supported by provider { int capabilities = layer->dataProvider()->capabilities(); if ( !( capabilities&QgsVectorDataProvider::CreateSpatialIndex ) ) { pbnIndex->setEnabled( false ); } } updateButtons(); leSpatialRefSys->setText( layer->srs().toProj4() ); leSpatialRefSys->setCursorPosition( 0 ); connect( sliderTransparency, SIGNAL( valueChanged( int ) ), this, SLOT( sliderTransparency_valueChanged( int ) ) ); tabWidget->setCurrentIndex( 0 ); } // QgsVectorLayerProperties ctor
//--------------------------------------------------------- int ofxXmlSettings::addAttribute(const string& tag, const string& attribute, const string& value){ return addAttribute(tag,attribute,value,-1); }
/************************************************ Function: extractRequestSubjectToAOS Parameters: const xacml_request_t request Description: This function extracts the Subject information details from the request and puts that into the EEF AOS. Return: 0 : good !0 : bad ************************************************/ int extractRequestSubjectToAOS (const xacml_request_t request) { /*char * logstr = "extractRequestSubjectToAOS()";*/ size_t count = 0; size_t i = 0; const char *category; const char *attribute_id; const char *data_type; const char *issuer; const char *value; aos_context_t* aos_context = NULL; aos_attribute_t* aos_attribute = NULL; xacml_request_get_subject_attribute_count(request, &count); if (count > 0) { rewindContexts(); if((aos_context = getNextContext(SUBJECT, NULL)) == NULL){ if((aos_context = createContext (SUBJECT)) == NULL){ return 1; } } /* aos_context should be set now */ } for (i = 0; i < count; i++) { category = NULL; attribute_id = NULL; data_type = NULL; issuer = NULL; value = NULL; xacml_request_get_subject_attribute( request, i, &category, &attribute_id, &data_type, &issuer, &value); /* EEF AOS magic */ /*fprintf (stderr, "aos_set_string (\"%s\", \"%s\")\n", attribute_id, (const char *) value);*/ /* if (strcmp ("http://authz-interop.org/xacml/subject/voms-fqan", attribute_id) == 0) */ /* { */ /* fprintf (stderr, "Skipping voms-fqan\n"); */ /* continue; */ /* } */ /* aos_set_string (attribute_id, (char *) value); */ if (aos_context){ if((aos_attribute = createAttribute())){ setAttributeId (aos_attribute, attribute_id); setAttributeIssuer(aos_attribute, issuer); setAttributeType (aos_attribute, data_type); setAttributeValue (aos_attribute, value, strlen(value) + 1); addAttribute(aos_context, aos_attribute); } } } if(aos_context){ addContext (aos_context); } return 0; }
// // DESCRIPTION: /////////////////////////////////////////////////////// MStatus ShadowMatte::initialize() { MFnNumericAttribute nAttr; MFnLightDataAttribute lAttr; // Outputs aViewColor = nAttr.create( "viewColor", "vc", MFnNumericData::kBoolean); nAttr.setKeyable(true); nAttr.setStorable(true); nAttr.setHidden(false); nAttr.setDefault(true); aOutColor = nAttr.createColor( "outColor", "oc"); nAttr.setStorable(false); nAttr.setHidden(false); nAttr.setReadable(true); nAttr.setWritable(false); aOutTransparency = nAttr.createColor( "outTransparency", "ot" ); nAttr.setStorable(false); nAttr.setHidden(false); nAttr.setReadable(true); nAttr.setWritable(false); // Inputs aLightDirection = nAttr.createPoint( "lightDirection", "ld" ); nAttr.setStorable(false); nAttr.setHidden(true); nAttr.setReadable(true); nAttr.setWritable(false); nAttr.setDefault(1.0f, 1.0f, 1.0f); aLightIntensity = nAttr.createColor( "lightIntensity", "li" ); nAttr.setStorable(false); nAttr.setHidden(true); nAttr.setReadable(true); nAttr.setWritable(false); nAttr.setDefault(1.0f, 1.0f, 1.0f); aLightAmbient = nAttr.create( "lightAmbient", "la", MFnNumericData::kBoolean); nAttr.setStorable(false); nAttr.setHidden(true); nAttr.setReadable(true); nAttr.setWritable(false); nAttr.setDefault(true); aLightDiffuse = nAttr.create( "lightDiffuse", "ldf", MFnNumericData::kBoolean); nAttr.setStorable(false); nAttr.setHidden(true); nAttr.setReadable(true); nAttr.setWritable(false); nAttr.setDefault(true); aLightSpecular = nAttr.create( "lightSpecular", "ls", MFnNumericData::kBoolean); nAttr.setStorable(false); nAttr.setHidden(true); nAttr.setReadable(true); nAttr.setWritable(false); nAttr.setDefault(false); aLightShadowFraction = nAttr.create("lightShadowFraction", "lsf", MFnNumericData::kFloat); nAttr.setStorable(false); nAttr.setHidden(true); nAttr.setReadable(true); nAttr.setWritable(false); nAttr.setDefault(0.0f); aPreShadowIntensity = nAttr.create("preShadowIntensity", "psi", MFnNumericData::kFloat); nAttr.setStorable(false); nAttr.setHidden(true); nAttr.setReadable(true); nAttr.setWritable(false); nAttr.setDefault(0.0f); aLightBlindData = nAttr.createAddr("lightBlindData", "lbld"); nAttr.setStorable(false); nAttr.setHidden(true); nAttr.setReadable(true); nAttr.setWritable(false); aLightData = lAttr.create( "lightDataArray", "ltd", aLightDirection, aLightIntensity, aLightAmbient, aLightDiffuse, aLightSpecular, aLightShadowFraction, aPreShadowIntensity, aLightBlindData); lAttr.setArray(true); lAttr.setStorable(false); lAttr.setHidden(true); lAttr.setDefault(0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, true, true, false, 0.0f, 1.0f, NULL); addAttribute(aLightData); addAttribute(aOutColor); addAttribute(aOutTransparency); addAttribute(aViewColor); attributeAffects (aViewColor, aOutColor); attributeAffects (aLightIntensity, aOutColor); attributeAffects (aLightData, aOutColor); attributeAffects (aLightAmbient, aOutColor); attributeAffects (aLightSpecular, aOutColor); attributeAffects (aLightDiffuse, aOutColor); attributeAffects (aLightDirection, aOutColor); attributeAffects (aLightShadowFraction, aOutColor); attributeAffects (aPreShadowIntensity, aOutColor); attributeAffects (aLightBlindData, aOutColor); attributeAffects (aViewColor, aOutTransparency); attributeAffects (aLightIntensity, aOutTransparency); attributeAffects (aLightData, aOutTransparency); attributeAffects (aLightAmbient, aOutTransparency); attributeAffects (aLightSpecular, aOutTransparency); attributeAffects (aLightDiffuse, aOutTransparency); attributeAffects (aLightDirection, aOutTransparency); attributeAffects (aLightShadowFraction, aOutTransparency); attributeAffects (aPreShadowIntensity, aOutTransparency); attributeAffects (aLightBlindData, aOutTransparency); 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; }
// // DESCRIPTION: /////////////////////////////////////////////////////// MStatus InterpNode::initialize() { MFnNumericAttribute nAttr; // Inputs and Attributes // // User defined attributes require a long-name and short-name that // are required to be unique within the node. // (See the compound attribute color1 named "Sides".) // // Rendering attributes that your node wants to get from the sampler // require them to be defined given the pre-defined unique long-name. // (See the compound attribute aNormalCamera named "normalCamera".) // // User defined Attributes are generally something that you want // to store in the Maya file. The setStorable(true) method enables // an attribute to be stored into the Maya scene file. // // Rendering attributes are primarily data that is generated per sample and // not something that you want to store in a file. To disable an // attribute from being recorded to the Maya scene file use // the setStorable(false) method. // // Simple attributes that represent a range of values can enable a // slider on the Attribute Editor by using the methods setMin() and // setMax(). // (See the simple attribute InputValue named "Power".) // // Compound attributes that represent a vector of 3 floats can enable // a color swatch on the Attribute Editor that will launch a color picker // tool by using the method setUsedAsColor(true). // (See the compound attribute color1 name "Sides".) // // Both Simple and Compound attributes can be initialized with a // default value using the method setDefault(). // // Attributes by default show up in the Attribute Editor and // in the Connection Editor unless they are specified as being hidden // by using the method setHidden(true). // // Attributes by default have both read/write access in the dependency graph. // To change an attributes behaviour you can use the methods // setReadable() and setWritable(). The method setReadable(true) // indicates that the attribute can be used as the source in // a dependency graph connection. The method setWritable(true) // indicates that the attribute can be used as the destination // in a dependency graph connection. // (See the compound attribute aOutColor named "outColor" below. // It has been marked as a read-only attribute since it is // the computed result of the node, it is not stored in the Maya file since // it is always computed, and it is marked as hidden to prevent it // from being displayed in the user interface.) // // // User defined input value aInputValue = nAttr.create( "power", "pow", MFnNumericData::kFloat); CHECK_MSTATUS ( nAttr.setDefault(1.0f) ); CHECK_MSTATUS ( nAttr.setMin(0.0f) ); CHECK_MSTATUS ( nAttr.setMax(3.0f) ); CHECK_MSTATUS ( nAttr.setKeyable(true) ); CHECK_MSTATUS ( nAttr.setStorable(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(true) ); // User defined color attribute aColor1 = nAttr.createColor( "sideColor", "sc"); CHECK_MSTATUS ( nAttr.setDefault(1.0f, 1.0f, 1.0f) ); CHECK_MSTATUS ( nAttr.setKeyable(true) ); CHECK_MSTATUS ( nAttr.setStorable(true) ); CHECK_MSTATUS ( nAttr.setUsedAsColor(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(true) ); aColor2 = nAttr.createColor( "facingColor", "fc"); CHECK_MSTATUS ( nAttr.setDefault(0.0f, 0.0f, 0.0f) ); CHECK_MSTATUS ( nAttr.setKeyable(true) ); CHECK_MSTATUS ( nAttr.setStorable(true) ); CHECK_MSTATUS ( nAttr.setUsedAsColor(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(true) ); // Surface Normal supplied by the render sampler aNormalCamera = nAttr.createPoint( "normalCamera", "n"); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(true) ); // Point on surface in camera space, will be used to compute view vector aPointCamera = nAttr.createPoint( "pointCamera", "p"); CHECK_MSTATUS ( nAttr.setStorable(false) ); CHECK_MSTATUS ( nAttr.setHidden(true) ); CHECK_MSTATUS ( nAttr.setReadable(true) ); CHECK_MSTATUS ( nAttr.setWritable(true) ); // Outputs // // Always set your output attributes to be read-only // You should also mark any internal attributes that your node // computes to be read-only also, this will prevent any connections. 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) ); CHECK_MSTATUS ( addAttribute(aInputValue) ); CHECK_MSTATUS ( addAttribute(aColor1) ); CHECK_MSTATUS ( addAttribute(aColor2) ); CHECK_MSTATUS ( addAttribute(aNormalCamera) ); CHECK_MSTATUS ( addAttribute(aPointCamera) ); CHECK_MSTATUS ( addAttribute(aOutColor) ); CHECK_MSTATUS ( attributeAffects (aInputValue, aOutColor) ); CHECK_MSTATUS ( attributeAffects (aColor1, aOutColor) ); CHECK_MSTATUS ( attributeAffects (aColor2, aOutColor) ); CHECK_MSTATUS ( attributeAffects (aNormalCamera, aOutColor) ); CHECK_MSTATUS ( attributeAffects (aPointCamera, aOutColor) ); return MS::kSuccess; }
MStatus inSpecular::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 ------------------------------------ backface_emit = nAttr.create("backface_emit", "backface_emit", MFnNumericData::kBoolean, false); CHECK_MSTATUS(addAttribute( backface_emit )); layer = nAttr.create("layer", "layer", MFnNumericData::kInt, 0); CHECK_MSTATUS(addAttribute( layer )); iesProfile = tAttr.create("iesProfile", "iesProfile", MFnNumericData::kString); CHECK_MSTATUS(addAttribute( iesProfile )); internal_medium_name = mAttr.create("internal_medium_name", "internal_medium_name"); CHECK_MSTATUS(addAttribute( internal_medium_name )); bump = nAttr.create("bump", "bump", MFnNumericData::kFloat, 0.0); CHECK_MSTATUS(addAttribute( bump )); base_emission = nAttr.createColor("base_emission", "base_emission"); nAttr.setDefault(0.0,0.0,0.0); CHECK_MSTATUS(addAttribute( base_emission )); displacement = nAttr.create("displacement", "displacement", MFnNumericData::kFloat, 0.0); CHECK_MSTATUS(addAttribute( displacement )); emission = nAttr.createColor("emission", "emission"); nAttr.setDefault(0.0,0.0,0.0); CHECK_MSTATUS(addAttribute( emission )); normalMap = nAttr.createColor("normalMap", "normalMap"); nAttr.setDefault(0,0,0); CHECK_MSTATUS(addAttribute( normalMap )); transparent = nAttr.create("transparent", "transparent", MFnNumericData::kBoolean, false); CHECK_MSTATUS(addAttribute( transparent )); //---------------------------- 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 ); }
MStatus OnbShader::initialize() { MFnNumericAttribute nAttr; MFnLightDataAttribute lAttr; // Outputs MObject outcR = nAttr.create("outColorR", "ocr", MFnNumericData::kFloat, 0.0); MObject outcG = nAttr.create("outColorG", "ocg", MFnNumericData::kFloat, 0.0); MObject outcB = nAttr.create("outColorB", "ocb", MFnNumericData::kFloat, 0.0); aOutColor = nAttr.create("outColor", "oc", outcR, outcG, outcB); MAKE_OUTPUT(nAttr); CHECK_MSTATUS(nAttr.setUsedAsColor(true)); MObject outtR = nAttr.create("outTransparencyR", "otr", MFnNumericData::kFloat, 0.0); MObject outtG = nAttr.create("outTransparencyG", "otg", MFnNumericData::kFloat, 0.0); MObject outtB = nAttr.create("outTransparencyB", "otb", MFnNumericData::kFloat, 0.0); aOutTransparency = nAttr.create("outTransparency", "ot", outtR, outtG, outtB); MAKE_OUTPUT(nAttr); CHECK_MSTATUS(nAttr.setUsedAsColor(true)); // Inputs MObject cR = nAttr.create("colorR", "cr", MFnNumericData::kFloat, 0.5); MObject cG = nAttr.create("colorG", "cg", MFnNumericData::kFloat, 0.5); MObject cB = nAttr.create("colorB", "cb", MFnNumericData::kFloat, 0.5); aColor = nAttr.create("color", "c", cR, cG, cB); MAKE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setUsedAsColor(true)); aRoughness = nAttr.create("roughness", "r", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setMin(0.0f)); CHECK_MSTATUS(nAttr.setMax(1.0f)); CHECK_MSTATUS(nAttr.setDefault(0.3f)); MObject tR = nAttr.create("transparencyR", "itr", MFnNumericData::kFloat, 0.0); MObject tG = nAttr.create("transparencyG", "itg", MFnNumericData::kFloat, 0.0); MObject tB = nAttr.create("transparencyB", "itb", MFnNumericData::kFloat, 0.0); aTransparency = nAttr.create("transparency", "it", tR, tG, tB); MAKE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setUsedAsColor(true)); MObject aR = nAttr.create("ambientColorR", "acr", MFnNumericData::kFloat, 0.0); MObject aG = nAttr.create("ambientColorG", "acg", MFnNumericData::kFloat, 0.0); MObject aB = nAttr.create("ambientColorB", "acb", MFnNumericData::kFloat, 0.0); aAmbientColor = nAttr.create("ambientColor", "ambc", aR, aG, aB); MAKE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setUsedAsColor(true)); MObject iR = nAttr.create("incandescenceR", "ir", MFnNumericData::kFloat, 0.0); MObject iG = nAttr.create("incandescenceG", "ig", MFnNumericData::kFloat, 0.0); MObject iB = nAttr.create("incandescenceB", "ib", MFnNumericData::kFloat, 0.0); aIncandescence = nAttr.create("incandescence", "ic", iR, iG, iB); MAKE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setUsedAsColor(true)); MObject sR = nAttr.create("specularColorR", "sr", MFnNumericData::kFloat, 1.0); MObject sG = nAttr.create("specularColorG", "sg", MFnNumericData::kFloat, 1.0); MObject sB = nAttr.create("specularColorB", "sb", MFnNumericData::kFloat, 1.0); aSpecularColor = nAttr.create("specularColor", "sc", sR, sG, sB); MAKE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setUsedAsColor(true)); aEccentricity = nAttr.create("eccentricity", "ecc", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setMin(0.0f)); CHECK_MSTATUS(nAttr.setMax(1.0f)); CHECK_MSTATUS(nAttr.setDefault(0.1f)); aSpecularRollOff = nAttr.create("specularRollOff", "sro", MFnNumericData::kFloat); MAKE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setMin(0.0f)); CHECK_MSTATUS(nAttr.setMax(1.0f)); CHECK_MSTATUS(nAttr.setDefault(0.7f)); aNormalCamera = nAttr.createPoint("normalCamera", "n"); MAKE_INPUT(nAttr); CHECK_MSTATUS(nAttr.setDefault(1.0f, 1.0f, 1.0f)); // Attributes for compute() aRayDirection = nAttr.createPoint("rayDirection", "rd"); 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)); 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)); // Add Attributes CHECK_MSTATUS(addAttribute(aOutColor)); CHECK_MSTATUS(addAttribute(aOutTransparency)); CHECK_MSTATUS(addAttribute(aColor)); CHECK_MSTATUS(addAttribute(aRoughness)); CHECK_MSTATUS(addAttribute(aTransparency)); CHECK_MSTATUS(addAttribute(aAmbientColor)); CHECK_MSTATUS(addAttribute(aIncandescence)); CHECK_MSTATUS(addAttribute(aSpecularColor)); CHECK_MSTATUS(addAttribute(aEccentricity)); CHECK_MSTATUS(addAttribute(aSpecularRollOff)); CHECK_MSTATUS(addAttribute(aNormalCamera)); CHECK_MSTATUS(addAttribute(aRayDirection)); CHECK_MSTATUS(addAttribute(aLightData)); // Attribute affects relationships CHECK_MSTATUS(attributeAffects(aColor, aOutColor)); CHECK_MSTATUS(attributeAffects(aColor, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aRoughness, aOutColor)); CHECK_MSTATUS(attributeAffects(aRoughness, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aTransparency, aOutColor)); CHECK_MSTATUS(attributeAffects(aTransparency, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aAmbientColor, aOutColor)); CHECK_MSTATUS(attributeAffects(aAmbientColor, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aIncandescence, aOutColor)); CHECK_MSTATUS(attributeAffects(aIncandescence, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aSpecularColor, aOutColor)); CHECK_MSTATUS(attributeAffects(aSpecularColor, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aEccentricity, aOutColor)); CHECK_MSTATUS(attributeAffects(aEccentricity, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aNormalCamera, aOutColor)); CHECK_MSTATUS(attributeAffects(aNormalCamera, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aRayDirection, aOutColor)); CHECK_MSTATUS(attributeAffects(aRayDirection, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aSpecularRollOff, aOutColor)); CHECK_MSTATUS(attributeAffects(aSpecularRollOff, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aLightDirection, aOutColor)); CHECK_MSTATUS(attributeAffects(aLightDirection, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aLightIntensity, aOutColor)); CHECK_MSTATUS(attributeAffects(aLightIntensity, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aLightAmbient, aOutColor)); CHECK_MSTATUS(attributeAffects(aLightAmbient, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aLightDiffuse, aOutColor)); CHECK_MSTATUS(attributeAffects(aLightDiffuse, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aLightSpecular, aOutColor)); CHECK_MSTATUS(attributeAffects(aLightSpecular, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aLightShadowFraction, aOutColor)); CHECK_MSTATUS(attributeAffects(aLightShadowFraction, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aPreShadowIntensity, aOutColor)); CHECK_MSTATUS(attributeAffects(aPreShadowIntensity, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aLightBlindData, aOutColor)); CHECK_MSTATUS(attributeAffects(aLightBlindData, aOutTransparency)); CHECK_MSTATUS(attributeAffects(aLightData, aOutColor)); CHECK_MSTATUS(attributeAffects(aLightData, aOutTransparency)); return MS::kSuccess; }
MStatus meshOpNode::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 status; MFnTypedAttribute attrFn; MFnEnumAttribute enumFn; cpList = attrFn.create("inputComponents", "ics", MFnComponentListData::kComponentList); attrFn.setStorable(true); // To be stored during file-save opType = enumFn.create("operationType", "oprt", 0, &status); enumFn.addField("subd_edges", 0); enumFn.addField("subd_faces", 1); enumFn.setHidden(false); enumFn.setKeyable(true); enumFn.setStorable(true); // To be stored during file-save inMesh = attrFn.create("inMesh", "im", MFnMeshData::kMesh); attrFn.setStorable(true); // To be stored during file-save // Attribute is read-only because it is an output attribute // outMesh = attrFn.create("outMesh", "om", MFnMeshData::kMesh); attrFn.setStorable(false); attrFn.setWritable(false); // Add the attributes we have created to the node // status = addAttribute( cpList ); if (!status) { status.perror("addAttribute"); return status; } status = addAttribute( opType ); if (!status) { status.perror("addAttribute"); return status; } status = addAttribute( inMesh ); if (!status) { status.perror("addAttribute"); return status; } status = addAttribute( outMesh); if (!status) { status.perror("addAttribute"); return status; } // 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. // status = attributeAffects( inMesh, outMesh ); if (!status) { status.perror("attributeAffects"); return status; } status = attributeAffects( cpList, outMesh ); if (!status) { status.perror("attributeAffects"); return status; } status = attributeAffects( opType, outMesh ); if (!status) { status.perror("attributeAffects"); return status; } return MS::kSuccess; }
// initialize // ------------ //! Initialises the Attributes on the node, and set the evaluation dependencies MStatus NBuddySurfaceToBodyNode::initialize() { MStatus status; //Function sets needed MFnStringData stringData; MFnPluginData dataFn; MFnMatrixData matrixFn; MFnGenericAttribute genFn; MFnTypedAttribute typedAttr; MFnNumericAttribute numAttr; MFnMatrixAttribute mAttr; //Attribute that specifies if the object should be converted to worldspace or localspace _useTransform = numAttr.create( "useTransform", "ut", MFnNumericData::kBoolean, true, &status ); NM_CheckMStatus(status, "ERROR creating useWorldSpace attribute.\n"); status = addAttribute( _useTransform ); //The input transform for the object _inTransform = mAttr.create("inTransform","it", MFnMatrixAttribute::kDouble, &status); mAttr.setStorable( true ); mAttr.setConnectable(true); NM_CheckMStatus(status, "ERROR creating inTransform attribute.\n"); status = addAttribute( _inTransform ); NM_CheckMStatus(status, "ERROR adding inTransform attribute.\n"); //Create the inSurface plug _inSurface = genFn.create( "inSurface", "surf", &status); NM_CheckMStatus( status, "Failed to create inSurface GenericAttribute"); genFn.addAccept(MFnData::kNurbsSurface); genFn.addAccept(MFnData::kMesh); genFn.addAccept(MFnData::kSubdSurface); genFn.setStorable(false); genFn.setCached(false); status = addAttribute( _inSurface ); NM_CheckMStatus(status, "ERROR adding inSurface attribute.\n"); // Create the attribute for the body output _outBody = typedAttr.create("outBody","ob" , naiadBodyData::id , MObject::kNullObj , &status); NM_CheckMStatus(status, "ERROR creating outBody attribute.\n"); typedAttr.setKeyable( false ); typedAttr.setWritable( false ); typedAttr.setReadable( true ); typedAttr.setStorable( false ); status = addAttribute( _outBody ); NM_CheckMStatus(status, "ERROR adding outBody attribute.\n"); // Create the attribute for the body name _bodyName = typedAttr.create( "bodyName", "bn", MFnData::kString ,stringData.create( MString("mesh-body") ), &status); NM_CheckMStatus( status, "Failed to create bodyName attribute"); typedAttr.setStorable( true ); typedAttr.setArray( false ); status = addAttribute( _bodyName ); NM_CheckMStatus( status, "Failed to add bodyName plug"); //Tesselation settings _subDivide = numAttr.create( "subDivide", "td", MFnNumericData::kInt , 0, &status); NM_CheckMStatus( status, "Failed to create subDivide attribute"); numAttr.setStorable( true ); numAttr.setArray( false ); status = addAttribute( _subDivide ); NM_CheckMStatus( status, "Failed to add bodyName plug"); // Attribute affects attributeAffects( _bodyName, _outBody ); attributeAffects( _subDivide, _outBody ); attributeAffects( _inSurface, _outBody ); attributeAffects( _useTransform, _outBody ); attributeAffects( _inTransform, _outBody ); return MS::kSuccess; }
MStatus hwPhongShader::initialize() { // Make sure that all attributes are cached internal for // optimal performance ! TRACE_API_CALLS("initialize"); MFnNumericAttribute nAttr; // Create input attributes aColor = nAttr.createColor( "color", "c"); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setDefault(0.1f, 0.1f, 0.1f); nAttr.setCached( true ); nAttr.setInternal( true ); aDiffuseColor = nAttr.createColor( "diffuseColor", "dc" ); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setDefault(1.f, 0.5f, 0.5f); nAttr.setCached( true ); nAttr.setInternal( true ); aSpecularColor = nAttr.createColor( "specularColor", "sc" ); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setDefault(0.5f, 0.5f, 0.5f); nAttr.setCached( true ); nAttr.setInternal( true ); // This is defined as a point, so that users can easily enter // values beyond 1. aShininess = nAttr.createPoint( "shininess", "sh" ); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setDefault(100.0f, 100.0f, 100.0f); nAttr.setCached( true ); nAttr.setInternal( true ); aGeometryShape = nAttr.create( "geometryShape", "gs", MFnNumericData::kInt ); nAttr.setStorable(true); nAttr.setKeyable(true); nAttr.setDefault(0); nAttr.setCached( true ); nAttr.setInternal( true ); // create output attributes here // outColor is the only output attribute and it is inherited // so we do not need to create or add it. // // Add the attributes here addAttribute(aColor); addAttribute(aDiffuseColor); addAttribute(aSpecularColor); addAttribute(aShininess); addAttribute(aGeometryShape); attributeAffects (aColor, outColor); attributeAffects (aDiffuseColor, outColor); attributeAffects (aSpecularColor, outColor); attributeAffects (aShininess, outColor); 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;} } { // 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::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;} } 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( 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;} return MS::kSuccess; }