コード例 #1
0
 public List <Vector3> GetPositions(float x, float y, float z, float sizeX, float sizeY, float sizeZ, float seed)
 {
     if (!_inputSocketPosition.CanGetResult())
     {
         return(null);
     }
     return(AbstractVector3Node.GetInputVector3List(_inputSocketPosition, x, y, z, sizeX, sizeY, sizeZ, seed));
 }
コード例 #2
0
        public UnityEngine.GameObject GetGameObject(OutputSocket ouputSocket, Request request)
        {
            if (!_initialLoadingDone)
            {
                LoadGameObject(_objectIdentifier, false);
                _initialLoadingDone = true;
            }

            List <UnityEngine.Vector3> position = AbstractVector3Node.GetInputVector3List(_inputSocketPosition, request);

            if (position != null && position.Count > 0 && _gameObject != null)
            {
                _gameObject.transform.position = position[0];
            }

            UnityEngine.Material material = AbstractMaterialNode.GetInputMaterial(_inputSocketMaterial, request);
            if (_gameObject != null && material != null)
            {
                Renderer renderer = _gameObject.GetComponent <Renderer>();
                if (renderer == null)
                {
                    renderer = _gameObject.AddComponent <MeshRenderer>();
                }
                renderer.material = material;
            }

            List <UnityEngine.Vector3> scale = AbstractVector3Node.GetInputVector3List(_inputSocketScale, request);

            if (scale != null && scale.Count > 0 && _gameObject != null)
            {
                _gameObject.transform.localScale = scale[0];
            }

            List <UnityEngine.Vector3> rotation = AbstractVector3Node.GetInputVector3List(_inputSocketRotation, request);

            if (rotation != null && rotation.Count > 0 && _gameObject != null)
            {
                _gameObject.transform.localRotation = Quaternion.FromToRotation(UnityEngine.Vector3.up, rotation[0]);
            }

            return(_gameObject);
        }
コード例 #3
0
        public override float GetNumber(OutputSocket outSocket, Request request)
        {
            if (_colorMap == null)
            {
                return(float.NaN);
            }

            float mask = GetInputNumber(_inputSocketMask, request);

            if (float.IsNaN(mask))
            {
                return(float.NaN);
            }
            if (mask < 0)
            {
                return(float.NaN);
            }

            int width  = _colorMap.GetLength(0);
            int height = _colorMap.GetLength(1);

            float halfWidth  = Mathf.Ceil(width / 2f);
            float halfHeight = Mathf.Ceil(height / 2f);

            Request r = new Request();

            r.X     = request.X - width * 1.5f - 1;
            r.Y     = request.Y;
            r.Z     = request.Z - height * 1.5f - 1;
            r.SizeX = width * 3 + 1;
            r.SizeZ = height * 3 + 1;
            r.Seed  = request.Seed;

            List <UnityEngine.Vector3> points = AbstractVector3Node.GetInputVector3List(_inputSocketPoints, request);

            if (points == null)
            {
                return(float.NaN);
            }

            float value       = float.NaN;
            bool  initialized = false;

            for (int index = 0; index < points.Count; index++)
            {
                var point = points[index];
                if (!_fadeMask && !AllPositionsCoveredByMask(
                        (int)(point.x - halfWidth),
                        (int)(point.z - halfHeight), width, height, request.Y, request.Seed))
                {
                    continue;
                }


                int mapRelativeX = (int)(halfWidth - (point.x - request.X));
                int mapRelativeZ = (int)(halfHeight - (point.z - request.Z));
                if (mapRelativeX < width && mapRelativeX > 0 && mapRelativeZ < height && mapRelativeZ > 0)
                {
                    if (!initialized)
                    {
                        value       = 0;
                        initialized = true;
                    }
                    value += _colorMap[mapRelativeX, mapRelativeZ].grayscale;
                }
            }

            if (_fadeMask)
            {
                value = value * mask;
            }
            return(value);
        }
コード例 #4
0
        public override float GetNumber(OutputSocket outSocket, Request request)
        {
            float mask = GetInputNumber(_inputSocketMask, request);

            if (float.IsNaN(mask))
            {
                return(float.NaN);
            }
            if (mask < 0)
            {
                return(float.NaN);
            }

            int width  = Mathf.FloorToInt(GetInputNumber(_inputSocketWidth, request));
            int height = Mathf.FloorToInt(GetInputNumber(_inputSocketHeight, request));

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

            float halfWidth  = Mathf.Ceil(width / 2f);
            float halfHeight = Mathf.Ceil(height / 2f);

            Request r = new Request();

            r.X     = request.X - width * 1.5f - 1;
            r.Y     = request.Y;
            r.Z     = request.Z - height * 1.5f - 1;
            r.SizeX = width * 3 + 1;
            r.SizeZ = height * 3 + 1;
            r.Seed  = request.Seed;
            List <UnityEngine.Vector3> points = AbstractVector3Node.GetInputVector3List(_inputSocketVec, r);

            if (points == null)
            {
                return(float.NaN);
            }

            float value       = float.NaN;
            bool  initialized = false;

            Request r2 = new Request();

            for (int index = 0; index < points.Count; index++)
            {
                var point = points[index];
                if (!_fadeMask && !AllPositionsCoveredByMask(
                        (int)(point.x - halfWidth),
                        (int)(point.z - halfHeight), width, height, request.Y, request.Seed))
                {
                    continue;
                }

                int mapRelativeX = (int)(halfWidth - (point.x - request.X));
                int mapRelativeZ = (int)(halfHeight - (point.z - request.Z));
                if (mapRelativeX < width && mapRelativeX > 0 && mapRelativeZ < height && mapRelativeZ > 0)
                {
                    r2.X    = mapRelativeX;
                    r2.Z    = mapRelativeZ;
                    r2.Seed = request.Seed;
                    float v = GetInputNumber(_inputSocketValue, r2);
                    if (!initialized && !float.IsNaN(v))
                    {
                        value       = 0;
                        initialized = true;
                    }

                    if (!float.IsNaN(v))
                    {
                        value = v;
                    }
                }
            }

            if (_fadeMask)
            {
                value = value * mask;
            }
            return(value);
        }
コード例 #5
0
 public List <UnityEngine.Vector3> GetPositions(Request request)
 {
     return(AbstractVector3Node.GetInputVector3List(_inputSocketPositions, request));
 }