Пример #1
0
    public void RunNode()
    {
        var layer = (NodeVariables.Texture)GetValue();

        if (layer == null)
        {
            return;
        }
        switch (layer.LandLayer)
        {
        case 0:
            MapManager.PaintConditional(LandLayers.Ground, TerrainSplat.TypeToIndex(layer.GroundTexture), conditions);
            break;

        case 1:
            MapManager.PaintConditional(LandLayers.Biome, TerrainBiome.TypeToIndex(layer.BiomeTexture), conditions);
            break;

        case 2:
            MapManager.PaintConditional(LandLayers.Alpha, layer.AlphaTexture, conditions);
            break;

        case 3:
            MapManager.PaintConditional(LandLayers.Topology, layer.TopologyTexture, conditions, layer.TopologyLayer);
            break;
        }
    }
Пример #2
0
    public void RunNode()
    {
        var layer = (NodeVariables.Texture)GetValue();

        if (layer == null) // Check for if the textures node is not connected.
        {
            return;
        }
        switch (layer.LandLayer)
        {
        case 0:
            MapManager.PaintLayer(LandLayers.Ground, TerrainSplat.TypeToIndex(layer.GroundTexture));
            break;

        case 1:
            MapManager.PaintLayer(LandLayers.Biome, TerrainBiome.TypeToIndex(layer.BiomeTexture));
            break;

        case 2:
            MapManager.PaintLayer(LandLayers.Alpha, layer.AlphaTexture);
            break;

        case 3:
            MapManager.PaintLayer(LandLayers.Topology, layer.TopologyTexture, layer.TopologyLayer);
            break;
        }
    }
Пример #3
0
    private void OnGUI()
    {
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, false);

        GUIContent[] layersOptionsMenu = new GUIContent[4];
        layersOptionsMenu[0] = new GUIContent("Ground");
        layersOptionsMenu[1] = new GUIContent("Biome");
        layersOptionsMenu[2] = new GUIContent("Alpha");
        layersOptionsMenu[3] = new GUIContent("Topology");

        EditorGUI.BeginChangeCheck();
        layerIndex = GUILayout.Toolbar(layerIndex, layersOptionsMenu, EditorStyles.toolbarButton);
        if (EditorGUI.EndChangeCheck())
            TerrainManager.ChangeLayer((TerrainManager.LayerType)layerIndex, TerrainTopology.TypeToIndex((int)layers.Topologies));

        if (layerIndex != (int)TerrainManager.CurrentLayerType)
            layerIndex = (int)TerrainManager.CurrentLayerType;

        switch ((TerrainManager.LayerType)layerIndex)
        {
            case TerrainManager.LayerType.Ground:
                Functions.TextureSelect(TerrainManager.CurrentLayerType, ref layers);
                Functions.AreaSelect();
                Functions.LayerTools(TerrainManager.CurrentLayerType, TerrainSplat.TypeToIndex((int)layers.Ground));
                Functions.RotateTools(TerrainManager.CurrentLayerType);
                Functions.RiverTools(TerrainManager.CurrentLayerType, TerrainSplat.TypeToIndex((int)layers.Ground), ref aboveTerrain);
                Functions.SlopeTools(TerrainManager.CurrentLayerType, TerrainSplat.TypeToIndex((int)layers.Ground), ref slopesInfo);
                Functions.HeightTools(TerrainManager.CurrentLayerType, TerrainSplat.TypeToIndex((int)layers.Ground), ref heightsInfo);
                break;
            case TerrainManager.LayerType.Biome:
                Functions.TextureSelect(TerrainManager.CurrentLayerType, ref layers);
                Functions.AreaSelect();
                Functions.LayerTools(TerrainManager.CurrentLayerType, TerrainBiome.TypeToIndex((int)layers.Biome));
                Functions.RotateTools(TerrainManager.CurrentLayerType);
                Functions.RiverTools(TerrainManager.CurrentLayerType, TerrainBiome.TypeToIndex((int)layers.Biome), ref aboveTerrain);
                Functions.SlopeTools(TerrainManager.CurrentLayerType, TerrainBiome.TypeToIndex((int)layers.Biome), ref slopesInfo);
                Functions.HeightTools(TerrainManager.CurrentLayerType, TerrainBiome.TypeToIndex((int)layers.Biome), ref heightsInfo);
                break;
            case TerrainManager.LayerType.Alpha:
                Functions.LayerTools((TerrainManager.LayerType)layerIndex, 0, 1);
                Functions.AreaSelect();
                Functions.RotateTools((TerrainManager.LayerType)layerIndex);
                Functions.RiverTools((TerrainManager.LayerType)layerIndex, 0, ref aboveTerrain, 1);
                Functions.SlopeTools((TerrainManager.LayerType)layerIndex, 0, ref slopesInfo, 1);
                Functions.HeightTools((TerrainManager.LayerType)layerIndex, 0, ref heightsInfo, 1);
                break;
            case TerrainManager.LayerType.Topology:
                Functions.TopologyLayerSelect(ref layers);
                Functions.AreaSelect();
                Functions.LayerTools(TerrainManager.CurrentLayerType, 0, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.RotateTools(TerrainManager.CurrentLayerType, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.TopologyTools();
                Functions.RiverTools(TerrainManager.CurrentLayerType, 0, ref aboveTerrain, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.SlopeTools(TerrainManager.CurrentLayerType, 0, ref slopesInfo, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.HeightTools(TerrainManager.CurrentLayerType, 0, ref heightsInfo, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));
                break;
        }
        EditorGUILayout.EndScrollView();
    }
Пример #4
0
        public static void ConditionalPaintLayerSelect(ref Conditions cnds, ref Layers layers, ref int texture)
        {
            Elements.MiniBoldLabel(ToolTips.textureToPaintLabel);

            Elements.BeginToolbarHorizontal();
            Elements.ToolbarLabel(ToolTips.layerSelect);
            layers.LandLayer = (LandLayers)Elements.ToolbarEnumPopup(layers.LandLayer);
            Elements.EndToolbarHorizontal();

            switch (layers.LandLayer)
            {
            case LandLayers.Ground:
                Elements.BeginToolbarHorizontal();
                Elements.ToolbarLabel(ToolTips.textureSelect);
                layers.Ground = (TerrainSplat.Enum)Elements.ToolbarEnumPopup(layers.Ground);
                texture       = TerrainSplat.TypeToIndex((int)layers.Ground);
                Elements.EndToolbarHorizontal();
                break;

            case LandLayers.Biome:
                Elements.BeginToolbarHorizontal();
                Elements.ToolbarLabel(ToolTips.textureSelect);
                layers.Biome = (TerrainBiome.Enum)Elements.ToolbarEnumPopup(layers.Biome);
                texture      = TerrainBiome.TypeToIndex((int)layers.Biome);
                Elements.EndToolbarHorizontal();
                break;

            case LandLayers.Alpha:
                Elements.BeginToolbarHorizontal();
                Elements.ToolbarLabel(ToolTips.textureSelect);
                layers.AlphaTexture = (AlphaTextures)Elements.ToolbarEnumPopup(layers.AlphaTexture);
                texture             = (int)layers.AlphaTexture;
                Elements.EndToolbarHorizontal();
                break;

            case LandLayers.Topology:
                Elements.BeginToolbarHorizontal();
                Elements.ToolbarLabel(ToolTips.topologyLayerSelect);
                layers.Topologies = (TerrainTopology.Enum)Elements.ToolbarEnumPopup(layers.Topologies);
                Elements.EndToolbarHorizontal();

                Elements.BeginToolbarHorizontal();
                Elements.ToolbarLabel(ToolTips.textureSelect);
                layers.TopologyTexture = (TopologyTextures)Elements.ToolbarEnumPopup(layers.TopologyTexture);
                texture = (int)layers.TopologyTexture;
                Elements.EndToolbarHorizontal();
                break;
            }

            Elements.BeginToolbarHorizontal();
            if (Elements.ToolbarButton(ToolTips.paintConditional))
            {
                MapManager.PaintConditional(layers.LandLayer, texture, cnds, TerrainTopology.TypeToIndex((int)layers.Topologies));
            }
            Elements.EndToolbarHorizontal();
        }
Пример #5
0
    public Color GetColor(float normX, float normZ, int mask = -1)
    {
        float biome   = this.biomeMap.GetBiome(normX, normZ, 1);
        float single  = this.biomeMap.GetBiome(normX, normZ, 2);
        float biome1  = this.biomeMap.GetBiome(normX, normZ, 4);
        float single1 = this.biomeMap.GetBiome(normX, normZ, 8);
        int   index   = TerrainSplat.TypeToIndex(this.splatMap.GetSplatMaxType(normX, normZ, mask));

        TerrainConfig.SplatType splats = this.config.Splats[index];
        return((((biome * splats.AridColor) + (single * splats.TemperateColor)) + (biome1 * splats.TundraColor)) + (single1 * splats.ArcticColor));
    }
Пример #6
0
    public Color GetColor(float normX, float normZ, int mask = -1)
    {
        double biome1 = (double)this.biomeMap.GetBiome(normX, normZ, 1);
        float  biome2 = this.biomeMap.GetBiome(normX, normZ, 2);
        float  biome3 = this.biomeMap.GetBiome(normX, normZ, 4);
        float  biome4 = this.biomeMap.GetBiome(normX, normZ, 8);

        TerrainConfig.SplatType splat = this.config.Splats[TerrainSplat.TypeToIndex(this.splatMap.GetSplatMaxType(normX, normZ, mask))];
        Color aridColor = splat.AridColor;

        return(Color.op_Addition(Color.op_Addition(Color.op_Addition(Color.op_Multiply((float)biome1, aridColor), Color.op_Multiply(biome2, splat.TemperateColor)), Color.op_Multiply(biome3, splat.TundraColor)), Color.op_Multiply(biome4, splat.ArcticColor)));
    }
Пример #7
0
    public static MapInfo EmptyMap(int size, float landHeight, TerrainSplat.Enum ground = TerrainSplat.Enum.Grass, TerrainBiome.Enum biome = TerrainBiome.Enum.Temperate)
    {
        MapInfo terrains = new MapInfo();

        int splatRes = Mathf.Clamp(Mathf.NextPowerOfTwo((int)(size * 0.50f)), 512, 2048);

        List <PathData>   paths   = new List <PathData>();
        List <PrefabData> prefabs = new List <PrefabData>();

        terrains.pathData   = paths.ToArray();
        terrains.prefabData = prefabs.ToArray();

        terrains.terrainRes = Mathf.Clamp(Mathf.NextPowerOfTwo(size), 512, 4096) + 1;
        terrains.size       = new Vector3(size, 1000, size);

        terrains.land.heights  = SetValues(new float[terrains.terrainRes, terrains.terrainRes], landHeight / 1000f, new Area(0, terrains.terrainRes, 0, terrains.terrainRes));
        terrains.water.heights = SetValues(new float[terrains.terrainRes, terrains.terrainRes], 500f / 1000f, new Area(0, terrains.terrainRes, 0, terrains.terrainRes));

        terrains.splatRes = splatRes;
        terrains.splatMap = new float[splatRes, splatRes, 8];
        int gndIdx = TerrainSplat.TypeToIndex((int)ground);

        Parallel.For(0, splatRes, i =>
        {
            for (int j = 0; j < splatRes; j++)
            {
                terrains.splatMap[i, j, gndIdx] = 1f;
            }
        });

        terrains.biomeMap = new float[splatRes, splatRes, 4];
        int biomeIdx = TerrainBiome.TypeToIndex((int)biome);

        Parallel.For(0, splatRes, i =>
        {
            for (int j = 0; j < splatRes; j++)
            {
                terrains.biomeMap[i, j, biomeIdx] = 1f;
            }
        });

        terrains.alphaMap = new bool[splatRes, splatRes];
        Parallel.For(0, splatRes, i =>
        {
            for (int j = 0; j < splatRes; j++)
            {
                terrains.alphaMap[i, j] = true;
            }
        });
        terrains.topology = new TerrainMap <int>(new byte[(int)Mathf.Pow(splatRes, 2) * 4 * 1], 1);
        return(terrains);
    }
Пример #8
0
    public void SetSplat(float normX, float normZ, int id, float opacity, float radius, float fade = 0f)
    {
        int index = TerrainSplat.TypeToIndex(id);
        Action <int, int, float> action = (int x, int z, float lerp) => {
            if (lerp > 0f)
            {
                float u003cu003e4_this = (float)this.dst[(index * this.res + z) * this.res + x];
                float single           = Mathf.Lerp(u003cu003e4_this, 1f, lerp * opacity);
                this.SetSplat(x, z, id, u003cu003e4_this, single);
            }
        };

        base.ApplyFilter(normX, normZ, radius, fade, action);
    }
Пример #9
0
    public void SetSplat(int x, int z, int id)
    {
        int index = TerrainSplat.TypeToIndex(id);

        for (int i = 0; i < this.num; i++)
        {
            if (i != index)
            {
                this.dst[(i * this.res + z) * this.res + x] = 0;
            }
            else
            {
                this.dst[(i * this.res + z) * this.res + x] = 255;
            }
        }
    }
Пример #10
0
    public void AddSplat(float normX, float normZ, int id, float delta, float radius, float fade = 0.0f)
    {
        int idx = TerrainSplat.TypeToIndex(id);
        Action <int, int, float> action = (Action <int, int, float>)((x, z, lerp) =>
        {
            if ((double)lerp <= 0.0)
            {
                return;
            }
            float old_val = (float)this.dst[(idx * this.res + z) * this.res + x];
            float new_val = Mathf.Clamp01(old_val + lerp * delta);
            this.SetSplat(x, z, id, old_val, new_val);
        });

        this.ApplyFilter(normX, normZ, radius, fade, action);
    }
Пример #11
0
    public void SetSplat(int x, int z, int id)
    {
        int index1 = TerrainSplat.TypeToIndex(id);

        for (int index2 = 0; index2 < this.num; ++index2)
        {
            if (index2 == index1)
            {
                this.dst[(index2 * this.res + z) * this.res + x] = byte.MaxValue;
            }
            else
            {
                this.dst[(index2 * this.res + z) * this.res + x] = (byte)0;
            }
        }
    }
Пример #12
0
    public float GetSplatMax(int x, int z, int mask = -1)
    {
        byte num = 0;

        for (int i = 0; i < this.num; i++)
        {
            if ((TerrainSplat.IndexToType(i) & mask) != 0)
            {
                byte num1 = this.src[(i * this.res + z) * this.res + x];
                if (num1 >= num)
                {
                    num = num1;
                }
            }
        }
        return(BitUtility.Byte2Float((int)num));
    }
Пример #13
0
    public float GetSplatMax(int x, int z, int mask = -1)
    {
        byte num1 = 0;

        for (int index = 0; index < this.num; ++index)
        {
            if ((TerrainSplat.IndexToType(index) & mask) != 0)
            {
                byte num2 = this.src[(index * this.res + z) * this.res + x];
                if ((int)num2 >= (int)num1)
                {
                    num1 = num2;
                }
            }
        }
        return(BitUtility.Byte2Float((int)num1));
    }
Пример #14
0
    public float GetSplat(int x, int z, int mask)
    {
        if (Mathf.IsPowerOfTwo(mask))
        {
            return(BitUtility.Byte2Float(this.src[(TerrainSplat.TypeToIndex(mask) * this.res + z) * this.res + x]));
        }
        int num = 0;

        for (int i = 0; i < this.num; i++)
        {
            if ((TerrainSplat.IndexToType(i) & mask) != 0)
            {
                num += this.src[(i * this.res + z) * this.res + x];
            }
        }
        return(Mathf.Clamp01(BitUtility.Byte2Float(num)));
    }
Пример #15
0
    public int GetSplatMaxIndex(int x, int z, int mask = -1)
    {
        byte num1 = 0;
        int  num2 = 0;

        for (int index = 0; index < this.num; ++index)
        {
            if ((TerrainSplat.IndexToType(index) & mask) != 0)
            {
                byte num3 = this.src[(index * this.res + z) * this.res + x];
                if ((int)num3 >= (int)num1)
                {
                    num1 = num3;
                    num2 = index;
                }
            }
        }
        return(num2);
    }
Пример #16
0
    public int GetSplatMaxIndex(int x, int z, int mask = -1)
    {
        byte num  = 0;
        int  num1 = 0;

        for (int i = 0; i < this.num; i++)
        {
            if ((TerrainSplat.IndexToType(i) & mask) != 0)
            {
                byte num2 = this.src[(i * this.res + z) * this.res + x];
                if (num2 >= num)
                {
                    num  = num2;
                    num1 = i;
                }
            }
        }
        return(num1);
    }
Пример #17
0
    private void SetSplat(int x, int z, int id, float old_val, float new_val)
    {
        int index1 = TerrainSplat.TypeToIndex(id);

        if ((double)old_val >= 1.0)
        {
            return;
        }
        float num = (float)((1.0 - (double)new_val) / (1.0 - (double)old_val));

        for (int index2 = 0; index2 < this.num; ++index2)
        {
            if (index2 == index1)
            {
                this.dst[(index2 * this.res + z) * this.res + x] = BitUtility.Float2Byte(new_val);
            }
            else
            {
                this.dst[(index2 * this.res + z) * this.res + x] = BitUtility.Float2Byte(num * BitUtility.Byte2Float((int)this.dst[(index2 * this.res + z) * this.res + x]));
            }
        }
    }
Пример #18
0
    private void SetSplat(int x, int z, int id, float old_val, float new_val)
    {
        int index = TerrainSplat.TypeToIndex(id);

        if (old_val >= 1f)
        {
            return;
        }
        float newVal = (1f - new_val) / (1f - old_val);

        for (int i = 0; i < this.num; i++)
        {
            if (i != index)
            {
                this.dst[(i * this.res + z) * this.res + x] = BitUtility.Float2Byte(newVal * BitUtility.Byte2Float(this.dst[(i * this.res + z) * this.res + x]));
            }
            else
            {
                this.dst[(i * this.res + z) * this.res + x] = BitUtility.Float2Byte(new_val);
            }
        }
    }
Пример #19
0
    public void RunNode()
    {
        var layer = (NodeVariables.Texture)GetValue();

        switch (layer.LandLayer)
        {
        case 0:
            MapManager.PaintRiver(LandLayers.Ground, aboveTerrain, TerrainSplat.TypeToIndex(layer.GroundTexture));
            break;

        case 1:
            MapManager.PaintRiver(LandLayers.Biome, aboveTerrain, TerrainBiome.TypeToIndex(layer.BiomeTexture));
            break;

        case 2:
            MapManager.PaintRiver(LandLayers.Alpha, aboveTerrain, layer.AlphaTexture);
            break;

        case 3:
            MapManager.PaintRiver(LandLayers.Topology, aboveTerrain, layer.TopologyTexture, layer.TopologyLayer);
            break;
        }
    }
Пример #20
0
        public static void NewMapOptions(ref int mapSize, ref float landHeight, ref Layers layers, CreateMapWindow window)
        {
            mapSize    = Elements.ToolbarIntSlider(ToolTips.mapSize, mapSize, 1000, 6000);
            landHeight = Elements.ToolbarSlider(ToolTips.newMapHeight, landHeight, 0, 1000);

            Elements.BeginToolbarHorizontal();
            Elements.ToolbarLabel(ToolTips.newMapGround);
            layers.Ground = (TerrainSplat.Enum)Elements.ToolbarEnumPopup(layers.Ground);
            Elements.EndToolbarHorizontal();

            Elements.BeginToolbarHorizontal();
            Elements.ToolbarLabel(ToolTips.newMapBiome);
            layers.Biome = (TerrainBiome.Enum)Elements.ToolbarEnumPopup(layers.Biome);
            Elements.EndToolbarHorizontal();

            Elements.BeginToolbarHorizontal();
            if (Elements.ToolbarButton(ToolTips.createMap))
            {
                window.Close();
                int newMap = EditorUtility.DisplayDialogComplex("Warning", "Creating a new map will remove any unsaved changes to your map.", "Create New Map", "Close", "Save and Create New Map");
                switch (newMap)
                {
                case 1:
                    return;

                case 2:
                    SaveMapPanel();
                    break;
                }
                MapManager.CreateMap(mapSize, TerrainSplat.TypeToIndex((int)layers.Ground), TerrainBiome.TypeToIndex((int)layers.Biome), landHeight);
            }
            if (Elements.ToolbarButton(ToolTips.cancel))
            {
                window.Close();
            }
            Elements.EndToolbarHorizontal();
        }
Пример #21
0
    public void OnGUI()
    {
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, false);
        GUIContent[] mainMenu = new GUIContent[6];
        mainMenu[0] = new GUIContent("File");
        mainMenu[1] = new GUIContent("Settings");
        mainMenu[2] = new GUIContent("Prefabs");
        mainMenu[3] = new GUIContent("Layers");
        mainMenu[4] = new GUIContent("Generator");
        mainMenu[5] = new GUIContent("Advanced");

        mainMenuOptions = GUILayout.Toolbar(mainMenuOptions, mainMenu, EditorStyles.toolbarButton);

        Functions.SaveSettings();

        #region Menu
        switch (mainMenuOptions)
        {
            #region File
        case 0:
            Functions.EditorIO();
            Functions.NewMapOptions(ref mapSize, ref landHeight, ref layers);
            Functions.MapInfo();
            break;

            #endregion
            #region Prefabs
        case 1:
            Functions.EditorSettings();
            Functions.EditorInfo();

            Functions.EditorLinks();
            break;

        case 2:
            Functions.Replacer(ref replacer, ref replacerPresetIndex, ref replacerList);
            break;

            #endregion
        case 3:
            GUIContent[] layersMenu = new GUIContent[4];
            layersMenu[0] = new GUIContent("Ground");
            layersMenu[1] = new GUIContent("Biome");
            layersMenu[2] = new GUIContent("Alpha");
            layersMenu[3] = new GUIContent("Topology");

            EditorGUI.BeginChangeCheck();
            layerIndex = GUILayout.Toolbar(layerIndex, layersMenu, EditorStyles.toolbarButton);

            if (EditorGUI.EndChangeCheck())
            {
                Functions.SetLandLayer((LandLayers)layerIndex, TerrainTopology.TypeToIndex((int)layers.Topologies));
            }

            switch (TerrainManager.LandLayer)
            {
            case LandLayers.Ground:
                Functions.TextureSelect((LandLayers)layerIndex, ref layers);

                Functions.LayerTools(TerrainManager.LandLayer, TerrainSplat.TypeToIndex((int)layers.Ground));



                crazing            = SettingsManager.crazing;
                crazing.splatLayer = TerrainTopology.TypeToIndex((int)layers.Ground);
                Functions.Crazing(ref crazing);

                perlinSplat            = SettingsManager.perlinSplat;
                perlinSplat.splatLayer = TerrainTopology.TypeToIndex((int)layers.Ground);
                Functions.PerlinSplat(ref perlinSplat);

                Functions.HeightTools(TerrainManager.LandLayer, TerrainSplat.TypeToIndex((int)layers.Ground), ref heightsInfo);
                Functions.SlopeTools(TerrainManager.LandLayer, TerrainSplat.TypeToIndex((int)layers.Ground), ref slopesInfo);

                Functions.RiverTools(TerrainManager.LandLayer, TerrainSplat.TypeToIndex((int)layers.Ground), ref aboveTerrain);

                break;

            case LandLayers.Biome:
                Functions.TextureSelect((LandLayers)layerIndex, ref layers);

                Functions.LayerTools(TerrainManager.LandLayer, TerrainBiome.TypeToIndex((int)layers.Biome));


                Functions.HeightTools(TerrainManager.LandLayer, TerrainBiome.TypeToIndex((int)layers.Biome), ref heightsInfo);
                Functions.SlopeTools(TerrainManager.LandLayer, TerrainBiome.TypeToIndex((int)layers.Biome), ref slopesInfo);
                break;

            case LandLayers.Alpha:

                Functions.LayerTools(TerrainManager.LandLayer, 0, 1);

                break;

            case LandLayers.Topology:

                Functions.TopologyTools();

                Functions.TopologyLayerSelect(ref layers);

                Functions.LayerTools(TerrainManager.LandLayer, 0, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));


                Functions.HeightTools(TerrainManager.LandLayer, 0, ref heightsInfo, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.SlopeTools(TerrainManager.LandLayer, 0, ref slopesInfo, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));

                Functions.Combinator(ref layers, ref sourceLayers, ref tttWeight, ref thicc);


                Functions.RiverTools(TerrainManager.LandLayer, 0, ref aboveTerrain, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.LakeOcean(ref layers);
                break;
            }

            switch (mapToolsOptions)
            {
                /*
                 #region HeightMap
                 * case 0:
                 * GUIContent[] heightMapMenu = new GUIContent[2];
                 * heightMapMenu[0] = new GUIContent("Heights");
                 * heightMapMenu[1] = new GUIContent("Filters");
                 * heightMapOptions = GUILayout.Toolbar(heightMapOptions, heightMapMenu, EditorStyles.toolbarButton);
                 *
                 * switch (heightMapOptions)
                 * {
                 * case 0:
                 * Elements.BoldLabel(ToolTips.heightsLabel);
                 * Functions.OffsetMap(ref offset, ref clampOffset);
                 * Functions.SetHeight(ref heightSet);
                 * Functions.ClampHeight(ref heightLow, ref heightHigh);
                 * Elements.BoldLabel(ToolTips.miscLabel);
                 * Functions.InvertMap();
                 * break;
                 * case 1:
                 * Functions.NormaliseMap(ref normaliseLow, ref normaliseHigh, ref autoUpdate);
                 * Functions.SmoothMap(ref filterStrength, ref blurDirection, ref smoothPasses);
                 * Functions.TerraceMap(ref terraceErodeFeatureSize, ref terraceErodeInteriorCornerWeight);
                 * break;
                 * }
                 * break;
                 #endregion
                 *
                 #region Textures
                 * case 0:
                 * Functions.ConditionalPaint(ref conditionalPaintOptions, ref texture, ref conditions, ref layers);
                 * break;
                 #endregion
                 *
                 #region Misc
                 * case 2:
                 * Functions.RotateMap(ref rotateSelection);
                 * break;
                 #endregion
                 */
            }
            break;

        case 4:
            GUIContent[] generatorMenu = new GUIContent[3];
            generatorMenu[0] = new GUIContent("Heightmap");
            generatorMenu[1] = new GUIContent("Geology");
            generatorMenu[2] = new GUIContent("Monuments");

            generatorOptions = GUILayout.Toolbar(generatorOptions, generatorMenu, EditorStyles.toolbarButton);
            switch (generatorOptions)
            {
            case 0:
                Functions.SetHeight(ref heightSet);
                Functions.OffsetMap(ref offset, ref clampOffset);

                perlin = SettingsManager.perlin;
                Functions.PerlinTerrain(ref perlin);

                Functions.NormaliseMap(ref normaliseLow, ref normaliseHigh, ref autoUpdate);

                ocean = SettingsManager.ocean;
                Functions.Ocean(ref ocean);

                ripple = SettingsManager.ripple;
                Functions.Ripple(ref ripple);

                terracing = SettingsManager.terracing;
                Functions.RandomTerracing(ref terracing);

                break;

            case 1:
                Functions.Geology(ref activePreset, ref presetIndex, ref geologyList, ref macroIndex, ref macroList, ref macroTitle, ref macroDisplay, ref layers);
                break;

            case 2:
                city = SettingsManager.city;
                Functions.RustCity(ref city);
                break;
            }
            break;

        case 5:
            Functions.Merger(ref zOffset);
            break;
        }
        #endregion
        EditorGUILayout.EndScrollView();
    }
        warp_Object CreateTerrain(WarpRenderer renderer, bool textureTerrain)
        {
            ITerrainChannel terrain = m_scene.RequestModuleInterface <ITerrainChannel> ();

            float diffX  = 1.0f; //(float) m_scene.RegionInfo.RegionSizeX/(float) Constants.RegionSize;
            float diffY  = 1.0f; //(float) m_scene.RegionInfo.RegionSizeY/(float) Constants.RegionSize;
            int   newRsX = m_scene.RegionInfo.RegionSizeX / (int)diffX;
            int   newRsY = m_scene.RegionInfo.RegionSizeY / (int)diffY;

            warp_Object obj = new warp_Object(newRsX * newRsY, ((newRsX - 1) * (newRsY - 1) * 2));

            for (float y = 0; y < m_scene.RegionInfo.RegionSizeY; y += diffY)
            {
                for (float x = 0; x < m_scene.RegionInfo.RegionSizeX; x += diffX)
                {
                    float t_height    = terrain [(int)x, (int)y];
                    float waterHeight = (float)m_scene.RegionInfo.RegionSettings.WaterHeight;

                    //clamp to eliminate artifacts
                    t_height = Utils.Clamp(t_height, waterHeight - 0.5f, waterHeight + 0.5f);
                    if (t_height < 0.0f)
                    {
                        t_height = 0.0f;
                    }

                    warp_Vector pos = ConvertVector(x / diffX, y / diffY, t_height);
                    obj.addVertex(
                        new warp_Vertex(pos,
                                        x / m_scene.RegionInfo.RegionSizeX,
                                        (m_scene.RegionInfo.RegionSizeY - y) / (m_scene.RegionInfo.RegionSizeY)));
                }
            }

            const float normal_map_reduction = 2.0f; //2.0f-2.5f is the sweet spot

            for (float y = 0; y < m_scene.RegionInfo.RegionSizeY; y += diffY)
            {
                for (float x = 0; x < m_scene.RegionInfo.RegionSizeX; x += diffX)
                {
                    float newX = x / diffX;
                    float newY = y / diffY;

                    if (newX < newRsX - 1 && newY < newRsY - 1)
                    {
                        int v = (int)(newY * newRsX + newX);

                        // Normal
                        Vector3 v1 = new Vector3(newX, newY, (terrain [(int)x, (int)y]) / normal_map_reduction);
                        Vector3 v2 = new Vector3(newX + 1, newY,
                                                 (terrain [(int)x + 1, (int)y]) / normal_map_reduction);
                        Vector3 v3 = new Vector3(newX, newY + 1,
                                                 (terrain [(int)x, (int)(y + 1)]) / normal_map_reduction);
                        warp_Vector norm = ConvertVector(SurfaceNormal(v1, v2, v3));
                        norm            = norm.reverse();
                        obj.vertex(v).n = norm;

                        // Triangle 1
                        obj.addTriangle(
                            v,
                            v + 1,
                            v + newRsX);

                        // Triangle 2
                        obj.addTriangle(
                            v + newRsX + 1,
                            v + newRsX,
                            v + 1);
                    }
                }
            }

            renderer.Scene.addObject("Terrain", obj);
            renderer.Scene.sceneobject("Terrain").setPos(0.0f, 0.0f, 0.0f);

            UUID []  textureIDs   = new UUID [4];
            float [] startHeights = new float [4];
            float [] heightRanges = new float [4];

            RegionSettings regionInfo = m_scene.RegionInfo.RegionSettings;

            textureIDs [0] = regionInfo.TerrainTexture1;
            textureIDs [1] = regionInfo.TerrainTexture2;
            textureIDs [2] = regionInfo.TerrainTexture3;
            textureIDs [3] = regionInfo.TerrainTexture4;

            startHeights [0] = (float)regionInfo.Elevation1SW;
            startHeights [1] = (float)regionInfo.Elevation1NW;
            startHeights [2] = (float)regionInfo.Elevation1SE;
            startHeights [3] = (float)regionInfo.Elevation1NE;

            heightRanges [0] = (float)regionInfo.Elevation2SW;
            heightRanges [1] = (float)regionInfo.Elevation2NW;
            heightRanges [2] = (float)regionInfo.Elevation2SE;
            heightRanges [3] = (float)regionInfo.Elevation2NE;

            uint globalX, globalY;

            Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out globalX, out globalY);

            Bitmap image = TerrainSplat.Splat(terrain, textureIDs, startHeights, heightRanges,
                                              new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain);
            warp_Texture  texture  = new warp_Texture(image);
            warp_Material material = new warp_Material(texture);

            material.setReflectivity(0);  // reduces tile seams a bit thanks lkalif
            renderer.Scene.addMaterial("TerrainColor", material);
            renderer.SetObjectMaterial("Terrain", "TerrainColor");

            image.Dispose();

            return(obj);
        }
Пример #23
0
    public void OnGUI()
    {
        scrollPos = EditorGUILayout.BeginScrollView(scrollPos, false, false);
        GUIContent[] mainMenu = new GUIContent[4];
        mainMenu[0] = new GUIContent("File");
        mainMenu[1] = new GUIContent("Prefabs");
        mainMenu[2] = new GUIContent("Layers");
        mainMenu[3] = new GUIContent("Advanced");

        EditorGUI.BeginChangeCheck();
        mainMenuOptions = GUILayout.Toolbar(mainMenuOptions, mainMenu, EditorStyles.toolbarButton);
        if (EditorGUI.EndChangeCheck() && mainMenuOptions == 2)
        {
            Functions.SetLandLayer((LandLayers)layerIndex);
        }

        #region Menu
        switch (mainMenuOptions)
        {
            #region File
        case 0:
            Functions.EditorIO();
            Functions.EditorInfo();
            Functions.MapInfo();
            Functions.EditorLinks();
            Functions.EditorSettings();
            break;

            #endregion
            #region Prefabs
        case 1:
            GUIContent[] prefabsOptionsMenu = new GUIContent[2];
            prefabsOptionsMenu[0] = new GUIContent("Asset Bundle");
            prefabsOptionsMenu[1] = new GUIContent("Prefab Tools");
            prefabOptions         = GUILayout.Toolbar(prefabOptions, prefabsOptionsMenu, EditorStyles.toolbarButton);

            switch (prefabOptions)
            {
            case 0:
                Functions.AssetBundle();
                break;

            case 1:
                Functions.PrefabTools(ref deletePrefabs, prefabSaveFile, mapPrefabSaveFile);
                break;
            }
            break;

            #endregion
            #region Layers
        case 2:
            GUIContent[] layersOptionsMenu = new GUIContent[4];
            layersOptionsMenu[0] = new GUIContent("Ground");
            layersOptionsMenu[1] = new GUIContent("Biome");
            layersOptionsMenu[2] = new GUIContent("Alpha");
            layersOptionsMenu[3] = new GUIContent("Topology");

            EditorGUI.BeginChangeCheck();
            layerIndex = GUILayout.Toolbar(layerIndex, layersOptionsMenu, EditorStyles.toolbarButton);
            if (EditorGUI.EndChangeCheck())
            {
                Functions.SetLandLayer((LandLayers)layerIndex, TerrainTopology.TypeToIndex((int)layers.Topologies));
            }

            switch (layerIndex)
            {
            case 0:
                Functions.TextureSelect((LandLayers)layerIndex, ref layers);
                Functions.AreaSelect();
                Functions.LayerTools((LandLayers)layerIndex, TerrainSplat.TypeToIndex((int)layers.Ground));
                Functions.RotateTools((LandLayers)layerIndex);
                Functions.RiverTools((LandLayers)layerIndex, TerrainSplat.TypeToIndex((int)layers.Ground), ref aboveTerrain);
                Functions.SlopeTools((LandLayers)layerIndex, TerrainSplat.TypeToIndex((int)layers.Ground), ref slopesInfo);
                Functions.HeightTools((LandLayers)layerIndex, TerrainSplat.TypeToIndex((int)layers.Ground), ref heightsInfo);
                break;

            case 1:
                Functions.TextureSelect((LandLayers)layerIndex, ref layers);
                Functions.AreaSelect();
                Functions.LayerTools((LandLayers)layerIndex, TerrainBiome.TypeToIndex((int)layers.Biome));
                Functions.RotateTools((LandLayers)layerIndex);
                Functions.RiverTools((LandLayers)layerIndex, TerrainBiome.TypeToIndex((int)layers.Biome), ref aboveTerrain);
                Functions.SlopeTools((LandLayers)layerIndex, TerrainBiome.TypeToIndex((int)layers.Biome), ref slopesInfo);
                Functions.HeightTools((LandLayers)layerIndex, TerrainBiome.TypeToIndex((int)layers.Biome), ref heightsInfo);
                break;

            case 2:
                Functions.LayerTools((LandLayers)layerIndex, 0, 1);
                Functions.AreaSelect();
                Functions.RotateTools((LandLayers)layerIndex);
                Functions.RiverTools((LandLayers)layerIndex, 0, ref aboveTerrain, 1);
                Functions.SlopeTools((LandLayers)layerIndex, 0, ref slopesInfo, 1);
                Functions.HeightTools((LandLayers)layerIndex, 0, ref heightsInfo, 1);
                break;

            case 3:
                Functions.TopologyLayerSelect(ref layers);
                Functions.AreaSelect();
                Functions.LayerTools((LandLayers)layerIndex, 0, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.RotateTools((LandLayers)layerIndex, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.TopologyTools();
                Functions.RiverTools((LandLayers)layerIndex, 0, ref aboveTerrain, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.SlopeTools((LandLayers)layerIndex, 0, ref slopesInfo, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));
                Functions.HeightTools((LandLayers)layerIndex, 0, ref heightsInfo, 1, TerrainTopology.TypeToIndex((int)layers.Topologies));
                break;
            }
            break;

            #endregion
            #region Advanced
        case 3:
            GUIContent[] advancedOptionsMenu = new GUIContent[2];
            advancedOptionsMenu[0] = new GUIContent("Generation");
            advancedOptionsMenu[1] = new GUIContent("Map Tools");

            EditorGUI.BeginChangeCheck();
            advancedOptions = GUILayout.Toolbar(advancedOptions, advancedOptionsMenu, EditorStyles.toolbarButton);
            if (EditorGUI.EndChangeCheck() && advancedOptions == 0)
            {
                MapManager.RefreshPresetsList();
            }

            switch (advancedOptions)
            {
                #region Generation
            case 0:
                Functions.NodePresets(presetScrollPos);
                break;

                #endregion
                #region Map Tools
            case 1:
                GUIContent[] mapToolsMenu = new GUIContent[3];
                mapToolsMenu[0] = new GUIContent("HeightMap");
                mapToolsMenu[1] = new GUIContent("Textures");
                mapToolsMenu[2] = new GUIContent("Misc");
                mapToolsOptions = GUILayout.Toolbar(mapToolsOptions, mapToolsMenu, EditorStyles.toolbarButton);

                switch (mapToolsOptions)
                {
                    #region HeightMap
                case 0:
                    GUIContent[] heightMapMenu = new GUIContent[2];
                    heightMapMenu[0] = new GUIContent("Heights");
                    heightMapMenu[1] = new GUIContent("Filters");
                    heightMapOptions = GUILayout.Toolbar(heightMapOptions, heightMapMenu, EditorStyles.toolbarButton);

                    switch (heightMapOptions)
                    {
                    case 0:
                        Elements.BoldLabel(ToolTips.heightsLabel);
                        Functions.OffsetMap(ref offset, ref clampOffset);
                        Functions.SetHeight(ref heightSet);
                        Functions.ClampHeight(ref heightLow, ref heightHigh);
                        Elements.BoldLabel(ToolTips.miscLabel);
                        Functions.InvertMap();
                        break;

                    case 1:
                        Functions.NormaliseMap(ref normaliseLow, ref normaliseHigh, ref autoUpdate);
                        Functions.SmoothMap(ref filterStrength, ref blurDirection, ref smoothPasses);
                        Functions.TerraceMap(ref terraceErodeFeatureSize, ref terraceErodeInteriorCornerWeight);
                        break;
                    }
                    break;

                    #endregion
                    #region Textures
                case 1:
                    Functions.ConditionalPaint(ref conditionalPaintOptions, ref texture, ref conditions, ref layers);
                    break;

                    #endregion
                    #region Misc
                case 2:
                    Functions.RotateMap(ref rotateSelection);
                    break;
                    #endregion
                }
                break;
                #endregion
            }
            break;
            #endregion
        }
        #endregion
        EditorGUILayout.EndScrollView();
    }
Пример #24
0
        private void CreateTerrain(WarpRenderer renderer, bool textureTerrain)
        {
            ITerrainChannel terrain = m_scene.RequestModuleInterface <ITerrainChannel>();

            warp_Object obj = new warp_Object(m_scene.RegionInfo.RegionSizeX * m_scene.RegionInfo.RegionSizeY, (m_scene.RegionInfo.RegionSizeX - 1) * (m_scene.RegionInfo.RegionSizeY - 1) * 2);

            for (int y = 0; y < m_scene.RegionInfo.RegionSizeY; y++)
            {
                for (int x = 0; x < m_scene.RegionInfo.RegionSizeX; x++)
                {
                    float height = terrain[x, y];

                    warp_Vector pos = ConvertVector(new Vector3(x, y, height));
                    obj.addVertex(new warp_Vertex(pos, (float)x / (m_scene.RegionInfo.RegionSizeX - 1), (float)((m_scene.RegionInfo.RegionSizeX - 1) - y) / (m_scene.RegionInfo.RegionSizeX - 1)));
                }
            }

            for (float y = 0; y < m_scene.RegionInfo.RegionSizeY; y += 1)
            {
                for (float x = 0; x < m_scene.RegionInfo.RegionSizeX; x += 1)
                {
                    if (x < m_scene.RegionInfo.RegionSizeX - 1 && y < m_scene.RegionInfo.RegionSizeY - 1)
                    {
                        float v = y * m_scene.RegionInfo.RegionSizeX + x;

                        // Normal
                        warp_Vector norm = new warp_Vector(x, y, terrain.GetNormalizedGroundHeight((int)x, (int)y));
                        norm = norm.reverse();
                        obj.vertex((int)v).n = norm;

                        // Triangle 1
                        obj.addTriangle(
                            (int)v,
                            (int)v + 1,
                            (int)v + m_scene.RegionInfo.RegionSizeX);

                        // Triangle 2
                        obj.addTriangle(
                            (int)v + m_scene.RegionInfo.RegionSizeX + 1,
                            (int)v + m_scene.RegionInfo.RegionSizeX,
                            (int)v + 1);
                    }
                }
            }

            renderer.Scene.addObject("Terrain", obj);

            UUID[]  textureIDs   = new UUID[4];
            float[] startHeights = new float[4];
            float[] heightRanges = new float[4];

            RegionSettings regionInfo = m_scene.RegionInfo.RegionSettings;

            textureIDs[0] = regionInfo.TerrainTexture1;
            textureIDs[1] = regionInfo.TerrainTexture2;
            textureIDs[2] = regionInfo.TerrainTexture3;
            textureIDs[3] = regionInfo.TerrainTexture4;

            startHeights[0] = (float)regionInfo.Elevation1SW;
            startHeights[1] = (float)regionInfo.Elevation1NW;
            startHeights[2] = (float)regionInfo.Elevation1SE;
            startHeights[3] = (float)regionInfo.Elevation1NE;

            heightRanges[0] = (float)regionInfo.Elevation2SW;
            heightRanges[1] = (float)regionInfo.Elevation2NW;
            heightRanges[2] = (float)regionInfo.Elevation2SE;
            heightRanges[3] = (float)regionInfo.Elevation2NE;

            uint globalX, globalY;

            Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out globalX, out globalY);

            Bitmap        image    = TerrainSplat.Splat(terrain, textureIDs, startHeights, heightRanges, new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain);
            warp_Texture  texture  = new warp_Texture(image);
            warp_Material material = new warp_Material(texture);

            material.setReflectivity(50);
            renderer.Scene.addMaterial("TerrainColor", material);
            renderer.SetObjectMaterial("Terrain", "TerrainColor");
        }
Пример #25
0
        private warp_Object CreateTerrain(WarpRenderer renderer, bool textureTerrain)
        {
            ITerrainChannel terrain = m_scene.RequestModuleInterface <ITerrainChannel>();

            float       diff = (float)m_scene.RegionInfo.RegionSizeY / (float)Constants.RegionSize;
            warp_Object obj  =
                new warp_Object(Constants.RegionSize * Constants.RegionSize,
                                ((Constants.RegionSize - 1) * (Constants.RegionSize - 1) * 2));

            for (float y = 0; y < m_scene.RegionInfo.RegionSizeY; y += diff)
            {
                for (float x = 0; x < m_scene.RegionInfo.RegionSizeX; x += diff)
                {
                    warp_Vector pos = ConvertVector(x, y, terrain[(int)x, (int)y]);
                    obj.addVertex(new warp_Vertex(pos, x / (float)(m_scene.RegionInfo.RegionSizeX),
                                                  (((float)m_scene.RegionInfo.RegionSizeX) - y) /
                                                  (m_scene.RegionInfo.RegionSizeX)));
                }
            }

            for (float y = 0; y < m_scene.RegionInfo.RegionSizeY; y += diff)
            {
                for (float x = 0; x < m_scene.RegionInfo.RegionSizeX; x += diff)
                {
                    float newX = x / diff;
                    float newY = y / diff;
                    if (newX < Constants.RegionSize - 1 && newY < Constants.RegionSize - 1)
                    {
                        int v = (int)(newY * Constants.RegionSize + newX);

                        // Normal
                        Vector3 v1 = new Vector3(newX, newY, (terrain[(int)x, (int)y]) / Constants.TerrainCompression);
                        Vector3 v2 = new Vector3(newX + 1, newY,
                                                 (terrain[(int)x + 1, (int)y]) / Constants.TerrainCompression);
                        Vector3 v3 = new Vector3(newX, newY + 1,
                                                 (terrain[(int)x, (int)(y + 1)]) / Constants.TerrainCompression);
                        warp_Vector norm = ConvertVector(SurfaceNormal(v1, v2, v3));
                        norm            = norm.reverse();
                        obj.vertex(v).n = norm;

                        // Triangle 1
                        obj.addTriangle(
                            v,
                            v + 1,
                            v + Constants.RegionSize);

                        // Triangle 2
                        obj.addTriangle(
                            v + Constants.RegionSize + 1,
                            v + Constants.RegionSize,
                            v + 1);
                    }
                }
            }

            renderer.Scene.addObject("Terrain", obj);

            UUID[]  textureIDs   = new UUID[4];
            float[] startHeights = new float[4];
            float[] heightRanges = new float[4];

            RegionSettings regionInfo = m_scene.RegionInfo.RegionSettings;

            textureIDs[0] = regionInfo.TerrainTexture1;
            textureIDs[1] = regionInfo.TerrainTexture2;
            textureIDs[2] = regionInfo.TerrainTexture3;
            textureIDs[3] = regionInfo.TerrainTexture4;

            startHeights[0] = (float)regionInfo.Elevation1SW;
            startHeights[1] = (float)regionInfo.Elevation1NW;
            startHeights[2] = (float)regionInfo.Elevation1SE;
            startHeights[3] = (float)regionInfo.Elevation1NE;

            heightRanges[0] = (float)regionInfo.Elevation2SW;
            heightRanges[1] = (float)regionInfo.Elevation2NW;
            heightRanges[2] = (float)regionInfo.Elevation2SE;
            heightRanges[3] = (float)regionInfo.Elevation2NE;

            uint globalX, globalY;

            Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out globalX, out globalY);

            Bitmap image = TerrainSplat.Splat(terrain, textureIDs, startHeights, heightRanges,
                                              new Vector3d(globalX, globalY, 0.0), m_scene.AssetService, textureTerrain);
            warp_Texture  texture  = new warp_Texture(image);
            warp_Material material = new warp_Material(texture);

            material.setReflectivity(0); // reduces tile seams a bit thanks lkalif
            renderer.Scene.addMaterial("TerrainColor", material);
            renderer.SetObjectMaterial("Terrain", "TerrainColor");
            return(obj);
        }
Пример #26
0
 public int GetSplatMaxType(int x, int z, int mask = -1)
 {
     return(TerrainSplat.IndexToType(this.GetSplatMaxIndex(x, z, mask)));
 }
Пример #27
0
 public int GetSplatMaxType(float normX, float normZ, int mask = -1)
 {
     return(TerrainSplat.IndexToType(this.GetSplatMaxIndex(normX, normZ, mask)));
 }
Пример #28
0
 public int GetSplatMaxType(Vector3 worldPos, int mask = -1)
 {
     return(TerrainSplat.IndexToType(this.GetSplatMaxIndex(worldPos, mask)));
 }
Пример #29
0
        public static void ConditionalPaintConditions(ref Conditions cnds, ref int cndsOptions)
        {
            Elements.BoldLabel(ToolTips.conditionalPaintLabel);

            GUIContent[] conditionalPaintMenu = new GUIContent[5];
            conditionalPaintMenu[0] = new GUIContent("Ground");
            conditionalPaintMenu[1] = new GUIContent("Biome");
            conditionalPaintMenu[2] = new GUIContent("Alpha");
            conditionalPaintMenu[3] = new GUIContent("Topology");
            conditionalPaintMenu[4] = new GUIContent("Terrain");
            cndsOptions             = GUILayout.Toolbar(cndsOptions, conditionalPaintMenu, EditorStyles.toolbarButton);

            Elements.MiniBoldLabel(ToolTips.conditionsLabel);

            switch (cndsOptions)
            {
            case 0:     // Ground
                Elements.BeginToolbarHorizontal();
                cnds.GroundConditions.CheckLayer[TerrainSplat.TypeToIndex((int)cnds.GroundConditions.Layer)] = Elements.ToolbarToggle(ToolTips.checkTexture, cnds.GroundConditions.CheckLayer[TerrainSplat.TypeToIndex((int)cnds.GroundConditions.Layer)]);
                cnds.GroundConditions.Layer = (TerrainSplat.Enum)Elements.ToolbarEnumPopup(cnds.GroundConditions.Layer);
                Elements.EndToolbarHorizontal();

                Elements.BeginToolbarHorizontal();
                cnds.GroundConditions.Weight[TerrainSplat.TypeToIndex((int)cnds.GroundConditions.Layer)] = Elements.ToolbarSlider(ToolTips.conditionalTextureWeight, cnds.GroundConditions.Weight[TerrainSplat.TypeToIndex((int)cnds.GroundConditions.Layer)], 0.01f, 1f);
                Elements.EndToolbarHorizontal();
                break;

            case 1:     // Biome
                Elements.BeginToolbarHorizontal();
                cnds.BiomeConditions.CheckLayer[TerrainBiome.TypeToIndex((int)cnds.BiomeConditions.Layer)] = Elements.ToolbarToggle(ToolTips.checkTexture, cnds.BiomeConditions.CheckLayer[TerrainBiome.TypeToIndex((int)cnds.BiomeConditions.Layer)]);
                cnds.BiomeConditions.Layer = (TerrainBiome.Enum)Elements.ToolbarEnumPopup(cnds.BiomeConditions.Layer);
                Elements.EndToolbarHorizontal();

                Elements.BeginToolbarHorizontal();
                cnds.BiomeConditions.Weight[TerrainBiome.TypeToIndex((int)cnds.BiomeConditions.Layer)] = Elements.ToolbarSlider(ToolTips.conditionalTextureWeight, cnds.BiomeConditions.Weight[TerrainBiome.TypeToIndex((int)cnds.BiomeConditions.Layer)], 0.01f, 1f);
                Elements.EndToolbarHorizontal();
                break;

            case 2:     // Alpha
                Elements.BeginToolbarHorizontal();
                cnds.AlphaConditions.CheckAlpha = Elements.ToolbarToggle(ToolTips.checkTexture, cnds.AlphaConditions.CheckAlpha);
                cnds.AlphaConditions.Texture    = (AlphaTextures)Elements.ToolbarEnumPopup(cnds.AlphaConditions.Texture);
                Elements.EndToolbarHorizontal();
                break;

            case 3:     // Topology
                Elements.BeginToolbarHorizontal();
                cnds.TopologyConditions.CheckLayer[TerrainTopology.TypeToIndex((int)cnds.TopologyConditions.Layer)] = Elements.ToolbarToggle(ToolTips.checkTopologyLayer, cnds.TopologyConditions.CheckLayer[TerrainTopology.TypeToIndex((int)cnds.TopologyConditions.Layer)]);
                cnds.TopologyConditions.Layer = (TerrainTopology.Enum)Elements.ToolbarEnumPopup(cnds.TopologyConditions.Layer);
                Elements.EndToolbarHorizontal();

                Elements.BeginToolbarHorizontal();
                Elements.ToolbarLabel(ToolTips.checkTexture);
                cnds.TopologyConditions.Texture[TerrainTopology.TypeToIndex((int)cnds.TopologyConditions.Layer)] = (TopologyTextures)Elements.ToolbarEnumPopup(cnds.TopologyConditions.Texture[TerrainTopology.TypeToIndex((int)cnds.TopologyConditions.Layer)]);
                Elements.EndToolbarHorizontal();
                break;

            case 4:     // Terrain
                float tempSlopeLow = cnds.TerrainConditions.Slopes.SlopeLow, tempSlopeHigh = cnds.TerrainConditions.Slopes.SlopeHigh;
                cnds.TerrainConditions.CheckSlopes     = Elements.ToolbarToggleMinMax(ToolTips.checkSlopes, ToolTips.rangeLow, ToolTips.rangeHigh, cnds.TerrainConditions.CheckSlopes, ref tempSlopeLow, ref tempSlopeHigh, 0f, 90f);
                cnds.TerrainConditions.Slopes.SlopeLow = tempSlopeLow; cnds.TerrainConditions.Slopes.SlopeHigh = tempSlopeHigh;

                float tempHeightLow = cnds.TerrainConditions.Heights.HeightLow, tempHeightHigh = cnds.TerrainConditions.Heights.HeightHigh;
                cnds.TerrainConditions.CheckHeights      = Elements.ToolbarToggleMinMax(ToolTips.checkHeights, ToolTips.rangeLow, ToolTips.rangeHigh, cnds.TerrainConditions.CheckHeights, ref tempHeightLow, ref tempHeightHigh, 0f, 1000f);
                cnds.TerrainConditions.Heights.HeightLow = tempHeightLow; cnds.TerrainConditions.Heights.HeightHigh = tempHeightHigh;
                break;
            }
        }
Пример #30
0
 public SplatMask(IConverter <Vector2Int, Vector3> coordinateConverter, int splatIndex)
 {
     _coordinateConverter = coordinateConverter;
     _splatType           = TerrainSplat.IndexToType(splatIndex);
 }