public static void initialize() { MFnNumericAttribute nAttr = new MFnNumericAttribute(); // single float attribute affecting a generic attribute try{ gInputInt = nAttr.create("gInputInt", "gii", MFnNumericData.Type.kInt, 0); } catch (System.Exception) { MGlobal.displayError("error happens in addAccept"); } nAttr.isStorable = true; nAttr.isKeyable = true; try{ addAttribute(gInputInt); } catch (System.Exception) { MGlobal.displayError("error happens in addAccept"); } addComplexFloatGenericAttribute(ref gOutputFloat_2Float_3Float, "gOutputFloat_2Float_3Float", "gof2f3f"); try{ attributeAffects(gInputInt, gOutputFloat_2Float_3Float); } catch (System.Exception) { MGlobal.displayError("error happens in addAccept"); } return; }
public static void initialize() { MFnNumericAttribute nAttr = new MFnNumericAttribute(); // single float attribute affecting a generic attribute try{ gInputInt = nAttr.create( "gInputInt", "gii", MFnNumericData.Type.kInt, 0 ); } catch (System.Exception) { MGlobal.displayError("error happens in addAccept"); } nAttr.isStorable = true; nAttr.isKeyable = true; try{ addAttribute( gInputInt ); } catch (System.Exception) { MGlobal.displayError("error happens in addAccept"); } addComplexFloatGenericAttribute(ref gOutputFloat_2Float_3Float, "gOutputFloat_2Float_3Float", "gof2f3f" ); try{ attributeAffects( gInputInt, gOutputFloat_2Float_3Float ); } catch (System.Exception) { MGlobal.displayError("error happens in addAccept"); } return; }
public static bool initialize() { MFnNumericAttribute numFn = new MFnNumericAttribute(); aRockInX = numFn.create("RockInX", "rockx", MFnNumericData.Type.kDouble, 0.0); numFn.isKeyable = true; numFn.isAffectsWorldSpace = true; addAttribute(aRockInX); // This is required so that the validateAndSet method is called mustCallValidateAndSet(aRockInX); return(true); }
public override void createPatternsFromString(string patternString, MAttributePatternArray patternArray) { string patternName = "testAttrPatternString"; MAttributePattern createdPattern = new MAttributePattern(patternName); MFnNumericAttribute nAttr = new MFnNumericAttribute(); // Ignore the string for now and create a single float attribute // MObject patternFactoryAttr = nAttr.create("testAttrPatternFactoryByString", "tafs", MFnNumericData.Type.kFloat, 0); nAttr.isKeyable = true; nAttr.isStorable = true; createdPattern.addRootAttr(patternFactoryAttr); patternArray.append(createdPattern); }
override public void createPatternsFromFile(string patternFile, MAttributePatternArray patternArray) { string patternName = "testAttrPatternFile"; MAttributePattern createdPattern = new MAttributePattern(patternName); MFnNumericAttribute nAttr = new MFnNumericAttribute(); // Ignore the string for now and create a single float attribute // MObject patternFactoryAttr = nAttr.create("testAttrPatternFactoryByString", "tafs", MFnNumericData.Type.kFloat, 0); nAttr.isKeyable = true; nAttr.isStorable = true; createdPattern.addRootAttr(patternFactoryAttr); patternArray.append(createdPattern); }
public static void initialize() { // constraint attributes { // Geometry: mesh, readable, not writable, delete on disconnect MFnTypedAttribute typedAttrNotWritable = new MFnTypedAttribute(); GeometrySurfaceConstraint.constraintGeometry = typedAttrNotWritable.create("constraintGeometry", "cg", MFnData.Type.kMesh); typedAttrNotWritable.isReadable = true; typedAttrNotWritable.isWritable = false; typedAttrNotWritable.disconnectBehavior = MFnAttribute.DisconnectBehavior.kDelete; } { // Parent inverse matrix: delete on disconnect MFnTypedAttribute typedAttr = new MFnTypedAttribute(); GeometrySurfaceConstraint.constraintParentInverseMatrix = typedAttr.create("constraintPim", "ci", MFnData.Type.kMatrix); typedAttr.disconnectBehavior = MFnAttribute.DisconnectBehavior.kDelete; // Target geometry: mesh, delete on disconnect GeometrySurfaceConstraint.targetGeometry = typedAttr.create("targetGeometry", "tg", MFnData.Type.kMesh); typedAttr.disconnectBehavior = MFnAttribute.DisconnectBehavior.kDelete; } { // Target weight: double, min 0, default 1.0, keyable, delete on disconnect MFnNumericAttribute typedAttrKeyable = new MFnNumericAttribute(); GeometrySurfaceConstraint.targetWeight = typedAttrKeyable.create("weight", "wt", MFnNumericData.Type.kDouble, 1.0); typedAttrKeyable.setMin((double)0); typedAttrKeyable.isKeyable = true; typedAttrKeyable.disconnectBehavior = MFnAttribute.DisconnectBehavior.kDelete; } { // Compound target(geometry,weight): array, delete on disconnect MFnCompoundAttribute compoundAttr = new MFnCompoundAttribute(); GeometrySurfaceConstraint.compoundTarget = compoundAttr.create("target", "tgt"); compoundAttr.addChild(GeometrySurfaceConstraint.targetGeometry); compoundAttr.addChild(GeometrySurfaceConstraint.targetWeight); compoundAttr.isArray = true; compoundAttr.disconnectBehavior = MFnAttribute.DisconnectBehavior.kDelete; } addAttribute(GeometrySurfaceConstraint.constraintParentInverseMatrix); addAttribute(GeometrySurfaceConstraint.constraintGeometry); addAttribute(GeometrySurfaceConstraint.compoundTarget); attributeAffects(compoundTarget, constraintGeometry); attributeAffects(targetGeometry, constraintGeometry); attributeAffects(targetWeight, constraintGeometry); attributeAffects(constraintParentInverseMatrix, constraintGeometry); }
public static void initialize() // // Description // // Attribute (static) initialization. // { MFnNumericAttribute numAttr = new MFnNumericAttribute(); MFnEnumAttribute enumAttr = new MFnEnumAttribute(); MFnTypedAttribute typedAttr = new MFnTypedAttribute(); // ----------------------- INPUTS ------------------------- size = numAttr.create("size", "sz", MFnNumericData.Type.kDouble, 1.0); numAttr.isArray = false; numAttr.usesArrayDataBuilder = false; numAttr.isHidden = false; numAttr.isKeyable = true; addAttribute(size); shapeType = enumAttr.create("shapeType", "st", 0); enumAttr.addField("cube", 0); enumAttr.addField("sphere", 1); enumAttr.isHidden = false; enumAttr.isKeyable = true; addAttribute(shapeType); inputMesh = typedAttr.create("inputMesh", "im", MFnData.Type.kMesh); typedAttr.isHidden = true; addAttribute(inputMesh); // ----------------------- OUTPUTS ------------------------- outputSurface = typedAttr.create("outputSurface", "os", new MTypeId(apiMeshData.id)); typedAttr.isWritable = false; addAttribute(outputSurface); // ---------- Specify what inputs affect the outputs ---------- // attributeAffects(inputMesh, outputSurface); attributeAffects(size, outputSurface); attributeAffects(shapeType, outputSurface); }
public static MPlug AddBoolAttr(MFnDependencyNode dnode, string attrLongName, bool defaultValue = true, string shortName = "", bool keyable = true) { if (shortName.Length == 0) { shortName = attrLongName; } MFnNumericAttribute na = new MFnNumericAttribute(); na.create(attrLongName, shortName, MFnNumericData.Type.kBoolean); na.setDefault(defaultValue); na.isKeyable = keyable; na.setChannelBox(true); dnode.addAttribute(na.objectProperty); return(dnode.findPlug(attrLongName)); //if (dagPath != null) //{ // string cmdStr = string.Format("addAttr -ln {0} -min {1} -max {2} -at \"float\" -dv {3} -k {4} {5}", attrLongName, min, max, defaultValue, keyable ? 1 : 0, dagPath.fullPathName); // Debug.Log("cmdStr:" + cmdStr); // MGlobal.executeCommand(cmdStr); //} }
public static void initialize() { MFnNumericAttribute numAttr = new MFnNumericAttribute(); MFnTypedAttribute typedAttr = new MFnTypedAttribute(); // ----------------------- INPUTS -------------------------- inputSurface = typedAttr.create("inputSurface", "is", new MTypeId(apiMeshData.id)); typedAttr.isStorable = false; addAttribute( inputSurface ); // ----------------------- OUTPUTS ------------------------- // bbox attributes // bboxCorner1 = numAttr.create( "bboxCorner1", "bb1", MFnNumericData.Type.k3Double, 0 ); numAttr.isArray = false; numAttr.usesArrayDataBuilder = false; numAttr.isHidden = false; numAttr.isKeyable = false; addAttribute( bboxCorner1 ); bboxCorner2 = numAttr.create( "bboxCorner2", "bb2", MFnNumericData.Type.k3Double, 0 ); numAttr.isArray = false; numAttr.usesArrayDataBuilder = false; numAttr.isHidden = false; numAttr.isKeyable = false; addAttribute( bboxCorner2 ); // local/world output surface attributes // outputSurface = typedAttr.create("outputSurface", "os", new MTypeId(apiMeshData.id)); addAttribute( outputSurface ); typedAttr.isWritable = false; worldSurface = typedAttr.create("worldSurface", "ws", new MTypeId(apiMeshData.id)); typedAttr.isCached = false; typedAttr.isWritable = false; typedAttr.isArray = true; typedAttr.usesArrayDataBuilder = true; typedAttr.disconnectBehavior = MFnAttribute.DisconnectBehavior.kDelete; typedAttr.isWorldSpace = true; addAttribute( worldSurface ); // Cached surface used for file IO // cachedSurface = typedAttr.create("cachedSurface", "cs", new MTypeId(apiMeshData.id)); typedAttr.isReadable = true; typedAttr.isWritable = true; typedAttr.isStorable = true; addAttribute( cachedSurface ); // ---------- Specify what inputs affect the outputs ---------- // attributeAffects( inputSurface, outputSurface ); attributeAffects( inputSurface, worldSurface ); attributeAffects( outputSurface, worldSurface ); attributeAffects( inputSurface, bboxCorner1 ); attributeAffects( inputSurface, bboxCorner2 ); attributeAffects( cachedSurface, outputSurface ); attributeAffects( cachedSurface, worldSurface ); attributeAffects( mControlPoints, outputSurface ); attributeAffects( mControlValueX, outputSurface ); attributeAffects( mControlValueY, outputSurface ); attributeAffects( mControlValueZ, outputSurface ); attributeAffects( mControlPoints, cachedSurface ); attributeAffects( mControlValueX, cachedSurface ); attributeAffects( mControlValueY, cachedSurface ); attributeAffects( mControlValueZ, cachedSurface ); attributeAffects( mControlPoints, worldSurface ); attributeAffects( mControlValueX, worldSurface ); attributeAffects( mControlValueY, worldSurface ); attributeAffects( mControlValueZ, worldSurface ); }
public static void initialize() { // constraint attributes { // Geometry: mesh, readable, not writable, delete on disconnect MFnTypedAttribute typedAttrNotWritable = new MFnTypedAttribute(); GeometrySurfaceConstraint.constraintGeometry = typedAttrNotWritable.create( "constraintGeometry", "cg", MFnData.Type.kMesh); typedAttrNotWritable.isReadable = true; typedAttrNotWritable.isWritable = false; typedAttrNotWritable.disconnectBehavior = MFnAttribute.DisconnectBehavior.kDelete; } { // Parent inverse matrix: delete on disconnect MFnTypedAttribute typedAttr = new MFnTypedAttribute(); GeometrySurfaceConstraint.constraintParentInverseMatrix = typedAttr.create( "constraintPim", "ci", MFnData.Type.kMatrix); typedAttr.disconnectBehavior = MFnAttribute.DisconnectBehavior.kDelete; // Target geometry: mesh, delete on disconnect GeometrySurfaceConstraint.targetGeometry = typedAttr.create( "targetGeometry", "tg", MFnData.Type.kMesh); typedAttr.disconnectBehavior = MFnAttribute.DisconnectBehavior.kDelete; } { // Target weight: double, min 0, default 1.0, keyable, delete on disconnect MFnNumericAttribute typedAttrKeyable = new MFnNumericAttribute(); GeometrySurfaceConstraint.targetWeight = typedAttrKeyable.create( "weight", "wt", MFnNumericData.Type.kDouble, 1.0); typedAttrKeyable.setMin( (double) 0 ); typedAttrKeyable.isKeyable = true; typedAttrKeyable.disconnectBehavior = MFnAttribute.DisconnectBehavior.kDelete; } { // Compound target(geometry,weight): array, delete on disconnect MFnCompoundAttribute compoundAttr = new MFnCompoundAttribute(); GeometrySurfaceConstraint.compoundTarget = compoundAttr.create( "target", "tgt"); compoundAttr.addChild(GeometrySurfaceConstraint.targetGeometry); compoundAttr.addChild(GeometrySurfaceConstraint.targetWeight); compoundAttr.isArray = true; compoundAttr.disconnectBehavior = MFnAttribute.DisconnectBehavior.kDelete; } addAttribute(GeometrySurfaceConstraint.constraintParentInverseMatrix); addAttribute(GeometrySurfaceConstraint.constraintGeometry); addAttribute(GeometrySurfaceConstraint.compoundTarget); attributeAffects(compoundTarget, constraintGeometry); attributeAffects(targetGeometry, constraintGeometry); attributeAffects(targetWeight, constraintGeometry); attributeAffects(constraintParentInverseMatrix, constraintGeometry); }
public static bool initialize() { MFnNumericAttribute numFn = new MFnNumericAttribute(); aRockInX = numFn.create("RockInX", "rockx", MFnNumericData.Type.kDouble, 0.0); numFn.isKeyable = true; numFn.isAffectsWorldSpace = true; addAttribute(aRockInX); // This is required so that the validateAndSet method is called mustCallValidateAndSet(aRockInX); return true; }
public static void initialize() { MFnNumericAttribute nAttr = new MFnNumericAttribute(); MFnMatrixAttribute nMAttr = new MFnMatrixAttribute(); //MFnTypedAttribute nTAttr; MFnGenericAttribute nGAttr = new MFnGenericAttribute(); // Input Attributes // aAngle = nAttr.create("angle", "ang", MFnNumericData.Type.kFloat); nAttr.setDefault(30.0f); nAttr.setMin(0.0f); nAttr.setMax(100.0f); nAttr.isKeyable = true; nAttr.isStorable = true; nAttr.isReadable = true; nAttr.isWritable = true; aColor1 = nAttr.createColor("walkableColor", "w"); nAttr.setDefault(0.0f, 1.0f, 0.0f); nAttr.isKeyable = true; nAttr.isStorable = true; nAttr.isUsedAsColor = true; nAttr.isReadable = true; nAttr.isWritable = true; aColor2 = nAttr.createColor("nonWalkableColor", "nw"); nAttr.setDefault(1.0f, 0.0f, 0.0f); nAttr.isKeyable = true; nAttr.isStorable = true; nAttr.isUsedAsColor = true; nAttr.isReadable = true; nAttr.isWritable = true; // Surface Normal supplied by the render sampler aTriangleNormalCamera = nAttr.createPoint("triangleNormalCamera", "n"); nAttr.isStorable = false; nAttr.isHidden = true; nAttr.isReadable = true; nAttr.isWritable = true; //View matrix from the camera into world space aMatrixEyeToWorld = nMAttr.create("matrixEyeToWorld", "mew", MFnMatrixAttribute.Type.kFloat); nAttr.isHidden = true; nMAttr.isWritable = true; // Output Attributes aOutColor = nAttr.createColor("outColor", "oc"); nAttr.isStorable = false; nAttr.isHidden = false; nAttr.isReadable = true; nAttr.isWritable = false; //dummy plug for forcing evaluation aDirtyShaderAttr = nGAttr.create("dirtyShaderPlug", "dsp"); nGAttr.isArray = true; nGAttr.isHidden = false; nGAttr.usesArrayDataBuilder = true; nGAttr.isReadable = false; nGAttr.isStorable = true; nGAttr.indexMatters = false; nGAttr.addAccept(MFnData.Type.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); }
public static void InitializeAnimClips() { var tAttr = new MFnTypedAttribute(); var nAttr = new MFnNumericAttribute(); var cAttr = new MFnCompoundAttribute(); var eAttr = new MFnEnumAttribute(); Name = tAttr.create("animClipName", "acn", MFnData.Type.kString); addAttribute(Name); Start = nAttr.create("animClipStart", "acs", MFnNumericData.Type.kInt); nAttr.setMin(0); addAttribute(Start); End = nAttr.create("animClipEnd", "ace", MFnNumericData.Type.kInt); nAttr.setMin(0); addAttribute(End); Type = eAttr.create("animClipType", "act"); foreach (var entry in AnimationData.NameToId) { eAttr.addField(entry.Key, (short)entry.Value); //TODO check performance } eAttr.setDefault(0); addAttribute(Type); LoopingFlag = nAttr.create("animClipLooping", "acl", MFnNumericData.Type.kBoolean); nAttr.setDefault(true); addAttribute(LoopingFlag); LowPriorityFlag = nAttr.create("animClipLowPriority", "aclp", MFnNumericData.Type.kBoolean); nAttr.setDefault(false); addAttribute(LowPriorityFlag); RepetitionsMin = nAttr.create("animClipRepMin", "acrepmin", MFnNumericData.Type.kFloat); nAttr.setDefault((float)0); nAttr.setMin(0); addAttribute(RepetitionsMin); RepetitionsMax = nAttr.create("animClipRepMax", "acrepmax", MFnNumericData.Type.kFloat); nAttr.setDefault((float)0); nAttr.setMin(0); addAttribute(RepetitionsMax); BlendingFlag = nAttr.create("animClipBlending", "acb", MFnNumericData.Type.kBoolean); nAttr.setDefault(true); addAttribute(BlendingFlag); BlendTimeStart = nAttr.create("animClipBlendTimeStart", "acbts", MFnNumericData.Type.kInt); nAttr.setDefault(150); nAttr.setMin(0); addAttribute(BlendTimeStart); BlendTimeEnd = nAttr.create("animClipBlendTimeEnd", "acbte", MFnNumericData.Type.kInt); nAttr.setDefault(150); nAttr.setMin(0); addAttribute(BlendTimeEnd); Rarity = nAttr.create("animClipRarity", "acra", MFnNumericData.Type.kFloat); nAttr.setDefault((float)100); nAttr.setMin(0); nAttr.setMax(100); addAttribute(Rarity); Export = nAttr.create("exportAnimClip", "eac", MFnNumericData.Type.kBoolean); nAttr.setDefault(true); addAttribute(Export); AnimClips = cAttr.create("animClips", "clips"); cAttr.addChild(Name); cAttr.addChild(Start); cAttr.addChild(End); cAttr.addChild(Type); cAttr.addChild(LoopingFlag); cAttr.addChild(LowPriorityFlag); cAttr.addChild(RepetitionsMin); cAttr.addChild(RepetitionsMax); cAttr.addChild(BlendingFlag); cAttr.addChild(BlendTimeStart); cAttr.addChild(BlendTimeEnd); cAttr.addChild(Rarity); cAttr.addChild(Export); cAttr.isArray = true; addAttribute(AnimClips); }
public static void initialize() // // Description: // Initializes the attributes for this node. // { MFnNumericAttribute nAttr = new MFnNumericAttribute(); MFnMatrixAttribute nMAttr = new MFnMatrixAttribute(); //MFnTypedAttribute nTAttr; MFnGenericAttribute nGAttr = new MFnGenericAttribute(); // Input Attributes // aAngle = nAttr.create("angle", "ang", MFnNumericData.Type.kFloat); nAttr.setDefault(30.0f); nAttr.setMin(0.0f); nAttr.setMax(100.0f); nAttr.isKeyable = true; nAttr.isStorable = true; nAttr.isReadable = true; nAttr.isWritable = true; aColor1 = nAttr.createColor("walkableColor", "w"); nAttr.setDefault(0.0f, 1.0f, 0.0f); nAttr.isKeyable = true; nAttr.isStorable = true; nAttr.isUsedAsColor = true; nAttr.isReadable = true; nAttr.isWritable = true; aColor2 = nAttr.createColor("nonWalkableColor", "nw"); nAttr.setDefault(1.0f, 0.0f, 0.0f); nAttr.isKeyable = true; nAttr.isStorable = true; nAttr.isUsedAsColor = true; nAttr.isReadable = true; nAttr.isWritable = true; // Surface Normal supplied by the render sampler aTriangleNormalCamera = nAttr.createPoint("triangleNormalCamera", "n"); nAttr.isStorable = false; nAttr.isHidden = true; nAttr.isReadable = true; nAttr.isWritable = true; //View matrix from the camera into world space aMatrixEyeToWorld = nMAttr.create("matrixEyeToWorld", "mew", MFnMatrixAttribute.Type.kFloat); nAttr.isHidden = true; nMAttr.isWritable = true; // Output Attributes aOutColor = nAttr.createColor("outColor", "oc"); nAttr.isStorable = false; nAttr.isHidden = false; nAttr.isReadable = true; nAttr.isWritable = false; //dummy plug for forcing evaluation aDirtyShaderAttr = nGAttr.create("dirtyShaderPlug", "dsp"); nGAttr.isArray = true; nGAttr.isHidden = false; nGAttr.usesArrayDataBuilder = true; nGAttr.isReadable = false; nGAttr.isStorable = true; nGAttr.indexMatters = false; nGAttr.addAccept(MFnData.Type.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); }