Exemplo n.º 1
0
        // Adds a generic attribute that accepts a float, float2, float3
        public static void addComplexFloatGenericAttribute(ref MObject attrObject, string longName, string shortName)
        {
            // Create the generic attribute and set the 3 accepts types
            MFnGenericAttribute gAttr = new MFnGenericAttribute();

            attrObject = gAttr.create(longName, shortName);
            try
            {
                gAttr.addAccept(MFnNumericData.Type.kFloat);

                gAttr.addAccept(MFnNumericData.Type.k2Float);

                gAttr.addAccept(MFnNumericData.Type.k3Float);
            }
            catch (System.Exception)
            {
                MGlobal.displayError("error happens in addAccept");
            }

            gAttr.isWritable = false;
            gAttr.isStorable = false;

            // Add the attribute to the node
            try
            {
                addAttribute(attrObject);
            }
            catch (System.Exception)
            {
                MGlobal.displayError("error happens in addAttribute");
            }
        }
        // Adds a generic attribute that accepts a float, float2, float3
        public static void addComplexFloatGenericAttribute(ref MObject attrObject, string longName, string shortName)
        {
            // Create the generic attribute and set the 3 accepts types
            MFnGenericAttribute gAttr = new MFnGenericAttribute();
            attrObject = gAttr.create( longName, shortName );
            try
            {
                gAttr.addAccept(MFnNumericData.Type.kFloat);

                gAttr.addAccept(MFnNumericData.Type.k2Float);

                gAttr.addAccept(MFnNumericData.Type.k3Float);
            }
            catch (System.Exception)
            {
                MGlobal.displayError("error happens in addAccept");
            }

            gAttr.isWritable = false;
            gAttr.isStorable = false;

            // Add the attribute to the node
            try
            {
                addAttribute(attrObject);
            }
            catch (System.Exception)
            {
                MGlobal.displayError("error happens in addAttribute");
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }