Exemple #1
0
        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()
        {
            // 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);
        }
Exemple #3
0
		protected void getAddAttrCmds(MObject node, MStringArray cmds)
		{
			//
			// Run through the node's attributes.
			//
			MFnDependencyNode	nodeFn = new MFnDependencyNode(node);
			uint numAttrs = nodeFn.attributeCount;
			uint i;

			for (i = 0; i < numAttrs; i++)
			{
				//
				// Use the attribute ordering which Maya uses when doing I/O.
				//
				MObject	attr = nodeFn.reorderedAttribute(i);

				//
				// If this attribute has been added since the node was created,
				// then we may want to write out an addAttr statement for it.
				//
				if (nodeFn.isNewAttribute(attr))
				{
					MFnAttribute	attrFn = new MFnAttribute(attr);

					//
					// If the attribute has a parent then ignore it because it will
					// be processed when we process the parent.
					//
                    bool bFound;
					attrFn.parent(out bFound);
					if ( !bFound )
					{
							//
						// If the attribute is a compound, then we can do its entire
						// tree at once.
						//
						try
						{
							MFnCompoundAttribute	cAttrFn = new MFnCompoundAttribute(attr);
							MStringArray	newCmds = new MStringArray();

							cAttrFn.getAddAttrCmds(newCmds);

							uint	numCommands = newCmds.length;
							int	c;

							for (c = 0; c < numCommands; c++)
							{
								if (newCmds[c] != "")
									cmds.append(newCmds[c]);
							}
						}
						catch (Exception)
						{
							string	newCmd = attrFn.getAddAttrCmd();
						
							if (newCmd != "") cmds.append(newCmd);
						}
					}
				}
			}
		}
Exemple #4
0
        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);
        }