Exemplo n.º 1
0
        public override void Run(VectorEntity ve, UnityTile tile)
        {
            var min  = Math.Min(_materials.Length, ve.MeshFilter.mesh.subMeshCount);
            var mats = new Material[min];

            if (!_projectMapImagery)
            {
                for (int i = 0; i < min; i++)
                {
                    mats[i] = _materials[i].Materials[UnityEngine.Random.Range(0, _materials[i].Materials.Length)];
                }
            }
            else
            {
                for (int i = 0; i < min; i++)
                {
                    mats[i] = Instantiate(_materials[i].Materials[UnityEngine.Random.Range(0, _materials[i].Materials.Length)]);
                }

                mats[0].mainTexture      = tile.GetRasterData();
                mats[0].mainTextureScale = new Vector2(1f, 1f);
            }

            ve.MeshRenderer.materials = mats;
        }
Exemplo n.º 2
0
        public override void Run(VectorEntity ve, UnityTile tile)
        {
            var _meshRenderer = ve.MeshRenderer;

            if (_textureSides && _sideMaterials.Length > 0)
            {
                _meshRenderer.materials = new Material[2]
                {
                    _topMaterials[Random.Range(0, _topMaterials.Length)],
                    _sideMaterials[Random.Range(0, _sideMaterials.Length)]
                };
            }
            else if (_textureTop)
            {
                _meshRenderer.materials = new Material[1]
                {
                    _topMaterials[Random.Range(0, _topMaterials.Length)]
                };
            }

            if (_useSatelliteTexture)
            {
                _meshRenderer.materials[0].mainTexture      = tile.GetRasterData();
                _meshRenderer.materials[0].mainTextureScale = new Vector2(1f, 1f);
            }
        }
        public override void Run(VectorEntity ve, UnityTile tile)
        {
            var min  = Math.Min(_options.materials.Length, ve.MeshFilter.mesh.subMeshCount);
            var mats = new Material[min];

            if (_options.style != StyleTypes.Satellite)
            {
                for (int i = 0; i < min; i++)
                {
                    mats[i] = _options.materials[i].Materials[UnityEngine.Random.Range(0, _options.materials[i].Materials.Length)];
                }
            }
            else
            {
                for (int i = 0; i < min; i++)
                {
                    mats[i] = _options.materials[i].Materials[UnityEngine.Random.Range(0, _options.materials[i].Materials.Length)];
                }

                mats[0].mainTexture      = tile.GetRasterData();
                mats[0].mainTextureScale = new Vector2(1f, 1f);
            }

            ve.MeshRenderer.materials = mats;
        }
Exemplo n.º 4
0
        public override void Run(VectorEntity ve, UnityTile tile)
        {
            var min  = Math.Min(_materials.Length, ve.MeshFilter.mesh.subMeshCount);
            var mats = new Material[min];

            if (!_projectMapImagery)
            {
                for (int i = 0; i < min; i++)
                {
                    mats[i] = _materials[i].Materials[UnityEngine.Random.Range(0, _materials[i].Materials.Length)];
                }
            }
            else
            {
                Material sideMaterial = _materials[1].Materials[UnityEngine.Random.Range(0, _materials[1].Materials.Length)];
                Material topMaterial  = new Material(sideMaterial.shader);
                mats = new Material[2] {
                    topMaterial,
                    sideMaterial
                };

                if (min > 0)
                {
                    mats[0].mainTexture      = tile.GetRasterData();
                    mats[0].mainTextureScale = new Vector2(1f, 1f);
                }
            }
            ve.MeshRenderer.materials = mats;

            if (min > 0)
            {
                DynamicMaterialModifier.Instance.modifyMaterial(ve.Feature.Properties, ve.MeshRenderer.materials);
            }
        }
Exemplo n.º 5
0
        public override void Run(VectorEntity ve, UnityTile tile)
        {
            var min  = Math.Min(_options.materials.Length, ve.MeshFilter.sharedMesh.subMeshCount);
            var mats = new Material[min];

            if (_options.style == StyleTypes.Custom)
            {
                for (int i = 0; i < min; i++)
                {
                    mats[i] = _options.customStyleOptions.materials[i].Materials[UnityEngine.Random.Range(0, _options.customStyleOptions.materials[i].Materials.Length)];
                }
            }
            else if (_options.style == StyleTypes.Satellite)
            {
                for (int i = 0; i < min; i++)
                {
                    mats[i] = Instantiate(_options.materials[i].Materials[UnityEngine.Random.Range(0, _options.materials[i].Materials.Length)]);
                }

                mats[0].mainTexture      = tile.GetRasterData();
                mats[0].mainTextureScale = new Vector2(1f, 1f);
            }
            else
            {
                float renderMode = 0.0f;
                switch (_options.style)
                {
                case StyleTypes.Light:
                    renderMode = GetRenderMode(_options.lightStyleOpacity);
                    break;

                case StyleTypes.Dark:
                    renderMode = GetRenderMode(_options.darkStyleOpacity);
                    break;

                case StyleTypes.Color:
                    renderMode = GetRenderMode(_options.colorStyleColor.a);
                    break;

                default:
                    break;
                }
                for (int i = 0; i < min; i++)
                {
                    mats[i] = _options.materials[i].Materials[UnityEngine.Random.Range(0, _options.materials[i].Materials.Length)];
                    mats[i].SetFloat("_Mode", renderMode);
                }
            }
            ve.MeshRenderer.materials = mats;
        }
Exemplo n.º 6
0
        public void Initialize(FeatureBehaviour feature, bool doTextureTop, bool useSatelliteRoof, Material[] topTextures, bool doTextureSides, Material[] sideTextures)
        {
            _useSatelliteRoof = useSatelliteRoof;
            _textureTop       = doTextureTop;
            _textureSides     = doTextureSides;

            _tile = GetComponent <UnityTile>();
            var t = transform;

            while (_tile == null && t.parent != null)
            {
                t     = t.parent;
                _tile = t.GetComponent <UnityTile>();
            }
            _feature      = feature;
            _topTextures  = topTextures;
            _sideTextures = sideTextures;
            _meshRenderer = GetComponent <MeshRenderer>();

            if (_textureSides && _sideTextures.Length > 0)
            {
                _meshRenderer.materials = new Material[2]
                {
                    _topTextures[Random.Range(0, _topTextures.Length)],
                    _sideTextures[Random.Range(0, _sideTextures.Length)]
                };
            }
            else if (_textureTop)
            {
                _meshRenderer.materials = new Material[1]
                {
                    _topTextures[Random.Range(0, _topTextures.Length)]
                };
            }

            if (_useSatelliteRoof)
            {
                _meshRenderer.materials[0].mainTexture      = _tile.GetRasterData();
                _meshRenderer.materials[0].mainTextureScale = new Vector2(1f, 1f);
            }
        }