Ejemplo n.º 1
0
        public ColorNode(int x, int y) : base("Color Node", new SerializableRect(x, y, 200, 150))
        {
            type = lastType = ColorNode.COLORTYPE.COLOR;

            gradient = new Gradient();
            if (gradientColorKeys != null && gradientAlphaKeys != null)
            {
                gradient.colorKeys = SerializableGradientColorKey.ToGradientColorKeys(gradientColorKeys);
                gradient.alphaKeys = SerializableGradientAlphaKey.ToGradientColorKeys(gradientAlphaKeys);
            }

            color = new SerializableColor(Color.black);

            SetInputs();
        }
Ejemplo n.º 2
0
        override public ModuleBase GetModule()
        {
            // check that has inputs
            if (type != COLORTYPE.COLOR)
            {
                for (int i = 0; i < inputs.Length; i++)
                {
                    if (inputs[i] == null)
                    {
                        return(null);
                    }
                }
            }

            // get module
            switch (type)
            {
            case COLORTYPE.GRADIENT:
                if (gradient == null)
                {
                    gradient = new Gradient();
                    if (gradientColorKeys != null)
                    {
                        gradient.colorKeys = SerializableGradientColorKey.ToGradientColorKeys(gradientColorKeys);
                    }
                    if (gradientAlphaKeys != null)
                    {
                        gradient.alphaKeys = SerializableGradientAlphaKey.ToGradientColorKeys(gradientAlphaKeys);
                    }
                }
                if (gradientColorKeys == null)
                {
                    gradientColorKeys = SerializableGradientColorKey.FromGradientColorKeys(gradient.colorKeys);
                }
                if (gradientAlphaKeys == null)
                {
                    gradientAlphaKeys = SerializableGradientAlphaKey.FromGradientColorKeys(gradient.alphaKeys);
                }

                module = new GradientModule(inputs[0].GetModule(), gradient);
                break;

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

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

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

            case COLORTYPE.COLOR:
                module = new ColorSource(color.ToColor());
                break;

            case COLORTYPE.OVERLAY:
                module = new OverlayColorModule(inputs[0].GetModule(), inputs[1].GetModule());
                break;
            }

            SetOutputOptions();

            return(this.module);
        }
Ejemplo n.º 3
0
        public NodeWindow(Node node)
        {
            this.windowIndex = indexCount;
            indexCount++;

            // cast to specific type
            if (node is GeneratorNode)
            {
                generatorNode = (GeneratorNode)node;
                type          = WINDOWTYPE.GENERATOR;
                node.title    = generatorNode.type.ToString();
            }
            if (node is OperatorNode)
            {
                operatorNode = (OperatorNode)node;
                type         = WINDOWTYPE.OPERATOR;
                node.title   = operatorNode.type.ToString();
            }
            if (node is OutputNode)
            {
                outputNode  = (OutputNode)node;
                type        = WINDOWTYPE.OUTPUT;
                previewSize = PreviewSize.x2;
            }
            if (node is MacroNode)
            {
                macroNode = (MacroNode)node;
                type      = WINDOWTYPE.MACRO;
            }
            if (node is TextureNode)
            {
                textureNode = (TextureNode)node;
                type        = WINDOWTYPE.TEXTURE;
            }
            if (node is ColorNode)
            {
                colorNode = (ColorNode)node;

                if (colorNode.gradient == null)
                {
                    colorNode.gradient = new Gradient();
                    if (colorNode.gradientColorKeys != null)
                    {
                        colorNode.gradient.colorKeys = SerializableGradientColorKey.ToGradientColorKeys(colorNode.gradientColorKeys);
                        colorNode.gradient.alphaKeys = SerializableGradientAlphaKey.ToGradientColorKeys(colorNode.gradientAlphaKeys);
                    }
                    gradient = new GradientWrapper();
                    gradient.GradientData = colorNode.gradient;
                }

                type = WINDOWTYPE.COLOR;
            }

            // also save general reference
            this.node = node;

            // random connection color
            connectionColor = new Color(Random.Range(100, 200) / 255f, Random.Range(100, 200) / 255f, Random.Range(100, 200) / 255f);

            UpdatePreview();
            node.rect.height = controlHeight + (int)previewSize;
            node.rect.width  = (int)previewSize + 20;
            if (node.rect.width < 200)
            {
                node.rect.width = 200;
            }
        }