示例#1
0
    private void OperatorGUI()
    {
        // generator type selection
        operatorNode.type = (OperatorNode.OPERATORTYPE)EditorGUILayout.EnumPopup(operatorNode.type);
        if (operatorNode.type != operatorNode.lastType)
        {
            operatorNode.SetInputs();
            preview = Generate((int)previewSize);
            operatorNode.lastType = operatorNode.type;
        }
        node.rect.height += controlHeight * 1.5f;

        // parameters
        //showParameters = EditorGUILayout.Foldout(showParameters, "Parameters");
        //if(showParameters) {
        // min max
        if (operatorNode.type == OperatorNode.OPERATORTYPE.CLAMP)
        {
            GUILayout.Label("Min:");
            operatorNode.min = EditorGUILayout.Slider(operatorNode.min, -1.0f, 1.0f);
            GUILayout.Label("Max:");
            operatorNode.max  = EditorGUILayout.Slider(operatorNode.max, -1.0f, 1.0f);
            node.rect.height += controlHeight * 2.5f;
        }

        if (operatorNode.type == OperatorNode.OPERATORTYPE.TERRACE)
        {
            GUILayout.Label("Min:");
            operatorNode.min = EditorGUILayout.Slider(operatorNode.min, -1.0f, 1.0f);
            GUILayout.Label("Max:");
            operatorNode.max = EditorGUILayout.Slider(operatorNode.max, -1.0f, 1.0f);
            GUILayout.Label("Power:");
            operatorNode.power = EditorGUILayout.Slider(operatorNode.power, 0f, 1.0f);
            node.rect.height  += controlHeight * 4f;
        }

        // exponent
        if (operatorNode.type == OperatorNode.OPERATORTYPE.EXPONENT)
        {
            GUILayout.Label("Exponent:");
            operatorNode.exponent = EditorGUILayout.Slider(operatorNode.exponent, -10.0f, 10f);
            node.rect.height     += controlHeight;
        }
        // x, y, z
        if (operatorNode.type == OperatorNode.OPERATORTYPE.TRANSLATE)
        {
            GUILayout.Label("X:");
            operatorNode.x = EditorGUILayout.Slider(operatorNode.x, -10.0f, 10.0f);
            GUILayout.Label("Y:");
            operatorNode.y = EditorGUILayout.Slider(operatorNode.y, -10.0f, 10.0f);
            GUILayout.Label("Z:");
            operatorNode.z    = EditorGUILayout.Slider(operatorNode.z, -10.0f, 10.0f);
            node.rect.height += controlHeight * 4f;
        }
        // curve
        if (operatorNode.type == OperatorNode.OPERATORTYPE.CURVE)
        {
            if (operatorNode.curve == null)
            {
                if (operatorNode.keyframes != null)
                {
                    operatorNode.curve = new AnimationCurve(SerializableKeyframe.ToKeyframeArray(operatorNode.keyframes));
                }
                else
                {
                    operatorNode.curve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
                }
            }

            try {
                operatorNode.curve = EditorGUILayout.CurveField(operatorNode.curve, GUILayout.Width(40), GUILayout.Height(30));
            }
            catch {}
            operatorNode.keyframes = SerializableKeyframe.FromKeyframeArray(operatorNode.curve.keys);
            node.rect.height      += controlHeight;
        }
        // exponent
        if (operatorNode.type == OperatorNode.OPERATORTYPE.WEIGHT)
        {
            GUILayout.Label("Weight:");
            operatorNode.min = EditorGUILayout.Slider(operatorNode.min, 0f, 1f);
            GUILayout.Label("Target:");
            operatorNode.max  = EditorGUILayout.Slider(operatorNode.max, -1f, 1f);
            node.rect.height += controlHeight * 2.5f;
        }
        //}
    }
示例#2
0
    override public ModuleBase GetModule()
    {
        // check that has inputs
        for (int i = 0; i < inputs.Length; i++)
        {
            if (inputs[i] == null)
            {
                return(null);
            }
        }

        // get module
        switch (type)
        {
        case OPERATORTYPE.ABS:
            module = new Abs(inputs[0].GetModule());
            break;

        case OPERATORTYPE.ADD:
            module = new Add(inputs[0].GetModule(), inputs[1].GetModule());
            break;

        case OPERATORTYPE.BLEND:
            module = new Blend(inputs[0].GetModule(), inputs[1].GetModule(), inputs[2].GetModule());
            break;

        case OPERATORTYPE.CLAMP:
            module = new Clamp(min, max, inputs[0].GetModule());
            break;

        case OPERATORTYPE.EXPONENT:
            module = new Exponent(exponent, inputs[0].GetModule());
            break;

        case OPERATORTYPE.INVERT:
            module = new Invert(inputs[0].GetModule());
            break;

        case OPERATORTYPE.MAX:
            module = new Max(inputs[0].GetModule(), inputs[1].GetModule());
            break;

        case OPERATORTYPE.MIN:
            module = new Min(inputs[0].GetModule(), inputs[1].GetModule());
            break;

        case OPERATORTYPE.MULTIPLY:
            module = new Multiply(inputs[0].GetModule(), inputs[1].GetModule());
            break;

        case OPERATORTYPE.POWER:
            module = new Power(inputs[0].GetModule(), inputs[1].GetModule());
            break;

        case OPERATORTYPE.SUBTRACT:
            module = new Subtract(inputs[0].GetModule(), inputs[1].GetModule());
            break;

        case OPERATORTYPE.TERRACE:
            module = new Terrace(min, max, power, inputs[0].GetModule());
            break;

        case OPERATORTYPE.TRANSLATE:
            module = new Translate(x, y, z, inputs[0].GetModule());
            break;

        case OPERATORTYPE.DIVIDE:
            module = new Divide(inputs[0].GetModule(), inputs[1].GetModule());
            break;

        case OPERATORTYPE.CURVE:
            if (curve == null)
            {
                curve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);
                if (keyframes != null)
                {
                    curve.keys = SerializableKeyframe.ToKeyframeArray(keyframes);
                }
            }
            if (keyframes == null)
            {
                keyframes = SerializableKeyframe.FromKeyframeArray(curve.keys);
            }
            module = new Curve(keyframes, inputs[0].GetModule());
            break;

        case OPERATORTYPE.WEIGHT:
            module = new Weight(inputs[0].GetModule(), min, max);
            break;
        }

        return(this.module);
    }