MStatus HesMeshNode::initialize() { MFnNumericAttribute numAttr; MStatus stat; MFnTypedAttribute stringAttr; input = stringAttr.create( "hesPath", "hsp", MFnData::kString ); stringAttr.setStorable(true); addAttribute( input ); ameshname = stringAttr.create( "meshName", "mn", MFnData::kString ); stringAttr.setStorable(true); stringAttr.setArray(true); stringAttr.setDisconnectBehavior(MFnAttribute::kDelete); addAttribute( ameshname ); MFnTypedAttribute meshAttr; outMesh = meshAttr.create( "outMesh", "o", MFnData::kMesh ); meshAttr.setStorable(false); meshAttr.setWritable(false); meshAttr.setArray(true); meshAttr.setDisconnectBehavior(MFnAttribute::kDelete); addAttribute( outMesh ); attributeAffects( input, outMesh ); return MS::kSuccess; }
MStatus OpenSubdivPtexShader::initialize() { MFnTypedAttribute typedAttr; MFnNumericAttribute numAttr; MFnEnumAttribute enumAttr; // level aLevel = numAttr.create("level", "lv", MFnNumericData::kLong, 3); numAttr.setInternal(true); numAttr.setMin(1); numAttr.setSoftMax(5); numAttr.setMax(10); // tessFactor aTessFactor = numAttr.create("tessFactor", "tessf", MFnNumericData::kLong, 2); numAttr.setInternal(true); numAttr.setMin(1); numAttr.setMax(10); // scheme aScheme = enumAttr.create("scheme", "sc", OsdPtexMeshData::kCatmark); enumAttr.addField("Catmull-Clark", OsdPtexMeshData::kCatmark); enumAttr.addField("Loop", OsdPtexMeshData::kLoop); enumAttr.addField("Bilinear", OsdPtexMeshData::kBilinear); enumAttr.setInternal(true); // kernel aKernel = enumAttr.create("kernel", "kn", OsdPtexMeshData::kCPU); enumAttr.addField("CPU", OsdPtexMeshData::kCPU); #ifdef OPENSUBDIV_HAS_OPENMP enumAttr.addField("OpenMP", OsdPtexMeshData::kOPENMP); #endif #ifdef OPENSUBDIV_HAS_OPENCL enumAttr.addField("CL", OsdPtexMeshData::kCL); #endif #ifdef OPENSUBDIV_HAS_CUDA enumAttr.addField("CUDA", OsdPtexMeshData::kCUDA); #endif enumAttr.setInternal(true); // interpolateBoundary aInterpolateBoundary = enumAttr.create("interpolateBoundary", "ib", OsdPtexMeshData::kInterpolateBoundaryNone); enumAttr.addField("None", OsdPtexMeshData::kInterpolateBoundaryNone); enumAttr.addField("Edge Only", OsdPtexMeshData::kInterpolateBoundaryEdgeOnly); enumAttr.addField("Edge and Corner", OsdPtexMeshData::kInterpolateBoundaryEdgeAndCorner); enumAttr.addField("Always Sharp", OsdPtexMeshData::kInterpolateBoundaryAlwaysSharp); enumAttr.setInternal(true); // adaptive aAdaptive = numAttr.create("adaptive", "adp", MFnNumericData::kBoolean, true); numAttr.setInternal(true); // wireframe aWireframe = numAttr.create("wireframe", "wf", MFnNumericData::kBoolean, false); // material attributes aDiffuse = numAttr.createColor("diffuse", "d"); numAttr.setDefault(0.6f, 0.6f, 0.7f); aAmbient = numAttr.createColor("ambient", "a"); numAttr.setDefault(0.1f, 0.1f, 0.1f); aSpecular = numAttr.createColor("specular", "s"); numAttr.setDefault(0.3f, 0.3f, 0.3f); // Ptex Texture Attributes // // diffuseEnvironmentMapFile; aDiffuseEnvironmentMapFile = typedAttr.create("diffuseEnvironmentMap", "difenv", MFnData::kString); typedAttr.setInternal(true); // don't let maya hold on to string when fileNode is disconnected typedAttr.setDisconnectBehavior(MFnAttribute::kReset); // specularEnvironmentMapFile; aSpecularEnvironmentMapFile = typedAttr.create("specularEnvironmentMap", "specenv", MFnData::kString); typedAttr.setInternal(true); // don't let maya hold on to string when fileNode is disconnected typedAttr.setDisconnectBehavior(MFnAttribute::kReset); // colorFile; aColorFile = typedAttr.create("colorFile", "cf", MFnData::kString); typedAttr.setInternal(true); // displacementFile; aDisplacementFile = typedAttr.create("displacementFile", "df", MFnData::kString); typedAttr.setInternal(true); // occlusionFile; aOcclusionFile = typedAttr.create("occlusionFile", "of", MFnData::kString); typedAttr.setInternal(true); // enableDisplacement; aEnableDisplacement = numAttr.create("enableDisplacement", "end", MFnNumericData::kBoolean, 1); numAttr.setInternal(true); // enableColor; aEnableColor = numAttr.create("enableColor", "enc", MFnNumericData::kBoolean, 1); numAttr.setInternal(true); // enableOcclusion; aEnableOcclusion = numAttr.create("enableOcclusion", "eno", MFnNumericData::kBoolean, 1); numAttr.setInternal(true); // enableNormal; aEnableNormal = numAttr.create("enableNormal", "enn", MFnNumericData::kBoolean, 1); numAttr.setInternal(true); // fresnelBias; aFresnelBias = numAttr.create("fresnelBias", "fb", MFnNumericData::kFloat, 0.2f); numAttr.setMin(0); numAttr.setMax(1); // fresnelScale; aFresnelScale = numAttr.create("fresnelScale", "fs", MFnNumericData::kFloat, 1.0f); numAttr.setMin(0); numAttr.setSoftMax(1); // fresnelPower; aFresnelPower = numAttr.create("fresnelPower", "fp", MFnNumericData::kFloat, 5.0f); numAttr.setMin(0); numAttr.setSoftMax(10); // shaderSource; aShaderSource = typedAttr.create("shaderSource", "ssrc", MFnData::kString); typedAttr.setInternal(true); // add attributes addAttribute(aLevel); addAttribute(aTessFactor); addAttribute(aScheme); addAttribute(aKernel); addAttribute(aInterpolateBoundary); addAttribute(aAdaptive); addAttribute(aWireframe); addAttribute(aDiffuse); addAttribute(aAmbient); addAttribute(aSpecular); addAttribute(aShaderSource); addAttribute(aDiffuseEnvironmentMapFile); addAttribute(aSpecularEnvironmentMapFile); addAttribute(aColorFile); addAttribute(aDisplacementFile); addAttribute(aOcclusionFile); addAttribute(aEnableDisplacement); addAttribute(aEnableColor); addAttribute(aEnableOcclusion); addAttribute(aEnableNormal); addAttribute(aFresnelBias); addAttribute(aFresnelScale); addAttribute(aFresnelPower); return MS::kSuccess; }
MStatus geometrySurfaceConstraint::initialize() { MFnNumericAttribute nAttr; MStatus status; // constraint attributes { // Geometry: mesh, readable, not writable, delete on disconnect MFnTypedAttribute typedAttrNotWritable; geometrySurfaceConstraint::constraintGeometry = typedAttrNotWritable.create( "constraintGeometry", "cg", MFnData::kMesh, &status ); if (!status) { status.perror("typedAttrNotWritable.create:cgeom"); return status;} status = typedAttrNotWritable.setReadable(true); if (!status) { status.perror("typedAttrNotWritable.setReadable:cgeom"); return status;} status = typedAttrNotWritable.setWritable(false); if (!status) { status.perror("typedAttrNotWritable.setWritable:cgeom"); return status;} status = typedAttrNotWritable.setDisconnectBehavior(MFnAttribute::kDelete); if (!status) { status.perror("typedAttrNotWritable.setDisconnectBehavior:cgeom"); return status;} } // Parent inverse matrix: delete on disconnect MFnTypedAttribute typedAttr; geometrySurfaceConstraint::constraintParentInverseMatrix = typedAttr.create( "constraintPim", "ci", MFnData::kMatrix, &status ); if (!status) { status.perror("typedAttr.create:matrix"); return status;} status = typedAttr.setDisconnectBehavior(MFnAttribute::kDelete); if (!status) { status.perror("typedAttr.setDisconnectBehavior:cgeom"); return status;} // Target geometry: mesh, delete on disconnect geometrySurfaceConstraint::targetGeometry = typedAttr.create( "targetGeometry", "tg", MFnData::kMesh, &status ); if (!status) { status.perror("typedAttr.create:tgeom"); return status;} status = typedAttr.setDisconnectBehavior(MFnAttribute::kDelete); if (!status) { status.perror("typedAttr.setDisconnectBehavior:cgeom"); return status;} targetTransform = typedAttr.create( "targetTransform", "ttm", MFnData::kMatrix, &status ); if (!status) { status.perror("typedAttr.create:targetTransform"); return status;} status = typedAttr.setDisconnectBehavior(MFnAttribute::kDelete); if (!status) { status.perror("typedAttr.setDisconnectBehavior:targetTransform"); return status;} // Target weight: double, min 0, default 1.0, keyable, delete on disconnect MFnNumericAttribute typedAttrKeyable; geometrySurfaceConstraint::targetWeight = typedAttrKeyable.create( "weight", "wt", MFnNumericData::kDouble, 1.0, &status ); if (!status) { status.perror("typedAttrKeyable.create:weight"); return status;} status = typedAttrKeyable.setMin( (double) 0 ); if (!status) { status.perror("typedAttrKeyable.setMin"); return status;} status = typedAttrKeyable.setKeyable( true ); if (!status) { status.perror("typedAttrKeyable.setKeyable"); return status;} status = typedAttrKeyable.setDisconnectBehavior(MFnAttribute::kDelete); if (!status) { status.perror("typedAttrKeyable.setDisconnectBehavior:cgeom"); return status;} { // Compound target(geometry,weight): array, delete on disconnect MFnCompoundAttribute compoundAttr; geometrySurfaceConstraint::compoundTarget = compoundAttr.create( "target", "tgt",&status ); if (!status) { status.perror("compoundAttr.create"); return status;} status = compoundAttr.addChild( geometrySurfaceConstraint::targetTransform ); if (!status) { status.perror("compoundAttr.addChild targetTransform"); return status;} status = compoundAttr.addChild( geometrySurfaceConstraint::targetGeometry ); if (!status) { status.perror("compoundAttr.addChild"); return status;} status = compoundAttr.addChild( geometrySurfaceConstraint::targetWeight ); if (!status) { status.perror("compoundAttr.addChild"); return status;} status = compoundAttr.setArray( true ); if (!status) { status.perror("compoundAttr.setArray"); return status;} status = compoundAttr.setDisconnectBehavior(MFnAttribute::kDelete); if (!status) { status.perror("typedAttrKeyable.setDisconnectBehavior:cgeom"); return status;} } MFnNumericAttribute numAttr; constraintTranslateX = numAttr.create( "constraintTranslateX", "ctx", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintTranslateX"); return status; } numAttr.setReadable(true); numAttr.setWritable(false); addAttribute(constraintTranslateX); constraintTranslateY = numAttr.create( "constraintTranslateY", "cty", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintTranslateY"); return status; } numAttr.setReadable(true); numAttr.setWritable(false); addAttribute(constraintTranslateY); constraintTranslateZ = numAttr.create( "constraintTranslateZ", "ctz", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintTranslateY"); return status; } numAttr.setReadable(true); numAttr.setWritable(false); addAttribute(constraintTranslateZ); constraintTargetX = numAttr.create( "constraintTargetX", "ttx", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintTargetX"); return status; } addAttribute(constraintTargetX); constraintTargetY = numAttr.create( "constraintTargetY", "tty", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintTargetY"); return status; } addAttribute(constraintTargetY); constraintTargetZ = numAttr.create( "constraintTargetZ", "ttz", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintTargetZ"); return status; } addAttribute(constraintTargetZ); constraintObjectX = numAttr.create( "constraintObjectX", "otx", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintObjectX"); return status; } addAttribute(constraintObjectX); constraintObjectY = numAttr.create( "constraintObjectY", "oty", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintObjectY"); return status; } addAttribute(constraintObjectY); constraintObjectZ = numAttr.create( "constraintObjectZ", "otz", MFnNumericData::kDouble, 0.0, &status ); if(!status) { MGlobal::displayInfo("failed to create attrib constraintObjectZ"); return status; } addAttribute(constraintObjectZ); targetOffset = numAttr.create("targetOffset", "tgo", MFnNumericData::k3Double, 0.0, &status); if (!status) { status.perror("addAttribute targetOffset"); return status;} addAttribute(targetOffset); targetRestP = numAttr.create("targetRestAt", "tgrt", MFnNumericData::k3Double, 0.0, &status); if (!status) { status.perror("addAttribute targetRestAt"); return status;} addAttribute(targetRestP); status = addAttribute( geometrySurfaceConstraint::constraintParentInverseMatrix ); if (!status) { status.perror("addAttribute"); return status;} status = addAttribute( geometrySurfaceConstraint::constraintGeometry ); if (!status) { status.perror("addAttribute"); return status;} status = addAttribute( geometrySurfaceConstraint::compoundTarget ); if (!status) { status.perror("addAttribute"); return status;} status = attributeAffects( compoundTarget, constraintGeometry ); if (!status) { status.perror("attributeAffects"); return status;} status = attributeAffects( targetTransform, constraintGeometry ); if (!status) { status.perror("attributeAffects"); return status;} status = attributeAffects( targetGeometry, constraintGeometry ); if (!status) { status.perror("attributeAffects"); return status;} status = attributeAffects( targetWeight, constraintGeometry ); if (!status) { status.perror("attributeAffects"); return status;} status = attributeAffects( constraintParentInverseMatrix, constraintGeometry ); if (!status) { status.perror("attributeAffects"); return status;} attributeAffects(targetTransform, constraintTranslateX); attributeAffects(targetTransform, constraintTranslateY); attributeAffects(targetTransform, constraintTranslateZ); return MS::kSuccess; }
MStatus OpenSubdivShader::initialize() { MFnTypedAttribute typedAttr; MFnNumericAttribute numAttr; MFnEnumAttribute enumAttr; // Subdivision level aLevel = numAttr.create("level", "lv", MFnNumericData::kLong, 3); numAttr.setInternal(true); numAttr.setMin(1); numAttr.setSoftMax(5); numAttr.setMax(10); addAttribute(aLevel); // GPU tesselation factor aTessFactor = numAttr.create("tessFactor", "tessf", MFnNumericData::kLong, 2); numAttr.setInternal(true); numAttr.setMin(1); numAttr.setMax(10); addAttribute(aTessFactor); // Subdivision scheme aScheme = enumAttr.create("scheme", "sc", OsdMeshData::kCatmark); enumAttr.setInternal(true); enumAttr.addField("Catmull-Clark", OsdMeshData::kCatmark); enumAttr.addField("Loop", OsdMeshData::kLoop); enumAttr.addField("Bilinear", OsdMeshData::kBilinear); addAttribute(aScheme); // Computation kernel aKernel = enumAttr.create("kernel", "kn", OsdMeshData::kCPU); enumAttr.setInternal(true); enumAttr.addField("CPU", OsdMeshData::kCPU); #ifdef OPENSUBDIV_HAS_OPENMP enumAttr.addField("OpenMP", OsdMeshData::kOPENMP); #endif #ifdef OPENSUBDIV_HAS_OPENCL enumAttr.addField("CL", OsdMeshData::kCL); #endif #ifdef OPENSUBDIV_HAS_CUDA enumAttr.addField("CUDA", OsdMeshData::kCUDA); #endif addAttribute(aKernel); // Boundary interpolation flag aInterpolateBoundary = enumAttr.create("interpolateBoundary", "ib", OsdMeshData::kInterpolateBoundaryNone); enumAttr.addField("None", OsdMeshData::kInterpolateBoundaryNone); enumAttr.addField("Edge Only", OsdMeshData::kInterpolateBoundaryEdgeOnly); enumAttr.addField("Edge and Corner", OsdMeshData::kInterpolateBoundaryEdgeAndCorner); enumAttr.addField("Always Sharp", OsdMeshData::kInterpolateBoundaryAlwaysSharp); enumAttr.setInternal(true); addAttribute(aInterpolateBoundary); // Feature-adaptive toggle aAdaptive = numAttr.create("adaptive", "adp", MFnNumericData::kBoolean, true); numAttr.setInternal(true); addAttribute(aAdaptive); // Wireframe display toggle aWireframe = numAttr.create("wireframe", "wf", MFnNumericData::kBoolean, false); addAttribute(aWireframe); // Material attributes aDiffuse = numAttr.createColor("diffuse", "d"); numAttr.setDefault(0.6f, 0.6f, 0.7f); addAttribute(aDiffuse); aAmbient = numAttr.createColor("ambient", "a"); numAttr.setDefault(0.1f, 0.1f, 0.1f); addAttribute(aAmbient); aSpecular = numAttr.createColor("specular", "s"); numAttr.setDefault(0.3f, 0.3f, 0.3f); addAttribute(aSpecular); aShininess = numAttr.create("shininess", "shin", MFnNumericData::kFloat, 50.0f); numAttr.setMin(0); numAttr.setSoftMax(128.0f); addAttribute(aShininess); // Texture attributes aDiffuseMapFile = typedAttr.create("diffuseMap", "difmap", MFnData::kString); typedAttr.setInternal(true); /* don't let maya hold on to string when fileNode is disconnected */ typedAttr.setDisconnectBehavior(MFnAttribute::kReset); addAttribute(aDiffuseMapFile); // UV set (defaults to current UV set) aUVSet = typedAttr.create("uvSet", "uvs", MFnData::kString); typedAttr.setInternal(true); addAttribute(aUVSet); // Boundary interpolation flag for face-varying data (UVs) aInterpolateUVBoundary = enumAttr.create("interpolateUVBoundary", "iuvb", OsdMeshData::kInterpolateBoundaryNone); enumAttr.addField("None", OsdMeshData::kInterpolateBoundaryNone); enumAttr.addField("Edge Only", OsdMeshData::kInterpolateBoundaryEdgeOnly); enumAttr.addField("Edge and Corner", OsdMeshData::kInterpolateBoundaryEdgeAndCorner); enumAttr.addField("Always Sharp", OsdMeshData::kInterpolateBoundaryAlwaysSharp); enumAttr.setInternal(true); addAttribute(aInterpolateUVBoundary); // Optional shader source filename aShaderSource = typedAttr.create("shaderSource", "ssrc", MFnData::kString); typedAttr.setInternal(true); addAttribute(aShaderSource); return MS::kSuccess; }
MStatus ProxyViz::initialize() { MFnNumericAttribute numFn; MStatus stat; alodgatehigh = numFn.create( "lodGateMax", "ldmx", MFnNumericData::kFloat, 1.f); numFn.setKeyable(true); numFn.setStorable(true); numFn.setMin(0.001f); numFn.setMax(2.f); addAttribute(alodgatehigh); alodgatelow = numFn.create( "lodGateMin", "ldmin", MFnNumericData::kFloat, 0.f); numFn.setKeyable(true); numFn.setStorable(true); numFn.setMin(0.f); numFn.setMax(0.999f); addAttribute(alodgatelow); abboxminx = numFn.create( "bBoxMinX", "bbmnx", MFnNumericData::kFloat, -1.f ); numFn.setKeyable(true); numFn.setStorable(true); addAttribute(abboxminx); abboxminy = numFn.create( "bBoxMinY", "bbmny", MFnNumericData::kFloat, -1.f ); numFn.setKeyable(true); numFn.setStorable(true); addAttribute(abboxminy); abboxminz = numFn.create( "bBoxMinZ", "bbmnz", MFnNumericData::kFloat, -1.f ); numFn.setKeyable(true); numFn.setStorable(true); addAttribute(abboxminz); abboxmaxx = numFn.create( "bBoxMaxX", "bbmxx", MFnNumericData::kFloat, 1.f ); numFn.setKeyable(true); numFn.setStorable(true); addAttribute(abboxmaxx); abboxmaxy = numFn.create( "bBoxMaxY", "bbmxy", MFnNumericData::kFloat, 1.f); numFn.setKeyable(true); numFn.setStorable(true); addAttribute(abboxmaxy); abboxmaxz = numFn.create( "bBoxMaxZ", "bbmxz", MFnNumericData::kFloat, 1.f); numFn.setKeyable(true); numFn.setStorable(true); addAttribute(abboxmaxz); aradiusMult = numFn.create( "radiusMultiplier", "rml", MFnNumericData::kFloat); numFn.setStorable(true); numFn.setKeyable(true); numFn.setDefault(1.f); numFn.setMin(.05f); addAttribute(aradiusMult); axmultiplier = numFn.create( "visualMultiplierX", "vmx", MFnNumericData::kFloat, 1.f); numFn.setKeyable(true); numFn.setStorable(true); numFn.setMin(0.001f); addAttribute(axmultiplier); aymultiplier = numFn.create( "visualMultiplierY", "vmy", MFnNumericData::kFloat, 1.f); numFn.setKeyable(true); numFn.setStorable(true); numFn.setMin(0.001f); addAttribute(aymultiplier); azmultiplier = numFn.create( "visualMultiplierZ", "vmz", MFnNumericData::kFloat, 1.f); numFn.setKeyable(true); numFn.setStorable(true); numFn.setMin(0.001f); addAttribute(azmultiplier); agroupcount = numFn.create( "numberInstances", "nis", MFnNumericData::kInt, 1); numFn.setKeyable(false); numFn.setStorable(true); numFn.setMin(1); addAttribute(agroupcount); ainstanceId = numFn.create( "instanceId", "iis", MFnNumericData::kInt, 0); numFn.setKeyable(false); numFn.setStorable(true); numFn.setMin(0); addAttribute(ainstanceId); MFnTypedAttribute typedAttrFn; MVectorArray defaultVectArray; MFnVectorArrayData vectArrayDataFn; vectArrayDataFn.create( defaultVectArray ); outPositionPP = typedAttrFn.create( "outPosition", "opos", MFnData::kVectorArray, vectArrayDataFn.object(), &stat ); if(!stat) MGlobal::displayWarning("failed create pospp"); typedAttrFn.setStorable(false); if(addAttribute( outPositionPP ) != MS::kSuccess) MGlobal::displayWarning("failed add pospp"); outScalePP = typedAttrFn.create( "outScale", "oscl", MFnData::kVectorArray, vectArrayDataFn.object(), &stat ); if(!stat) MGlobal::displayWarning("failed create sclpp"); typedAttrFn.setStorable(false); if(addAttribute(outScalePP) != MS::kSuccess) MGlobal::displayWarning("failed add sclpp"); outRotationPP = typedAttrFn.create( "outRotation", "orot", MFnData::kVectorArray, vectArrayDataFn.object(), &stat ); if(!stat) MGlobal::displayWarning("failed create rotpp"); typedAttrFn.setStorable(false); if(addAttribute(outRotationPP) != MS::kSuccess) MGlobal::displayWarning("failed add rotpp"); MDoubleArray defaultDArray; MFnDoubleArrayData dArrayDataFn; dArrayDataFn.create( defaultDArray ); outReplacePP = typedAttrFn.create( "outReplace", "orpl", MFnData::kDoubleArray, dArrayDataFn.object(), &stat ); if(stat != MS::kSuccess) { MGlobal::displayWarning("failed create outReplace"); } typedAttrFn.setStorable(false); stat = addAttribute(outReplacePP); if(stat != MS::kSuccess) { MGlobal::displayWarning("failed add outReplace"); } outValue = numFn.create( "outValue", "ov", MFnNumericData::kFloat ); numFn.setStorable(false); numFn.setWritable(false); addAttribute(outValue); outValue1 = numFn.create( "outValue1", "ov1", MFnNumericData::kFloat ); numFn.setStorable(false); numFn.setWritable(false); addAttribute(outValue1); MFnTypedAttribute stringAttr; acachename = stringAttr.create( "cachePath", "cp", MFnData::kString ); stringAttr.setStorable(true); addAttribute( acachename ); astandinNames = stringAttr.create( "standinNames", "sdn", MFnData::kString ); stringAttr.setStorable(true); stringAttr.setArray(true); addAttribute(astandinNames); MFnMatrixAttribute matAttr; acameraspace = matAttr.create( "cameraSpace", "cspc", MFnMatrixAttribute::kDouble ); matAttr.setStorable(false); matAttr.setWritable(true); matAttr.setConnectable(true); addAttribute(acameraspace); ahapeture = numFn.create( "horizontalFilmAperture", "hfa", MFnNumericData::kDouble, 1.0 ); numFn.setStorable(false); numFn.setConnectable(true); addAttribute( ahapeture ); avapeture = numFn.create( "verticalFilmAperture", "vfa", MFnNumericData::kDouble, 1.0 ); numFn.setStorable(false); numFn.setConnectable(true); addAttribute( avapeture ); afocallength = numFn.create( "focalLength", "fl", MFnNumericData::kDouble ); numFn.setStorable(false); numFn.setConnectable(true); addAttribute( afocallength ); aconvertPercentage = numFn.create( "convertPercentage", "cvp", MFnNumericData::kDouble ); numFn.setStorable(false); numFn.setConnectable(true); numFn.setDefault(1.0); numFn.setMax(1.0); numFn.setMin(0.01); addAttribute(aconvertPercentage); agroundMesh = typedAttrFn.create("groundMesh", "grdm", MFnMeshData::kMesh); typedAttrFn.setStorable(false); typedAttrFn.setWritable(true); typedAttrFn.setConnectable(true); typedAttrFn.setArray(true); typedAttrFn.setDisconnectBehavior(MFnAttribute::kDelete); addAttribute( agroundMesh ); attributeAffects(agroundMesh, outValue); agroundSpace = matAttr.create("groundSpace", "grdsp", MFnMatrixAttribute::kDouble); matAttr.setStorable(false); matAttr.setWritable(true); matAttr.setConnectable(true); matAttr.setArray(true); matAttr.setDisconnectBehavior(MFnAttribute::kDelete); addAttribute( agroundSpace ); attributeAffects(agroundSpace, outValue); MPointArray defaultPntArray; MFnPointArrayData pntArrayDataFn; pntArrayDataFn.create( defaultPntArray ); aplantTransformCache = typedAttrFn.create( "transformCachePlant", "tmcpl", MFnData::kPointArray, pntArrayDataFn.object(), &stat ); typedAttrFn.setStorable(true); addAttribute(aplantTransformCache); MIntArray defaultIntArray; MFnIntArrayData intArrayDataFn; intArrayDataFn.create( defaultIntArray ); aplantIdCache = typedAttrFn.create( "idCachePlant", "idcpl", MFnData::kIntArray, intArrayDataFn.object(), &stat ); typedAttrFn.setStorable(true); addAttribute(aplantIdCache); aplantTriangleIdCache = typedAttrFn.create( "triCachePlant", "trcpl", MFnData::kIntArray, intArrayDataFn.object(), &stat ); typedAttrFn.setStorable(true); addAttribute(aplantTriangleIdCache); aplantTriangleCoordCache = typedAttrFn.create( "coordCachePlant", "crcpl", MFnData::kVectorArray, vectArrayDataFn.object(), &stat ); typedAttrFn.setStorable(true); addAttribute(aplantTriangleCoordCache); aplantOffsetCache = typedAttrFn.create( "offsetCachePlant", "otcpl", MFnData::kVectorArray, vectArrayDataFn.object(), &stat ); typedAttrFn.setStorable(true); addAttribute(aplantOffsetCache); ainexamp = typedAttrFn.create("inExample", "ixmp", MFnData::kPlugin); typedAttrFn.setStorable(false); typedAttrFn.setConnectable(true); typedAttrFn.setArray(true); addAttribute(ainexamp); adisplayVox = numFn.create( "showVoxelThreshold", "svt", MFnNumericData::kFloat ); numFn.setDefault(1.0); numFn.setMin(.7); numFn.setMax(1.0); numFn.setStorable(true); numFn.setKeyable(true); addAttribute(adisplayVox); acheckDepth = numFn.create( "checkDepth", "cdp", MFnNumericData::kBoolean ); numFn.setDefault(0); numFn.setStorable(false); addAttribute(acheckDepth); ainoverscan = numFn.create( "cameraOverscan", "cos", MFnNumericData::kDouble ); numFn.setDefault(1.33); numFn.setStorable(false); addAttribute(ainoverscan); aactivated = numFn.create( "activated", "act", MFnNumericData::kBoolean ); numFn.setDefault(0); numFn.setStorable(false); addAttribute(aactivated); attributeAffects(ainexamp, outValue1); attributeAffects(aradiusMult, outValue1); attributeAffects(abboxminx, outValue); attributeAffects(abboxmaxx, outValue); attributeAffects(abboxminy, outValue); attributeAffects(abboxmaxy, outValue); attributeAffects(abboxminz, outValue); attributeAffects(abboxmaxz, outValue); attributeAffects(outPositionPP, outValue); 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; }