예제 #1
0
 public override void Update()
 {
     _color.r = AbstractNumberNode.GetInputNumber(_inputSocketR, 0, 0, 0, 0);
     _color.g = AbstractNumberNode.GetInputNumber(_inputSocketG, 0, 0, 0, 0);
     _color.b = AbstractNumberNode.GetInputNumber(_inputSocketB, 0, 0, 0, 0);
     _color.a = AbstractNumberNode.GetInputNumber(_inputSocketA, 0, 0, 0, 0);
 }
예제 #2
0
 private void UpdateColor(Request request)
 {
     _color.r = AbstractNumberNode.GetInputNumber(_inputSocketR, request);
     _color.g = AbstractNumberNode.GetInputNumber(_inputSocketG, request);
     _color.b = AbstractNumberNode.GetInputNumber(_inputSocketB, request);
     _color.a = AbstractNumberNode.GetInputNumber(_inputSocketA, request);
 }
예제 #3
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;
                        }
                    }
                }
            }
        }
예제 #4
0
    public override List <Vector3> GetVector3List(OutputSocket outSocket, float x, float y, float z, float sizeX, float sizeY, float sizeZ, float seed)
    {
        List <Vector3> vec = GetInputVector3List(_inputSocketVector, x, y, z, sizeX, sizeY, sizeZ, seed);

        if (vec == null)
        {
            return(null);
        }

        List <Vector3> removeList = new List <Vector3>();

        for (var i = 0; i < vec.Count; i++)
        {
            float maskValue = AbstractNumberNode.GetInputNumber(_inputSocketMask, vec[i].x, vec[i].y, vec[i].z, seed);
            if (maskValue < 0 && outSocket == _outputSocket01)
            {
                removeList.Add(vec[i]);
            }
            if (maskValue >= 0 && outSocket == _outputSocket02)
            {
                removeList.Add(vec[i]);
            }
        }

        foreach (var r in removeList)
        {
            vec.Remove(r);
        }
        return(vec);
    }
예제 #5
0
        public override UnityEngine.Color GetColor(OutputSocket outSocket, Request request)
        {
            float rangeScale = AbstractNumberNode.GetInputNumber(_inputSocketRangeScale, request);

            if (float.IsNaN(request.Y))
            {
                return(_nanColor);
            }
            UnityEngine.Color color = _gradient.Evaluate((request.Y * rangeScale + 1) / 2f);
            return(color);
        }
예제 #6
0
        public override List <UnityEngine.Vector3> GetVector3List(OutputSocket outSocket, float x, float y, float z,
                                                                  float sizeX, float sizeY, float sizeZ, float seed)
        {
            float valueX = AbstractNumberNode.GetInputNumber(_inputX, x, y, z, seed);
            float valueY = AbstractNumberNode.GetInputNumber(_inputY, x, y, z, seed);
            float valueZ = AbstractNumberNode.GetInputNumber(_inputZ, x, y, z, seed);
            List <UnityEngine.Vector3> positions = new List <UnityEngine.Vector3>();

            positions.Add(new UnityEngine.Vector3(valueX, valueY, valueZ));
            return(positions);
        }
예제 #7
0
        public override UnityEngine.Color GetColor(OutputSocket socket, Request request)
        {
            UnityEngine.Color color01 = GetInputColor(_inputSocketColor01, request);
            UnityEngine.Color color02 = GetInputColor(_inputSocketColor02, request);
            float             value   = AbstractNumberNode.GetInputNumber(_inputSocketValue, request);

            if (float.IsNaN(value))
            {
                return(UnityEngine.Color.magenta);
            }
            value = (value + 1) / 2;
            UnityEngine.Color color = color01 * value + color02 * (1 - value);
            return(color);
        }
예제 #8
0
        public override List <UnityEngine.Vector3> GetVector3List(OutputSocket outSocket, Request request)
        {
            float valueX = AbstractNumberNode.GetInputNumber(_inputX, request);
            float valueY = AbstractNumberNode.GetInputNumber(_inputY, request);
            float valueZ = AbstractNumberNode.GetInputNumber(_inputZ, request);

            if (float.IsNaN(valueX) || float.IsNaN(valueY) || float.IsNaN(valueZ))
            {
                return(null);
            }

            List <UnityEngine.Vector3> positions = new List <UnityEngine.Vector3>();

            positions.Add(new UnityEngine.Vector3(valueX, valueY, valueZ));
            return(positions);
        }
예제 #9
0
        public override List <UnityEngine.Vector3> GetVector3List(OutputSocket s, Request request)
        {
            float left  = request.X;
            float right = request.X + request.SizeX;

            if (request.SizeX < 0)
            {
                left  = request.X + request.SizeX;
                right = request.X;
            }

            left  = Mathf.Floor(left);
            right = Mathf.Ceil(right);

            float bottom = request.Z;
            float top    = request.Z + request.SizeZ;

            if (request.SizeZ < 0)
            {
                bottom = request.Z + request.SizeZ;
                top    = request.Z;
            }

            bottom = Mathf.Floor(bottom);
            top    = Mathf.Ceil(top);

            float scaleX = AbstractNumberNode.GetInputNumber(_inputX, request);
            float scaleZ = AbstractNumberNode.GetInputNumber(_inputZ, request);


            List <UnityEngine.Vector3> positions = new List <UnityEngine.Vector3>();

            for (int leftIndex = Mathf.FloorToInt(left / scaleX); leftIndex <= Mathf.CeilToInt(right / scaleX); leftIndex++)
            {
                for (int bottomIndex = Mathf.FloorToInt(bottom / scaleZ); bottomIndex <= Mathf.CeilToInt(top / scaleZ); bottomIndex++)
                {
                    if (leftIndex * scaleX >= left && leftIndex * scaleX < right)
                    {
                        if (bottomIndex * scaleZ >= bottom && bottomIndex * scaleZ < top)
                        {
                            positions.Add(new UnityEngine.Vector3(leftIndex * scaleX, 0, bottomIndex * scaleZ));
                        }
                    }
                }
            }
            return(positions);
        }
예제 #10
0
    public override List <Vector3> GetVector3List(OutputSocket s, float x, float y, float z, float sizeX, float sizeY, float sizeZ, float seed)
    {
        float left  = x;
        float right = x + sizeX;

        if (sizeX < 0)
        {
            left  = x + sizeX;
            right = x;
        }

        left  = (float)Math.Floor(left);
        right = (float)Math.Ceiling(right);

        float bottom = z;
        float top    = z + sizeZ;

        if (sizeZ < 0)
        {
            bottom = z + sizeZ;
            top    = z;
        }

        bottom = (float)Math.Floor(bottom);
        top    = (float)Math.Ceiling(top);

        float scaleX = AbstractNumberNode.GetInputNumber(_inputX, x, y, z, seed);
        float scaleZ = AbstractNumberNode.GetInputNumber(_inputZ, x, y, z, seed);


        List <Vector3> positions = new List <Vector3>();

        for (int leftIndex = (int)Math.Floor(left / scaleX); leftIndex <= (int)Math.Ceiling(right / scaleX); leftIndex++)
        {
            for (int bottomIndex = (int)Math.Floor(bottom / scaleZ); bottomIndex <= (int)Math.Ceiling(top / scaleZ); bottomIndex++)
            {
                if (leftIndex * scaleX >= left && leftIndex * scaleX < right)
                {
                    if (bottomIndex * scaleZ >= bottom && bottomIndex * scaleZ < top)
                    {
                        positions.Add(new Vector3(leftIndex * scaleX, 0, bottomIndex * scaleZ));
                    }
                }
            }
        }
        return(positions);
    }
예제 #11
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;
                        }
                    }
                }
            }
        }
예제 #12
0
        /// <summary>
        /// Requests the chunks relative to the assigned parameter.
        /// Does not request chunks that are already loaded.
        /// Does not request if no new chunks are in sight.
        /// </summary>
        /// <param name="requestCenterWorld">The position of the request center in world coordinates.</param>
        public void RequestChunks(UnityEngine.Vector3 requestCenterWorld)
        {
            float seed    = AbstractNumberNode.GetInputNumber(_inputSocketSeed, new Request());
            var   request = new Request();

            request.Seed = seed;
            int size   = Mathf.CeilToInt(AbstractNumberNode.GetInputNumber(_inputSocketSize, request));
            int radius = Mathf.CeilToInt(AbstractNumberNode.GetInputNumber(_inputSocketChunkRadius, request));

            if (float.IsNaN(size) || float.IsNaN(radius) || size < 1 || radius < 1)
            {
                return;
            }

            Vector2 newCenterChunk = ToChunkPosition(requestCenterWorld.x, requestCenterWorld.z, size, size);

            bool hasMoved = !_requestCenterChunk.Equals(newCenterChunk);

            if (!hasMoved)
            {
                return;
            }

            _requestCenterChunk = newCenterChunk;

            RemoveNotInSightChunks(size, size, requestCenterWorld, radius);


            for (var x = (int)_requestCenterChunk.x - radius; x <= _requestCenterChunk.x + radius; x++)
            {
                for (var z = (int)_requestCenterChunk.y - radius; z <= _requestCenterChunk.y + radius; z++)
                {
                    if (IsChunkInSight(x, z, size, size, requestCenterWorld, radius))
                    {
                        Assets.GDI.Code.Chunk.Chunk chunk = GetChunk(x, z, size, size, seed);
                        if (chunk != null)
                        {
                            chunk.Update();
                        }
                    }
                }
            }
        }
예제 #13
0
        public override List <UnityEngine.Vector3> GetVector3List(OutputSocket socket, Request request)
        {
            Request r = new Request();
            List <UnityEngine.Vector3> vec = GetInputVector3List(_inputSocketVec, request);

            if (vec == null)
            {
                return(null);
            }

            for (var i = 0; i < vec.Count; i++)
            {
                UnityEngine.Vector3 v = vec[i];
                r.X    = v.x;
                r.Y    = v.y;
                r.Z    = v.z;
                r.Seed = request.Seed;
                float noise  = AbstractNumberNode.GetInputNumber(_inputSocketNoise, r);
                float offset = AbstractNumberNode.GetInputNumber(_inputSocketOffset, r);

                if (float.IsNaN(noise) || float.IsNaN(offset))
                {
                    continue;
                }

                if (_offsetX)
                {
                    v.x += offset * noise;
                }
                if (_offsetY)
                {
                    v.y += offset * noise;
                }
                if (_offsetZ)
                {
                    v.z += offset * noise;
                }

                vec[i] = v;
            }

            return(vec);
        }
예제 #14
0
        public override List <UnityEngine.Vector3> GetVector3List(OutputSocket s, float x, float y, float z, float sizeX, float sizeY, float sizeZ, float seed)
        {
            List <UnityEngine.Vector3> vectors = GetInputVector3List(_inputSocketVectors, x, y, z, sizeX, sizeY, sizeZ, seed);

            if (vectors != null)
            {
                for (var i = 0; i < vectors.Count; i++)
                {
                    UnityEngine.Vector3 v = vectors[i];

                    float valueX = AbstractNumberNode.GetInputNumber(_inputSocketX, v.x, v.y, v.z, seed);
                    float valueY = AbstractNumberNode.GetInputNumber(_inputSocketY, v.x, v.y, v.z, seed);
                    float valueZ = AbstractNumberNode.GetInputNumber(_inputSocketZ, v.x, v.y, v.z, seed);

                    //Debug.Log("valueX " + valueX + " valueY " + valueY + " valueZ " + valueZ);

                    if (_selectedMode == 0)
                    {
                        v.Set(v.x + valueX, v.y + valueY, v.z + valueZ);
                    }
                    if (_selectedMode == 1)
                    {
                        v.Set(v.x - valueX, v.y - valueY, v.z - valueZ);
                    }
                    if (_selectedMode == 2)
                    {
                        v.Set(v.x * valueX, v.y * valueY, v.z * valueZ);
                    }
                    if (_selectedMode == 3)
                    {
                        v.Set(valueX != 0 ? v.x / valueX : v.x, valueY != 0 ? v.y / valueY : v.y, valueZ != 0 ? v.z / valueZ : valueZ);
                    }

                    vectors[i] = v;

                    //Debug.Log("x " + vectors[i].x + " y " + vectors[i].y + " z " + vectors[i].z + " valueY " + valueY);
                }
            }
            return(vectors);
        }
예제 #15
0
        public override List <UnityEngine.Vector3> GetVector3List(OutputSocket socket, float x, float y, float z, float sizeX, float sizeY, float sizeZ, float seed)
        {
            List <UnityEngine.Vector3> vec = GetInputVector3List(_inputSocketVec, x, y, z, sizeX, sizeY, sizeZ, seed);

            if (vec == null)
            {
                return(null);
            }

            for (var i = 0; i < vec.Count; i++)
            {
                UnityEngine.Vector3 v = vec[i];

                float noise  = AbstractNumberNode.GetInputNumber(_inputSocketNoise, v.x, v.y, v.z, seed);
                float offset = AbstractNumberNode.GetInputNumber(_inputSocketOffset, v.x, v.y, v.z, seed);

                if (float.IsNaN(noise) || float.IsNaN(offset))
                {
                    continue;
                }

                if (_offsetX)
                {
                    v.x += offset * noise;
                }
                if (_offsetY)
                {
                    v.y += offset * noise;
                }
                if (_offsetZ)
                {
                    v.z += offset * noise;
                }

                vec[i] = v;
            }

            return(vec);
        }
예제 #16
0
        public override List <UnityEngine.Vector3> GetVector3List(OutputSocket s, Request request)
        {
            Request r = new Request();
            List <UnityEngine.Vector3> vectors = GetInputVector3List(_inputSocketVectors, request);

            if (vectors != null)
            {
                for (var i = 0; i < vectors.Count; i++)
                {
                    UnityEngine.Vector3 v = vectors[i];
                    r.X    = v.x;
                    r.Y    = v.y;
                    r.Z    = v.z;
                    r.Seed = request.Seed;
                    float valueX = AbstractNumberNode.GetInputNumber(_inputSocketX, r);
                    float valueY = AbstractNumberNode.GetInputNumber(_inputSocketY, r);
                    float valueZ = AbstractNumberNode.GetInputNumber(_inputSocketZ, r);

                    if (_selectedMode == 0)
                    {
                        v.Set(v.x + valueX, v.y + valueY, v.z + valueZ);
                    }
                    if (_selectedMode == 1)
                    {
                        v.Set(v.x - valueX, v.y - valueY, v.z - valueZ);
                    }
                    if (_selectedMode == 2)
                    {
                        v.Set(v.x * valueX, v.y * valueY, v.z * valueZ);
                    }
                    if (_selectedMode == 3)
                    {
                        v.Set(valueX != 0 ? v.x / valueX : v.x, valueY != 0 ? v.y / valueY : v.y, valueZ != 0 ? v.z / valueZ : valueZ);
                    }
                    vectors[i] = v;
                }
            }
            return(vectors);
        }
예제 #17
0
        public override List <UnityEngine.Vector3> GetVector3List(OutputSocket outSocket, Request request)
        {
            List <UnityEngine.Vector3> vec = GetInputVector3List(_inputSocketVector, request);

            if (vec == null)
            {
                return(null);
            }

            List <UnityEngine.Vector3> removeList = new List <UnityEngine.Vector3>();

            Request r = new Request();

            for (var i = 0; i < vec.Count; i++)
            {
                r.X    = vec[i].x;
                r.Y    = vec[i].y;
                r.Z    = vec[i].z;
                r.Seed = request.Seed;
                float maskValue = AbstractNumberNode.GetInputNumber(_inputSocketMask, r);
                if (maskValue < 0 && outSocket == _outputSocket01)
                {
                    removeList.Add(vec[i]);
                }
                if (maskValue >= 0 && outSocket == _outputSocket02)
                {
                    removeList.Add(vec[i]);
                }
            }

            for (int index = 0; index < removeList.Count; index++)
            {
                var remove = removeList[index];
                vec.Remove(remove);
            }
            return(vec);
        }
예제 #18
0
 public float GetRotationY(Request request)
 {
     return(AbstractNumberNode.GetInputNumber(_inputSocketRotationY, request));
 }
예제 #19
0
 public float GetNumber(OutputSocket socket, Request request)
 {
     return(AbstractNumberNode.GetInputNumber(_heightValueSocket, request));
 }
예제 #20
0
 public float GetScaleZ(Request request)
 {
     return(AbstractNumberNode.GetInputNumber(_inputSocketScaleZ, request));
 }
예제 #21
0
 public float GetHeightFactor(Request request)
 {
     return(AbstractNumberNode.GetInputNumber(_inputSocketHeightFactor, request));
 }