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);
        }
Exemple #2
0
        public static MPlug AddFloatAttr(MDagPath dagPath, string attrLongName, float min = 0, float max = 1, float defaultValue = 0, string shortName = "", bool keyable = true)
        {
            if (shortName.Length == 0)
            {
                shortName = attrLongName;
            }
            MFnDependencyNode   dnode = new MFnDependencyNode(dagPath.node);
            MFnNumericAttribute na    = new MFnNumericAttribute();

            na.create(attrLongName, shortName, MFnNumericData.Type.kFloat);
            na.setMin(min);
            na.setMax(max);
            na.setDefault(defaultValue);
            na.isKeyable = keyable;
            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()
        {
            // 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()
        {
            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);
        }
Exemple #5
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);
        }
Exemple #6
0
        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);
        }