Esempio n. 1
0
        private void UpdateGradient(float x, float y, float z, float seed)
        {
            GradientColorKey[] colorKeys = new GradientColorKey[_inputSockets.Count];
            GradientAlphaKey[] alphaKeys = new GradientAlphaKey[_inputSockets.Count];
            Request            request   = new Request();

            request.X    = x;
            request.Y    = y;
            request.Z    = z;
            request.Seed = seed;
            for (int i = 0; i < _inputSockets.Count; i++)
            {
                UnityEngine.Color c = UnityEngine.Color.black;
                if (_inputSockets[i].IsConnected())
                {
                    AbstractColorNode colorNode = (AbstractColorNode)_inputSockets[i].GetConnectedSocket().Parent;
                    c = colorNode.GetColor(_inputSockets[i].GetConnectedSocket(), request);
                }
                colorKeys[i]       = new GradientColorKey();
                colorKeys[i].color = c;
                colorKeys[i].time  = _times[i];
                alphaKeys[i]       = new GradientAlphaKey();
                alphaKeys[i].alpha = c.a;
                alphaKeys[i].time  = _times[i];
            }
            _gradient.SetKeys(colorKeys, alphaKeys);
        }
Esempio n. 2
0
        public override void Update()
        {
            float widthF  = AbstractNumberNode.GetInputNumber(_inputSocketWidth, new Request());
            float heightF = AbstractNumberNode.GetInputNumber(_inputSocketHeight, new Request());

            _colorMap = null;

            if (!float.IsNaN(widthF) && !float.IsNaN(heightF))
            {
                int widthI  = (int)widthF;
                int heightI = (int)heightF;

                Request request = new Request();

                if (widthI > 0 && heightI > 0)
                {
                    _colorMap = new UnityEngine.Color[widthI, heightI];

                    for (int x = 0; x < widthI; x++)
                    {
                        for (int z = 0; z < heightI; z++)
                        {
                            request.X = x;
                            request.Z = z;
                            UnityEngine.Color c = AbstractColorNode.GetInputColor(_inputSocketColor, request);
                            _colorMap[x, z] = c;
                        }
                    }
                }
            }
        }
Esempio n. 3
0
        public override UnityEngine.Material GetMaterial(OutputSocket outSocket, Request request)
        {
            if (_inputSocketColor.CanGetResult())
            {
                UnityEngine.Color c = AbstractColorNode.GetInputColor(_inputSocketColor, request);
                _material.color = c;
            }

            return(_material);
        }
        public UnityEngine.Color GetColorFrom(float i)
        {
            if (!_gradientSocket.IsConnected())
            {
                return(UnityEngine.Color.black);
            }
            AbstractColorNode node = (AbstractColorNode)_gradientSocket.GetConnectedSocket().Parent;

            return(node.GetColor(_gradientSocket.GetConnectedSocket(), i));
        }
Esempio n. 5
0
        public UnityEngine.Color GetColor(OutputSocket socket, Request request)
        {
            if (!_colorSocket.IsConnected())
            {
                return(UnityEngine.Color.magenta);
            }
            AbstractColorNode node = (AbstractColorNode)_colorSocket.GetConnectedSocket().Parent;

            UnityEngine.Color color = node.GetColor(_colorSocket.GetConnectedSocket(), request);
            return(color);
        }
Esempio n. 6
0
        public override void Update()
        {
            float width  = AbstractNumberNode.GetInputNumber(_inputSocketWidth, new Request());
            float height = AbstractNumberNode.GetInputNumber(_inputSocketHeight, new Request());

            _colors = null;
            if (float.IsNaN(width) || float.IsNaN(height) || width == 0 || height == 0)
            {
                return;
            }

            _colors = new UnityEngine.Color[(int)width, (int)height];
            Request request = new Request();

            for (int x = 0; x < width; x++)
            {
                for (int z = 0; z < height; z++)
                {
                    request.X = x;
                    request.Z = z;
                    float value = AbstractNumberNode.GetInputNumber(_inputSocketHeightMap, request);
                    if (float.IsNaN(value))
                    {
                        _colors[x, z] = UnityEngine.Color.magenta;
                    }
                    else
                    {
                        if (_inputSocketGradient.IsConnected())
                        {
                            Request r = new Request();
                            r.Y = value;
                            UnityEngine.Color c = AbstractColorNode.GetInputColor(_inputSocketGradient, r);
                            _colors[x, z] = c;
                        }
                        else
                        {
                            _colors[x, z]   = UnityEngine.Color.white * (value + 1) / 2f;
                            _colors[x, z].a = 1;
                        }
                    }
                }
            }
        }
Esempio n. 7
0
 private void UpdateGradient()
 {
     GradientColorKey[] colorKeys = new GradientColorKey[_inputSockets.Count];
     GradientAlphaKey[] alphaKeys = new GradientAlphaKey[_inputSockets.Count];
     for (int i = 0; i < _inputSockets.Count; i++)
     {
         UnityEngine.Color c = UnityEngine.Color.black;
         if (_inputSockets[i].IsConnected())
         {
             AbstractColorNode colorNode = (AbstractColorNode)_inputSockets[i].GetConnectedSocket().Parent;
             c = colorNode.GetColor(_inputSockets[i].GetConnectedSocket(), 0);
         }
         colorKeys[i]       = new GradientColorKey();
         colorKeys[i].color = c;
         colorKeys[i].time  = _times[i];
         alphaKeys[i]       = new GradientAlphaKey();
         alphaKeys[i].alpha = c.a;
         alphaKeys[i].time  = _times[i];
     }
     _gradient.SetKeys(colorKeys, alphaKeys);
 }
 public override float GetNumber(OutputSocket outSocket, Request request)
 {
     UnityEngine.Color c = AbstractColorNode.GetInputColor(_inputSocketColor, request);
     if (outSocket == _outputSocketR)
     {
         return(c.r);
     }
     if (outSocket == _outputSocketG)
     {
         return(c.g);
     }
     if (outSocket == _outputSocketB)
     {
         return(c.b);
     }
     if (outSocket == _outputSocketA)
     {
         return(c.a);
     }
     return(float.NaN);
 }