Пример #1
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);
            //}
        }
Пример #2
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);
        }
Пример #3
0
        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);
        }
Пример #4
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);
        }