Inheritance: MonoBehaviour
Esempio n. 1
0
 // Use this for initialization
 void Start()
 {
     terrain = terrainObj.GetComponent<TextureGenerator> ();
     mainCamera = this.GetComponent<Camera> ();
     isActive = true;
     screenMargin = (int)(Screen.width * marginRate);
 }
Esempio n. 2
0
 void Awake()
 {
     textureGenerator = GetComponent<TextureGenerator>();
     if (textureGenerator != null)
     {
         texture = textureGenerator.GenerateTexture();
     }
 }
Esempio n. 3
0
    void Start()
    {
        terrain = this.gameObject.GetComponent<TextureGenerator> ();

        ///******** Testing For Sprite Displays ********
        Faction f = new Faction();
        f.initialize("A Faction", Color.black);

        Reader r = new Reader();
        Troop t = this.gameObject.AddComponent<Troop>();
        TroopType tt = Reader.getTroopType("cavalry_heavy");
        tt.faction = f;
        t.initialize(tt, 500);

        GameObject troopObj = TroopOnField.instantiate(t, new Vector2(0, 0), this.gameObject);
        //TroopOnField.instantiate(t, new Vector2(1, 0), this.gameObject);
        //TroopOnField.instantiate(t, new Vector2(1, 1), this.gameObject);
        troopObj.GetComponent<TroopOnField>().troop_stat.status = TroopStats.TroopStatus.Rout;
    }
Esempio n. 4
0
    protected virtual void Generate()
    {
        GetData();
        LoadTiles();

        UpdateNeighbours();

        GenerateRivers();
        BuildRiverGroups();
        DigRiverGroups();
        AdjustMoistureMap();

        UpdateBitmasks();
        FloodFill();

        GenerateBiomeMap();
        UpdateBiomeBitmasks();

        heightMapRenderer.materials [0].mainTexture   = TextureGenerator.GenerateHeightMapTexture(width, height, tiles);
        heatMapRenderer.materials [0].mainTexture     = TextureGenerator.GenerateHeatMapTexture(width, height, tiles);
        moistureMapRenderer.materials [0].mainTexture = TextureGenerator.GenerateMoistureMapTexture(width, height, tiles);
        biomeMapRenderer.materials [0].mainTexture    = TextureGenerator.GenerateBiomeMapTexture(width, height, tiles, coldestValue, colderValue, coldValue);
    }
Esempio n. 5
0
    public void GenerateMap()
    {
        float[,] noiseMap = Noise.GenerateNoiseMap(width, height, seed, noiseScale, octaves, persistance, lacunarity, offset);

        colourMap = new Color[width * height];
        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                float currentHeight = noiseMap [x, y];
                //now finf whihc region this current height falls within
                for (int i = 0; i < regions.Length; i++)
                {
                    if (currentHeight <= regions [i].height)
                    {
                        colourMap [y * width + x] = regions [i].colour;
                        break;
                    }
                }
            }
        }
        DrawTexture(TextureGenerator.TextureFromColourMap(colourMap, width, height));
    }
Esempio n. 6
0
        public override void Draw(UISpriteBatch batch)
        {
            if (!Visible || Thumb == null)
            {
                return;
            }
            var ThumbImg = Thumb.LotTexture;

            if (ThumbImg != null && BgImg != null && HoverImg != null)
            {
                UITerrainHighlight.DrawArrow(batch,
                                             ((CoreGameScreen)GameFacade.Screens.CurrentUIScreen).CityRenderer,
                                             (Position + new Vector2(40, 25)) * FSOEnvironment.DPIScaleFactor, (int)LotId);
                DrawLocalTexture(batch, (m_isOver && !m_isDown) ? HoverImg : BgImg, new Vector2());

                var scale = new Vector2(0.25f, 0.25f);
                DrawLocalTexture(batch, ThumbImg, null, new Vector2(40, 25) - new Vector2(32, 32), scale);
                var px = TextureGenerator.GetPxWhite(batch.GraphicsDevice);
                DrawLocalTexture(batch, px, null, new Vector2(0, 50), new Vector2(80, 16 * NameLabel.NumLines + 7), Color.Black * 0.6f);

                base.Draw(batch);
            }
        }
    public void DrawMapInEditor()
    {
        MapData    mapData    = GenerateMapData(Vector2.zero);
        MapDisplay mapDisplay = FindObjectOfType <MapDisplay> ();

        if (drawMode == DrawMode.NoiseMap)
        {
            mapDisplay.drawTexture(TextureGenerator.textureFromHeightMap(mapData.heightMap));
        }
        else if (drawMode == DrawMode.ColorMap)
        {
            mapDisplay.drawTexture(TextureGenerator.textureFromColorMap(mapData.colorMap, MAP_CHUNK_SIZE, MAP_CHUNK_SIZE));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            mapDisplay.DrawMesh(MeshGenerator.GeneratTerrainMesh(mapData.heightMap, meshHeightMultipier, meshHeightCurve, editorPreviewLOD),
                                TextureGenerator.textureFromColorMap(mapData.colorMap, MAP_CHUNK_SIZE, MAP_CHUNK_SIZE));
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            mapDisplay.drawTexture(TextureGenerator.textureFromHeightMap(FalloffGenerator.GenerateFalloffMap(MAP_CHUNK_SIZE)));
        }
    }
Esempio n. 8
0
    public void DrawMapEditor()
    {
        //value might not be correct if we apply the falloffmap because it might falten down the highest point
        textureData.UpdateMeshHeight(terrainMaterial, terrainData.minHeight, terrainData.maxHeight);

        MapData    mapData    = generateMapData(Vector2.zero);
        MapDisplay mapDisplay = FindObjectOfType <MapDisplay>();

        if (drawMode == DrawMode.noiseMap)
        {
            Texture2D texture = TextureGenerator.textureHeightMap(mapData.heightMap);
            mapDisplay.drawTexture(texture);
        }
        else if (drawMode == DrawMode.Mesh)
        {
            mapDisplay.drawMesh(MeshGenerator.generateTerrainMesh(mapData.heightMap, terrainData.meshHeight, terrainData.meshHeightCurve, previewLevelOfDetail));
        }
        else if (drawMode == DrawMode.FallOffMap)
        {
            Texture2D texture = TextureGenerator.textureHeightMap(fallOffMap);
            mapDisplay.drawTexture(texture);
        }
    }
    public void DrawMapInEditor()
    {
        textureData.ApplyToMaterial(terrainMaterial);
        textureData.UpdateMeshHeights(terrainMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);
        HeightMap heightMap = HeightMapGenerator.GenerateHeightMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, heightMapSettings, Vector2.zero);

        if (drawMode == DrawMode.NoiseMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            MeshData meshData = MeshGenerator.GenerateTerrainMesh(heightMap.values, meshSettings, editorPreviewLOD);
            DrawMesh(meshData);

            ObjectsGenerator.GeneratePointsRandom(objectData.objectList, meshData.CreateMesh(), meshSettings, heightMapSettings.noiseSettings.seed);
            ObjectsGenerator.SpawnObjects(objectData, transform, meshSettings, heightMapSettings.noiseSettings.seed);
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(new HeightMap(FalloffGenerator.GenerateFalloffMap(meshSettings.numVertsPerLine), 0, 1)));
        }
    }
Esempio n. 10
0
        public void PrepareLighting()
        {
            var adv = (Light?.LightMap) ?? TextureGenerator.GetDefaultAdv(Device);
            var amb = AmbientLight ?? TextureGenerator.GetPxWhite(Device);

            WorldContent._2DWorldBatchEffect.Parameters["advancedLight"].SetValue(adv);
            WorldContent.GrassEffect.Parameters["advancedLight"].SetValue(adv);
            WorldContent._2DWorldBatchEffect.Parameters["ambientLight"].SetValue(amb);
            Avatar.Effect.Parameters["advancedLight"].SetValue(adv);

            var frontDir    = WorldCamera.FrontDirection();
            var lightOffset = new Vector2(frontDir.X / (6 * 75), frontDir.Z / (6 * 75));

            if (Light != null)
            {
                lightOffset *= Light.InvMapLayout;
            }
            WorldContent._2DWorldBatchEffect.Parameters["LightOffset"].SetValue(lightOffset);
            WorldContent.GrassEffect.Parameters["LightOffset"].SetValue(lightOffset);
            Avatar.Effect.Parameters["LightOffset"].SetValue(lightOffset);

            WorldContent._2DWorldBatchEffect.Parameters["MaxFloor"].SetValue((float)Level - 1);
        }
Esempio n. 11
0
    public void DrawMapInEditor()
    {
        MapData mapData = GenerateMapData(Vector2.zero);

        // Reference to the MapDisplay object
        MapDisplay display = FindObjectOfType <MapDisplay> ();

        if (drawMode == DrawMode.NoiseMap)
        {
            // Draw the noise map on the MapDisplay object
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(mapData.heightMap));
        }
        else if (drawMode == DrawMode.ColorMap)
        {
            // Draw the color map on the MapDisplay object
            display.DrawTexture(TextureGenerator.TextureFromColorMap(mapData.colorMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            // Draw the mesh
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(mapData.heightMap, meshHeightMultiplier, meshHeightCurve, editorPreviewLOD, useFlatShading), TextureGenerator.TextureFromColorMap(mapData.colorMap, mapChunkSize, mapChunkSize));
        }
    }
    public void DrawMapInEditor()
    {
        MapData mapData = GenerateMapData(Vector2.zero);

        DisplayMap display = FindObjectOfType <DisplayMap>();

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(mapData.heightMap));
        }
        else if (drawMode == DrawMode.ColorMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromColourMap(mapData.colorMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(mapData.heightMap, meshHeightMultiplier, meshHeightCurve, editorPreviewLOD, useFlatShading), TextureGenerator.TextureFromColourMap(mapData.colorMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(IslandGenerator.GenerateIslandEffect(mapChunkSize)));
        }
    }
Esempio n. 13
0
        public override void Initialize(_3DLayer layer)
        {
            /**
             * Setup world state, this object acts as a facade
             * to world objects as well as providing various
             * state settings for the world and helper functions
             */
            State = new WorldState(layer.Device, layer.Device.Viewport.Width / FSOEnvironment.DPIScaleFactor, layer.Device.Viewport.Height / FSOEnvironment.DPIScaleFactor, this);
            State.AmbientLight = new Texture2D(layer.Device, 256, 256);
            State._3D          = new FSO.LotView.Utils._3DWorldBatch(State);
            State._2D          = new FSO.LotView.Utils._2DWorldBatch(layer.Device, 2, new SurfaceFormat[] {
                World2D.BUFFER_SURFACE_FORMATS[0],
                World2D.BUFFER_SURFACE_FORMATS[World2D.BUFFER_THUMB_DEPTH]
            }, new bool[] { true, false }, World2D.SCROLL_BUFFER);
            State._2D.AdvLight = TextureGenerator.GetDefaultAdv(layer.Device);
            State.DrawOOB      = true;
            UseBackbuffer      = false;

            base.Camera = State.Camera;

            HasInitGPU = true;
            HasInit    = HasInitGPU & HasInitBlueprint;
        }
Esempio n. 14
0
        public override void Draw(UISpriteBatch batch)
        {
            //simple overide that always draws lots that are community regardless of their online status
            //Visible=cityview (don't draw in lotview), Lot_IsOnline= lotthread is open(blinking red on map), CLots= list with specific overrides based on db location
            if (!Visible || Thumb == null || (!Target.Value.Lot_IsOnline && !WorldObjectCatalog.CLots.Contains(Convert.ToString(LotId))))
            {
                return;
            }
            var ThumbImg = Thumb.LotTexture;

            if (ThumbImg != null && BgImg != null && HoverImg != null)
            {
                UITerrainHighlight.DrawArrow(batch, ((CoreGameScreen)GameFacade.Screens.CurrentUIScreen).CityRenderer, Position + new Vector2(40, 25), (int)LotId);
                DrawLocalTexture(batch, (m_isOver && !m_isDown) ? HoverImg : BgImg, new Vector2());

                var scale = new Vector2(0.25f, 0.25f);
                DrawLocalTexture(batch, ThumbImg, null, new Vector2(40, 25) - new Vector2(32, 32), scale);
                var px = TextureGenerator.GetPxWhite(batch.GraphicsDevice);
                DrawLocalTexture(batch, px, null, new Vector2(0, 50), new Vector2(80, 16 * NameLabel.NumLines + 7), Color.Black * 0.6f);

                base.Draw(batch);
            }
        }
Esempio n. 15
0
    public void DrawMapInEditor()
    {
        textureData.ApplyToMaterial(terrainMaterial);
        textureData.UpdateMeshHeights(terrainMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);
        HeightMap heightMap = HeightMapGenerator.GenerateHeightMap(meshSettings.numVerticesPerLine,
                                                                   meshSettings.numVerticesPerLine, heightMapSettings, Vector2.zero);
        MapPreview display = FindObjectOfType <MapPreview>();

        if (drawMode == DrawMode.NoiseMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            DrawMesh(
                MeshGenerator.GenerateTerrainMesh(heightMap.values, meshSettings, editorPreviewLod));
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(
                            new HeightMap(FalloffGenerator.GenerateFalloffMap(meshSettings.numVerticesPerLine), 0, 1)));
        }
    }
Esempio n. 16
0
    public void DrawMapInEditor()
    {
        MapData mapData = GenerateMapData(Vector2.zero);

        MapDisplay display = FindObjectOfType <MapDisplay>();

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(mapData.heightMap));
        }
        else if (drawMode == DrawMode.ColourMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromColourMap(mapData.colourMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(NoiseMeshGenerator.GenerateTerrainMesh(mapData.heightMap, meshHeightMultiplier, meshHeightCurve, editorPreviewLOD), TextureGenerator.TextureFromColourMap(mapData.colourMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(FalloffGenerator.GenerateFalloffMap(mapChunkSize)));
        }
    }
Esempio n. 17
0
    public void GenerateMap()
    {
        float[,] noiseMap = Noise.GenerateNoiseMap(mapChunkSize, mapChunkSize, seed, noiseScale, octaves, persistance, lacunarity, offset);

        Color[] colorMap = new Color[mapChunkSize * mapChunkSize];
        for (int y = 0; y < mapChunkSize; y++)
        {
            for (int x = 0; x < mapChunkSize; x++)
            {
                float currentHeight = noiseMap[x, y];

                for (int i = 0; i < regions.Length; i++)
                {
                    if (currentHeight <= regions[i].height)
                    {
                        colorMap[y * mapChunkSize + x] = regions[i].color;
                        break;
                    }
                }
            }
        }

        MapDisplay display = FindObjectOfType <MapDisplay>();

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(noiseMap));
        }
        else if (drawMode == DrawMode.ColorMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromColorMap(colorMap, mapChunkSize, mapChunkSize));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(noiseMap, meshHeightMultiplier, meshHeightCurve, levelOfDetail), TextureGenerator.TextureFromColorMap(colorMap, mapChunkSize, mapChunkSize));
        }
    }
Esempio n. 18
0
        public UIFamiliesCASPanel()
        {
            var gd = GameFacade.GraphicsDevice;
            var ui = Content.Get().CustomUI;
            var sh = UIScreen.Current.ScreenHeight;
            var sw = UIScreen.Current.ScreenWidth;

            FamilyList = new UITouchScroll(FamilyLength, FamilyProvider);
            FamilyList.VerticalMode = true;
            FamilyList.Size         = new Vector2(810, sh);
            FamilyList.X            = (sw - 810) / 2;
            FamilyList.ItemWidth    = 180;
            FamilyList.Margin       = 90;
            FamilyList.DrawBounds   = false;
            Add(FamilyList);
            WhitePx = TextureGenerator.GetPxWhite(GameFacade.GraphicsDevice);

            Title = new UILabel();
            Title.NewStyle(UIStyle.Current.Text, 37);
            Title.Caption   = "Select a Family";
            Title.Size      = new Vector2(sw, 60);
            Title.Alignment = TextAlignment.Middle | TextAlignment.Center;
            Title.Y         = -85;
            Add(Title);

            DeleteButton          = new UITwoStateButton(ui.Get("btn_deletefam.png").Get(gd));
            DeleteButton.Position = new Vector2(sw - 140, sh - 260);
            Add(DeleteButton);

            NewButton          = new UITwoStateButton(ui.Get("btn_createfam.png").Get(gd));
            NewButton.Position = new Vector2(sw - 140, sh - 380);
            Add(NewButton);
            NewButton.OnButtonClick += (btn) => OnNewFamily?.Invoke();

            TitleI = TitleI;
            SetSelection(-1);
        }
    public override void OnInspectorGUI()
    {
        GUIStyle styleFold = EditorStyles.foldout;

        styleFold.fontStyle = FontStyle.Bold;
        styleFold.fontSize  = 14;

        serializedObject.Update();
        statusNoise = EditorGUILayout.Foldout(statusNoise, "Noise", styleFold);
        if (statusNoise)
        {
            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.PropertyField(plantOct);
            EditorGUILayout.PropertyField(plantFre);
            if (GUILayout.Button("Generate"))
            {
                noiseTex = TextureGenerator.GetNoiseTex(sizeTex, sizeTex, grass.floatValue, plantOct.intValue, plantFre.floatValue);
            }
            GUILayout.Label(noiseTex);
            EditorGUILayout.EndVertical();
        }

        statusPlants = EditorGUILayout.Foldout(statusPlants, "Plant Map", styleFold);
        if (statusPlants)
        {
            EditorGUILayout.BeginVertical("Box");
            EditorGUILayout.PropertyField(grass);
            EditorGUILayout.PropertyField(serializedObject.FindProperty("savanna"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("swamp"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("desert"));
            EditorGUILayout.PropertyField(serializedObject.FindProperty("cold"));
            EditorGUILayout.EndVertical();
        }
        EditorGUILayout.PropertyField(serializedObject.FindProperty("textures"), true);
        EditorGUILayout.PropertyField(serializedObject.FindProperty("prefChunk"));
        serializedObject.ApplyModifiedProperties();
    }
Esempio n. 20
0
    public void GenerateMap()
    {
        float[,] noiseMap = Noise.GenerateNoiseMap(MapWidth, MapHeight, Seed, NoiseScale,
                                                   OctavesNumber, Persistance, Lacunarity,
                                                   Offset);

        //Store the colors in respect of the Map height
        Color[] colorMap = new Color[MapWidth * MapHeight];

        //
        for (int y = 0; y < MapHeight; y++)
        {
            for (int x = 0; x < MapWidth; x++)
            {
                float currentHeight = noiseMap[x, y];
                for (int i = 0; i < Regions.Length; i++)
                {
                    if (currentHeight <= Regions[i].Height)
                    {
                        colorMap [y * MapWidth + x] = Regions [i].TerrainColor;
                        break;                        //no need to
                    }
                }
            }
        }

        MapDisplayBehaviour display = FindObjectOfType <MapDisplayBehaviour> ();

        if (Mode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(noiseMap));
        }
        if (Mode == DrawMode.ColorMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromColorMap(colorMap, MapWidth, MapHeight));
        }
    }
    public void GenerateMap()
    {
        float[,] noiseMap = Noise.GenerateNoiseMap(mapWidth, mapHeight, seed, noiseScale, octaves, persistance, lacunarity, offset);

        Color[] colorMap = new Color[mapHeight * mapWidth];
        for (var y = 0; y < mapHeight; y++)
        {
            for (var x = 0; x < mapWidth; x++)
            {
                float currentHeight = noiseMap[x, y];

                for (var i = 0; i < regions.Length; i++)
                {
                    if (currentHeight <= regions[i].height)
                    {
                        colorMap[y * mapWidth + x] = regions[i].color;
                        break;
                    }
                }
            }
        }

        MapDisplay display = FindObjectOfType <MapDisplay>();

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(noiseMap));
        }
        else if (drawMode == DrawMode.ColorMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromColourMap(colorMap, mapWidth, mapHeight));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(noiseMap), TextureGenerator.TextureFromColourMap(colorMap, mapWidth, mapHeight));
        }
    }
Esempio n. 22
0
    public void GenerateMap()
    {
        float[,] noiseMap = Noise.GenerateNoiseMap(mapWidth, mapHeight, noiseScale, seed, octaves, persistance, lacunarity, offset);
        Color[] colorMap = new Color[mapWidth * mapHeight];

        for (int y = 0; y < mapHeight; y++)
        {
            for (int x = 0; x < mapWidth; x++)
            {
                float currentHeight = noiseMap[x, y];

                for (int i = 0; i < regions.Length; i++)
                {
                    if (currentHeight <= regions[i].height)
                    {
                        colorMap[y * mapWidth + x] = regions[i].TerrainColor;
                        break;
                    }
                }
            }
        }

        MapDisplay display = GetComponent <MapDisplay>();

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(noiseMap));
        }
        else if (drawMode == DrawMode.ColorMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromColorMap(colorMap, mapWidth, mapHeight));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(noiseMap, heightMultiplier, heightCurve), TextureGenerator.TextureFromColorMap(colorMap, mapWidth, mapHeight));
        }
    }
    public void GenerateMap()
    {
        float[,]  noiseMap = Noise.generateNoiseMap(MAP_CHUNK_SIZE, MAP_CHUNK_SIZE, seed, noiseScale, octaves, persistance, lacunarity, offSet);

        Color[] colourMap = new Color[MAP_CHUNK_SIZE * MAP_CHUNK_SIZE];
        for (int y = 0; y < MAP_CHUNK_SIZE; y++)
        {
            for (int x = 0; x < MAP_CHUNK_SIZE; x++)
            {
                float currentHeight = noiseMap[x, y];
                for (int i = 0; i < regions.Length; i++)
                {
                    if (currentHeight <= regions[i].height)
                    {
                        colourMap[y * MAP_CHUNK_SIZE + x] = regions[i].colour;
                        break;
                    }
                }
            }
        }
        MapDisplay display = FindObjectOfType <MapDisplay>();

        if (drawMode == DrawMode.NoiseMap)
        {
            texture2d = TextureGenerator.TextureFromHeightMap(noiseMap);
            display.DrawTexture(texture2d);
        }
        else if (drawMode == DrawMode.ColourMap)
        {
            texture2d = TextureGenerator.TextureFromColourMap(colourMap, MAP_CHUNK_SIZE, MAP_CHUNK_SIZE);
            display.DrawTexture(texture2d);
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGenerator.GenerateTerrainMwsh(noiseMap, meshHeightMultiplier, meshHeightCurve, levelOfDetail), TextureGenerator.TextureFromColourMap(colourMap, MAP_CHUNK_SIZE, MAP_CHUNK_SIZE));
        }
    }
Esempio n. 24
0
    public void drawMapInEditor()
    {
        MapData map = generateMapData(Vector2.zero, false);

        MapDisplay display = FindObjectOfType <MapDisplay> ();

        switch (drawMode)
        {
        case DrawMode.NoiseMap:
            display.drawMap(TextureGenerator.generateNoiseTexture(map.heightMap));
            break;

        case DrawMode.Mesh:
            display.drawMesh(MeshGenerator.generateTerrainMesh(map.heightMap, terrainSettings.meshHeightMultiplier, terrainSettings.meshHeightCurve, editorPreviewLOD));
            break;

        case DrawMode.NoiseMesh:
            display.drawTextureMesh(MeshGenerator.generateTerrainMesh(map.heightMap, terrainSettings.meshHeightMultiplier, terrainSettings.meshHeightCurve, editorPreviewLOD), TextureGenerator.generateNoiseTexture(map.heightMap));
            break;

        default:
            break;
        }
    }
Esempio n. 25
0
    public void GenerateMap()
    {
        float[,] NoiseMap = Noise.GenerateNoiseMap(MapChunkSize, MapChunkSize, Seed, NoiseScale, Octaves, Persistance, Lacunarity, Offset);

        Color[] ColourMap = new Color[MapChunkSize * MapChunkSize];
        for (int y = 0; y < MapChunkSize; y++)
        {
            for (int x = 0; x < MapChunkSize; x++)
            {
                float CurrentHeight = NoiseMap[x, y];
                for (int i = 0; i < Regions.Length; i++)
                {
                    if (CurrentHeight <= Regions[i].Height)
                    {
                        ColourMap[y * MapChunkSize + x] = Regions[i].Colour;
                        break;
                    }
                }
            }
        }

        MapDisplay Display = FindObjectOfType <MapDisplay>();

        if (drawMode == DrawnMode.NoiseMap)
        {
            Display.DrawTexture(TextureGenerator.TextureFromHeightMap(NoiseMap));
        }
        else if (drawMode == DrawnMode.ColourMap)
        {
            Display.DrawTexture(TextureGenerator.TextureFromColourMap(ColourMap, MapChunkSize, MapChunkSize));
        }
        else if (drawMode == DrawnMode.Mesh)
        {
            Display.DrawMesh(MeshGenerator.GenerateTerrainMesh(NoiseMap, MeshHeightMultiplier, MeshHeightCurve, LevelOfDetail), TextureGenerator.TextureFromColourMap(ColourMap, MapChunkSize, MapChunkSize));
        }
    }
Esempio n. 26
0
    // Main thread
    public void DrawMapInEditor()
    {
        // Update textureData
        textureData.ApplyToMaterial(terrainMaterial);
        textureData.UpdateMeshHeights(terrainMaterial, terrainData.minHeight, terrainData.maxHeight);

        MapData mapData = GenerateMapData(Vector2.zero);

        // Draw texture to the display
        MapDisplay display = FindObjectOfType <MapDisplay>();

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(mapData.heightMap));
        }
        else if (drawMode == DrawMode.MeshMap)
        {
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(mapData.heightMap, terrainData.meshHeightMultiplier, terrainData.meshHeightCurve, editorPreviewLOD, terrainData.useFlatShading));
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(FalloffGenerator.GenerateFalloffMap(mapChunkSize)));
        }
    }
Esempio n. 27
0
    public void DrawMapInEditor()
    {
        textureData.UpdateMeshHeights(terrainMaterial, terrainData.minHeight, terrainData.maxHeight);

        MapData    mapdata = GenerateMapData(Vector2.zero);
        MapDisplay display = FindObjectOfType <MapDisplay>();

        switch (drawMode)
        {
        case DrawMode.NoiseMap:
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(mapdata.heightMap));
            break;

        case DrawMode.Mesh:
            display.DrawMesh(
                MeshGenerator.GenerateTerrainMesh(mapdata.heightMap, terrainData.meshHeightMultiplier, terrainData.meshHeightCurve, editorPreviewLOD, terrainData.useFlatShading)
                );
            break;

        case DrawMode.FalloffMap:
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(FalloffGenerator.GenerateFalloffMap(mapChunkSize)));
            break;
        }
    }
Esempio n. 28
0
    public void GenerateMap()
    {
        MapDisplay display = FindObjectOfType <MapDisplay>();

        float[,] noiseMap = Noise.GenerateNoiseMap(mapWidth, mapHeight, seed, noiseScale, octaves, persistance, lacunarity, offset);

        Color[] colourMap = new Color[mapWidth * mapHeight];
        for (int y = 0; y < mapHeight; y++)
        {
            for (int x = 0; x < mapWidth; x++)
            {
                float currentHeight = noiseMap [x, y];
                for (int i = 0; i < regions.Length; i++)
                {
                    if (currentHeight <= regions [i].height)
                    {
                        colourMap [y * mapWidth + x] = regions [i].colour;
                        break;
                    }
                }
            }
        }

        if (drawMode == DrawMode.NoiseMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(noiseMap));
        }
        else if (drawMode == DrawMode.ColourMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromColourMap(colourMap, mapWidth, mapHeight));
        }
        else if (drawMode == DrawMode.TextureTerrain)
        {
            display.DrawCubes(textures, noiseMap, mapWidth, mapHeight, heightDescrepancy, cubeScale);
        }
    }
Esempio n. 29
0
    public void generateMap()
    {
        float[,] map = Noise.generateNosieMap(map_width, map_height, seed, noise_scale, octaves, persistance, lacunarity, offset);
        Color[] color_map = new Color[map_width * map_height];

        for (int x = 0; x < map_width; x++)
        {
            for (int y = 0; y < map_height; y++)
            {
                float current_height = map[x, y];
                for (int i = 0; i < regions.Length; i++)
                {
                    if (current_height <= regions[i].height)
                    {
                        color_map[y * map_width + x] = regions[i].color;
                        break;
                    }
                }
            }
        }

        MapDisplay display = FindObjectOfType <MapDisplay>();

        if (draw_mode == DrawMode.NoiseMap)
        {
            display.drawTexture(TextureGenerator.textureFromHeightMap(map));
        }
        else if (draw_mode == DrawMode.ColorMap)
        {
            display.drawTexture(TextureGenerator.textureFromColorMap(color_map, map_width, map_height));
        }
        else if (draw_mode == DrawMode.Mesh)
        {
            display.drawMesh(MeshGenerator.generateTerrainMesh(map), TextureGenerator.textureFromColorMap(color_map, map_width, map_height));
        }
    }
Esempio n. 30
0
    public void DrawMapInEditor()
    {
        textureData.ApplyToMaterial(terrainMaterial);
        textureData.UpdateMeshHeights(terrainMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);
        HeightMap heightMap = HeightMapGenerator.GenerateHeightMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, heightMapSettings, Vector2.zero);

        if (drawMode == DrawMode.NoiseMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            var data = MeshGenerator.GenerateTerrainMesh(heightMap.values, meshSettings, editorPreviewLOD);

            DrawMesh(data);

            // Sagie: Place an item
            //GenItem(data);
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(new HeightMap(FalloffGenerator.GenerateFalloffMap(meshSettings.numVertsPerLine), 0, 1)));
        }
    }
Esempio n. 31
0
    public void DrawMapInEditor()
    {
        MapData    mapData = GenerateMapData(Vector2.zero);
        MapDisplay display = FindObjectOfType <MapDisplay>();

        switch (drawMode)
        {
        case DrawMode.NoiseMap:
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(mapData.heightMap));
            break;

        case DrawMode.ColorMap:
            display.DrawTexture(TextureGenerator.TextureFromColorMap(mapData.colorMap, mapChunkSize, mapChunkSize));
            break;

        case DrawMode.Mesh:
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(mapData.heightMap, heightFactor, heightCurve, editorPreviewLOD), TextureGenerator.TextureFromColorMap(mapData.colorMap, mapChunkSize, mapChunkSize));
            break;

        case DrawMode.FalloffMap:
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(FalloffGenerator.GenerateFalloffMap(mapChunkSize)));
            break;
        }
    }
Esempio n. 32
0
    public void GenerateMap()
    {
        Stopwatch total = new Stopwatch();

        total.Start();

        Initialize();

        Stopwatch s = new Stopwatch();

        s.Start();

        CreateContinentHeightMap();

        UnityEngine.Debug.Log("total time to create continents: " + s.ElapsedMilliseconds);
        s.Restart();


        CreatePerlinMap();
        CreateRidgedMap();
        CreateVelleyMap();

        UnityEngine.Debug.Log("total time to create noisemaps: " + s.ElapsedMilliseconds);
        s.Restart();

        CombineHeightMaps();

        RecalculateMinMax();

        float[,] heightMap = CreateHeightMap();
        Color[] colorMap = GenerateColorMap(heightMap);

        display.DrawMesh(MeshGenerator.GenerateTerrainMesh(heightMap), TextureGenerator.TextureFromColourMap(colorMap, mapWidth, mapHeight));

        UnityEngine.Debug.Log("total time to do everything: " + total.ElapsedMilliseconds);
    }
    ///<summary>
    ///Generates the map texture via a noiseMap or a colourMap. Acts as user-interface in the Unity Inspector panel.
    ///</summary>
    ///<remarks>
    ///Whether a noiseMap or colourMap is generated is determined by the DrawMode setting set in the Unity Inspector.
    ///</remarks>
    public void GenerateMap()
    {
        float[,] noiseMap = Noise.GenerateNoiseMap (mapChunkSize,mapChunkSize, seed, noiseScale, octaves, persistance, lacunarity, offset);

        //Detecting height and assigning colour.
        Color[] colourMap = new Color[mapChunkSize*mapChunkSize];
        for (int y = 0; y < mapChunkSize; y++)     //loop through y coordinates of map.
        {
            for (int x = 0; x < mapChunkSize; x++)  //loop through x coordinates of map.
            {
                float currentHeight = noiseMap[x, y];
                for (int i = 0; i < regions.Length; i++)                    //Judging color by comparing height value to each region's bounds.
                {
                    if (currentHeight <= regions[i].height)
                    {
                        colourMap[y * mapChunkSize + x] = regions[i].colour;    //[y * mapwidth + x] is a 2D array to 1D array mapping. 
                        break;
                    }
                }
            }
        }

        MapDisplay display = FindObjectOfType<MapDisplay>();
        if (drawMode == DrawMode.NoiseMap)                      //Depending on Draw Mode setting in inspector, generate a BW texture from heightMap, color texture by colourMap, or Mesh from the Map data.
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(noiseMap));
        }
        else if (drawMode == DrawMode.ColourMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromColourMap(colourMap, mapChunkSize, mapChunkSize));
        } 
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(noiseMap, meshHeightMultiplier, meshHeightCurve, levelOfDetail), TextureGenerator.TextureFromColourMap(colourMap, mapChunkSize, mapChunkSize));
        }
    }