Ejemplo n.º 1
0
        public void AutoPaint(HeightMap heightMap, NormalMap normalMap, Vector3 mousePosition)
        {
            if (normalMap.HasChanged)
            {
                normalMap.UpdateNormalArray();
            }

            var normals        = normalMap.Normals;
            var textureChanges = new bool[TerrainConfig.Textures.Length];
            var pos            = ((mousePosition.Xz / Map.MapData.MapSize) + new Vector2(0.5f)) * size;
            var radius         = (int)(State.ToolRadius * size / Map.MapData.MapSize);

            for (var z = (int)(pos.Y - radius); z < pos.Y + radius; z++)
            {
                for (var x = (int)(pos.X - radius); x < pos.X + radius; x++)
                {
                    if (Vector2.Distance(pos, new Vector2(x, z)) < State.ToolRadius / 2.0f)
                    {
                        autoPaintPixel(ref textureChanges, normals, heightMap, x, z);
                    }
                }
            }

            for (var i = 0; i < TerrainConfig.Textures.Length; i++)
            {
                if (textureChanges[i])
                {
                    ToTexture(i);
                }
            }
        }
Ejemplo n.º 2
0
        public void AutoPaint(HeightMap heightMap, NormalMap normalMap)
        {
            if (normalMap.HasChanged)
            {
                normalMap.UpdateNormalArray();
            }
            var normals        = normalMap.Normals;
            var textureChanges = new bool[TerrainConfig.Textures.Length];

            for (var z = 0; z < size; z++)
            {
                for (var x = 0; x < size; x++)
                {
                    autoPaintPixel(ref textureChanges, normals, heightMap, x, z);
                }
            }

            for (var i = 0; i < TerrainConfig.Textures.Length; i++)
            {
                if (textureChanges[i])
                {
                    ToTexture(i);
                }
            }
        }