ApplyToMaterial() 공개 메소드

public ApplyToMaterial ( Material material ) : void
material Material
리턴 void
예제 #1
0
    public void DrawMapInEditor()
    {
        textureData.ApplyToMaterial(terrainMaterial);
        textureData.UpdateMeshHeights(terrainMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);

        ChunkBorderInfo chunkBorderInfo = new ChunkBorderInfo(false, FalloffGenerator.Corner.TOPLEFT, false, FalloffGenerator.Edge.TOP);
        HeightMap       heightMap       = HeightMapGenerator.GenerateHeightMap(meshSettings.numberVerticesPerLine, meshSettings.numberVerticesPerLine, heightMapSettings, mapRulesSettings, Vector2.zero, chunkBorderInfo);

        CleanScene();

        if (drawMode == DrawMode.NoiseMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(new HeightMap(FalloffGenerator.GenerateFalloffMap(meshSettings.numberVerticesPerLine, mapRulesSettings), 0, 1)));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            DrawMesh(MeshGenerator.GenerateTerrainMesh(heightMap.values, meshSettings, editorPreviewLOD));
        }
        else if (drawMode == DrawMode.Map)
        {
            DrawMesh(MeshGenerator.GenerateTerrainMesh(heightMap.values, meshSettings, editorPreviewLOD));
            DrawMap();
        }
    }
예제 #2
0
    public void DrawMapInEditor()
    {
        if (newSeed)
        {
            heightMapSettings.noiseSettings.seed = rng.Next();
        }
        else
        {
            heightMapSettings.noiseSettings.seed = seed;
        }
        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)
        {
            DrawMesh(MeshGenerator.GenerateTerrainMesh(heightMap.values, meshSettings, editorPreviewLOD));
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(new HeightMap(FalloffGenerator.GenerateFalloffMap(meshSettings.numVertsPerLine), 0, 1)));
        }
    }
예제 #3
0
    public void DrawMapInEditor()
    {
        textureData.ApplyToMaterial(terrainMaterial);
        textureData.UpdateMeshHeights(terrainMaterial, heightMapSettings.MinHeight, heightMapSettings.MaxHeight);
        HeightMap heightMap = HeightMapGenerator.GenerateHeightMap(meshSettings.NumberOfVerticesPerLine,
                                                                   meshSettings.NumberOfVerticesPerLine, heightMapSettings, Vector2.zero);

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

        case DrawMode.Mesh:
            DrawMesh(
                MeshGenerator.GenerateTerrainMesh(heightMap.values, meshSettings, editorPreviewLevelOfDetail));
            break;

        case DrawMode.FallofMap:
            DrawTexture(
                TextureGenerator.TextureFromHeightMap(
                    new HeightMap(FallofGenerator.GenerateFallofMap(meshSettings.NumberOfVerticesPerLine), 0, 1)));
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
예제 #4
0
 private void Update()
 {
     if (!textureData.hasTextureSet)
     {
         textureData.ApplyToMaterial(terrainMaterial);
     }
 }
예제 #5
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
            );

        switch (drawMode)
        {
        case DrawMode.NoiseMap:
            DrawTexture(TextureGenerator.TextureFromeHeightMap(heightMap));
            break;

        case DrawMode.Mesh:
            DrawMesh(MeshGenerator.GenerateTerrainMesh(heightMap.values, meshSettings, editorPreviewLOD));
            break;

        case DrawMode.FallofMap:
            DrawTexture(TextureGenerator.TextureFromeHeightMap(new HeightMap(FalloffGenerator.GenerateFalloffMap(meshSettings.numVertsPerLine), 0, 1)));
            break;
        }
    }
예제 #6
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);
        HeatMap   heatMap   = HeatMapGenerator.GenerateHeatMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, heightMap, heatMapSettings, Vector2.zero);
        TreeMap   treeMap   = TreeMapGenerator.generateVegetationMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, heightMap, heatMap, treeMapSettings, Vector2.zero);

        DestroyTrees();          //temporary fix

        if (drawMode == DrawMode.HeightMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            DrawMesh(MeshGenerator.GenerateTerrainMesh2(heightMap.values, meshSettings, editorPreviewLOD, heatMap.values));
            DrawTrees(heightMap.values, meshSettings, treeMap.values);
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(new HeightMap(FalloffGenerator.GenerateFalloffMap(meshSettings.numVertsPerLine), 0, 1)));
        }
        else if (drawMode == DrawMode.HeatMap)
        {
            DrawTexture(TextureGenerator.TextureColorizedFromHeatMap(heatMap));
        }
        else if (drawMode == DrawMode.TreeMap)
        {
            DrawTexture(TextureGenerator.TextureFromTreeMap(treeMap));
        }
    }
예제 #7
0
    public void DrawMapInEditor()
    {
        textureData.ApplyToMaterial(terrainMaterial);
        textureData.UpdateMeshHeights(terrainMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);
        HeightMap heightMap;

        if (eastSettings != null && westSettings != null && westLocation != null && westLocation != null)
        {
            Region east = new Region(eastSettings, eastLocationPos);
            Region west = new Region(westSettings, westLocationPos);
            heightMap = HeightMapGenerator.GenerateHeightMap(meshSettings, new Region(heightMapSettings, east, west, Vector3.zero, power), Vector2.zero);
        }
        else
        {
            heightMap = HeightMapGenerator.GenerateHeightMap(meshSettings, heightMapSettings, Vector2.zero);
        }

        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.numVertsPerLine), 0, 1)));
        }
    }
예제 #8
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
            );

        if (drawMode == DrawMode.NoiseMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            DrawMesh(MeshGenerator.GenerateTerrainMesh(
                         heightMap.values,
                         editorPreviewLOD,
                         meshSettings
                         )
                     );
        }
        else
        {
            float[,] values = FalloffGenerator.GenerateFalloffMap(meshSettings.numVerticesPerLine);
            DrawTexture(TextureGenerator.TextureFromHeightMap(new HeightMap(values, 0, 1)));
        }
    }
예제 #9
0
    public void GenerateMap()
    {
        var meshData = MapMeshGenerator.GenerateTerrainMesh(Noise.GenerateNoiseMap(noiseMapSettings), noiseMapSettings.heightMultiplier, noiseMapSettings.heightEvaluator);

        meshFilter.sharedMesh = meshData.CreateMesh();

        textureData.ApplyToMaterial(meshRenderer.sharedMaterial);
    }
예제 #10
0
    public void DrawMapInEditor()
    {
        //Used to store prefab objects in edit mode and delete them when changes are made (is a bit buggy)
        if (_biomeContainer != null)
        {
            DestroyImmediate(_biomeContainer.gameObject);
        }
        _biomeContainer = new GameObject("DELETE ME IF MANY OF ME").transform;

        //Apply material to mesh
        _textureData.ApplyToMaterial(_terrainMaterial);
        _textureData.UpdateMeshHeights(_terrainMaterial, _heightMapSettings.MinHeight, _heightMapSettings.MaxHeight);

        //Generate the heightmap for the chunk at origin
        HeightMap heightMap = HeightMapGenerator.GenerateHeightMap(_meshSettings.NumVertsPerLine, _meshSettings.NumVertsPerLine, _heightMapSettings, _chunkCoord);

        Vector2 sampleCenter = _chunkCoord * _meshSettings.MeshWorldSize / _meshSettings.MeshScale;

        float[,] noise1 = Noise.GenerateNoiseMap(_meshSettings.NumVertsPerLine * _noiseViewSize, _meshSettings.NumVertsPerLine * _noiseViewSize, 1, _noiseSettingsData_1.NoiseSettingsDataMerge, _chunkCoord);
        noise1          = Noise.Clamp(noise1, _noiseSettingsData_1);
        float[,] noise2 = Noise.GenerateNoiseMap(_meshSettings.NumVertsPerLine * _noiseViewSize, _meshSettings.NumVertsPerLine * _noiseViewSize, 1, _noiseSettingsData_2.NoiseSettingsDataMerge, _chunkCoord);
        noise2          = Noise.Clamp(noise2, _noiseSettingsData_2);

        float[,] noise = _noiseMergeType == NoiseMergeType.ONLY_FIRST ? noise1 : noise2;



        if (_drawMode == DrawMode.NOISE_MAP)
        {
            DrawTexture(TextureGenerator.TextureFromNoise(noise));
        }
        else if (_drawMode == DrawMode.MESH)
        {
            DrawMesh(MeshGenerator.GenerateTerrainMesh(heightMap.heightMap, _meshSettings, _editorPreviewLevelOfDetail));
        }
        else if (_drawMode == DrawMode.FALL_OF_MAP)
        {
            float[,] fallOf = (new HeightMap(FallofGenerator.GenerateFallofMap(_meshSettings.NumVertsPerLine), 1, 1).heightMap);
            DrawTexture(TextureGenerator.TextureFromNoise(fallOf));
        }
        else if (_drawMode == DrawMode.BIOME)
        {
            MeshData meshData = MeshGenerator.GenerateTerrainMesh(heightMap.heightMap, _meshSettings, _editorPreviewLevelOfDetail);
            DrawMesh(meshData);
            PrefabSpawner    prefabSpawner = new PrefabSpawner();
            List <SpawnInfo> spawnInfo     = prefabSpawner.SpawnOnChunk(2, 0, _biome, heightMap, meshData, _meshSettings, new Vector2(sampleCenter.x, -sampleCenter.y), _chunkCoord);
            prefabSpawner.SpawnSpawnInfo(spawnInfo, _biomeContainer, true);
        }
        else if (_drawMode == DrawMode.MAP)
        {
            TextureChunkData data = TextureGenerator.DrawMap(_meshSettings.NumVertsPerLine * _noiseViewSize, _mapSettings, new Vector2(sampleCenter.x, -sampleCenter.y), _chunkCoord);
            DrawTexture(TextureGenerator.TextureFromColorMap(data.colorMap, data.width, data.height));
        }
    }
예제 #11
0
    private void Start()
    {
        panelProcess = gameObject.GetComponent <PanelProcess>() as PanelProcess;
        eGen         = gameObject.GetComponent <EnvironmentGenerator>() as EnvironmentGenerator;

        textureData.ApplyToMaterial(terrainMateial, meshSettings.uniformScale);
        textureData.UpdateMeshH(terrainMateial, hightMapSettings.minH, hightMapSettings.maxH, meshSettings.uniformScale);

        if (draweMode == DraweMode.MeshAndEnvironment)
        {
            panelProcess.setActive(true);
        }
        StartCoroutine(startGenIn());
        panelProcess.setNumer("1/1");
    }
        public IEnumerator <WaitForEndOfFrame> ModifySection(ISentenceData data)
        {
            var groundData   = data as IGroundData;
            var groundColors = groundData.GroundColors();

            // Keep runing till replaced by new enumerator
            while (true)
            {
                // Change each layer color
                for (int i = 0; i < MaxLayers; i++)
                {
                    var currColor = Color.Lerp(orgLayerColors[i], Helpers.FromText(groundColors[i]), Globals.speedChange * (Time.time - startTime));
                    textureData.layers[i].tint = currColor;
                }

                // Apply color changes
                textureData.ApplyToMaterial(groundMaterial);

                // Change glossiness and metallic
                groundMaterial.SetFloat(Glossiness, Mathf.Lerp(orgGlosiness, groundData.Smoothness(), Globals.speedChange * (Time.time - startTime)));
                groundMaterial.SetFloat(Glossiness, Mathf.Lerp(orgMetallic, groundData.Metallic(), Globals.speedChange * (Time.time - startTime)));

                yield return(Globals.EndOfFrame);
            }
        }
예제 #13
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.TextureFromHightMap(heightMap));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            DrawMesh(MeshGenerator.GenerateTerrainMesh(heightMap.values, meshSettings, editorPreviewLevelOfDetail));
        }
    }
예제 #14
0
    public void GenerateWorld()
    {
        GameObject world = new GameObject("World");

        GenerateChunks(world.transform);

        currentTextureSettings.UpdateMeshHeights(worldMeshMaterial, worldMinHeight, worldMaxHeight);
        currentTextureSettings.ApplyToMaterial(worldMeshMaterial);

        Instantiate(waterPrefab, new Vector3(0, seaLevel, 0), Quaternion.identity, world.transform);

        Instantiate(seaFloorPrefab, new Vector3(0, -0.05f, 0), Quaternion.identity, world.transform);

        Transform clutterParent = new GameObject("Clutter").transform;

        clutterParent.parent = world.transform;

        GameObject[][] clutterPrefabs = new GameObject[2][];
        clutterPrefabs[0] = rockPrefabs;
        clutterPrefabs[1] = treePrefabs;

        ClutterPlacer.PlaceClutter(new ClutterMap[] { rockClutterMap, treeClutterMap }, meshSettings, clutterPrefabs, clutterParent);

        Camera.main.GetComponent <SimpleCameraController>().enabled = true;
        canvasMapGenerator.SetActive(false);
        gameObject.SetActive(false);
    }
    public void DrawMapInEditor()
    {
        textureData.ApplyToMaterial(terrainMaterial);
        textureData.UpdateMeshHeights(terrainMaterial, heightMapSettings.MinHeight, heightMapSettings.MaxHeight);
        HeightMap data = HeightMapGenerator.GenerateHeightMap(meshSettings.NumVertsPerLine, meshSettings.NumVertsPerLine, heightMapSettings, Vector2.zero);

        if (drawMode == DrawMode.Noise)
        {
            DrawTexture(TextureGenerator.GenerateTextureFromHeightMap(data));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            DrawMesh(MeshGenerator.GenerateTerrainMesh(data.Values, meshSettings, editorPreviewLOD));
        }
        else if (drawMode == DrawMode.Falloff)
        {
            DrawTexture(TextureGenerator.GenerateTextureFromHeightMap(new HeightMap(FalloffGenerator.GenerateFalloffMap(meshSettings.NumVertsPerLine), 0, 1)));
        }
    }
    // Start is called before the first frame update
    void Start()
    {
        textureSettings.ApplyToMaterial(mapMaterial); // Onvalidate is not called when application is built
        textureSettings.UpdateMeshHeights(mapMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);

        float maxViewDst = detailLevels[detailLevels.Length - 1].visibleDstThreshold;

        meshWorldSize          = meshSettings.meshWorldSize;
        chunksVisibleInViewDst = Mathf.RoundToInt(maxViewDst / meshWorldSize);
    }
예제 #17
0
    void Start()
    {
        textureSettings.ApplyToMaterial(mapMaterial);
        textureSettings.UpdateMeshHeights(mapMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);
        float maxViewDst = detailLevels [detailLevels.Length - 1].visibleDstThreshold;

        meshWorldSize          = meshSettings.meshWorldSize;
        chunksVisibleInViewDst = Mathf.RoundToInt(maxViewDst / meshWorldSize);
        UpdateVisibleChunks();
    }
예제 #18
0
    public void DrawMapInEditor()
    {
        textureData.ApplyToMaterial(terrainMaterial);
        textureData.UpdateMeshHeights(terrainMaterial, heightMapSettings.minHeight, heightMapSettings.maximumMapHeight);
        HeightMap heightMap = HeightMapGenerator.GenerateHeightMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, heightMapSettings, Vector2.zero);

        if (drawMode == DrawMode.NoiseMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            DrawMesh(WorldMesh.GenerateTerrainMesh(heightMap.values, meshSettings, editorPreviewLOD));
            //DrawWater();
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(new HeightMap(WorldFalloff.GenerateFalloffMap(meshSettings.numVertsPerLine), 0, 1, heightMapSettings.maximumMapHeight)));
        }
    }
예제 #19
0
        private void Start()
        {
            textureSettings.ApplyToMaterial(mapMaterial);
            textureSettings.UpdateMeshHeights(mapMaterial, heightMapSettings.MinHeight, heightMapSettings.MaxHeight);

            float maxViewDistance = detailLevels[detailLevels.Length - 1].visibleDistanceThreshold;

            _worldSize = meshSettings.MeshWorldSize;
            _chunksVisibleInViewDistance = Mathf.RoundToInt(maxViewDistance / _worldSize);

            UpdateVisibleChunks();
        }
예제 #20
0
    bool startFix; //костыль

    void Start()
    {
        textureSettings.ApplyToMaterial(mapMaterial);
        textureSettings.UpdateMeshHeights(mapMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);
        float maxViewDst = detailLevels[detailLevels.Length - 1].visibleDstThreshold;

        // отличается от размера куска из генератора, тк описывает кол-во сторон, а не вершин
        meshWorldSize          = meshSettings.meshWorldSize;
        chunksVisibleInViewDst = Mathf.RoundToInt(maxViewDst / meshWorldSize);
        isViewerSet            = false;
        startFix = true;
    }
    public void DrawMapInEditor()
    {
        textureData.ApplyToMaterial(terrainMaterial);
        textureData.UpdateMeshHeights(terrainMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);
        HeightMap heightMap = HeightMapGenerator.GenerateHeightMap(meshSettings.numberOfVerticesPerLine, meshSettings.numberOfVerticesPerLine, heightMapSettings, Vector2.zero);

        if (drawMode == DrawMode.NoiseMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            MeshData meshData = MeshGenerator.GenerateTerrainMeshData(heightMap.values, meshSettings, editorPreviewLevelOfDetail);
            DrawMesh(meshData);
        }
        else if (drawMode == DrawMode.Falloff)
        {
            HeightMap falloffMap = new HeightMap(FalloffGenerator.GenerateFallofMap(meshSettings.numberOfVerticesPerLine), 0, 1);
            DrawTexture(TextureGenerator.TextureFromHeightMap(falloffMap));
        }
    }
    public void DrawMapInEditor()
    {
        textureData.ApplyToMaterial(terrainMaterial);
        textureData.UpdateMeshHeight(terrainMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);

        HeightMap heightMap = HeightMapGenerator.GenerateHeightMap(meshSettings.numberOfVerticesPerLine,
                                                                   meshSettings.numberOfVerticesPerLine, heightMapSettings, Vector2.zero);

        //Chooses to draw the raw or the coloured noise map
        if (drawMode == DrawMode.NoiseMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            DrawMesh(MeshGenerator.GenerateTerrainMesh(heightMap.values, meshSettings, editorPreviewLevelOfDetail));
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(new HeightMap(FalloffGen.GenerateFalloffMap(meshSettings.numberOfVerticesPerLine), 0, 1)));
        }
    }
    private void Start()
    {
        textureData.ApplyToMaterial(mapMaterial);
        textureData.UpdateMeshHeight(mapMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);

        viewerPositionOld = viewerPosition;
        float maxViewDist = detailLevels[detailLevels.Length - 1].visibleDistThreshhold;

        meshWorldSize           = meshSettings.meshWorldSize;
        chunksVisibleInViewDist = Mathf.RoundToInt(maxViewDist / meshWorldSize);

        UpdateVisibleChunks();
    }
예제 #24
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)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
        }
        else if (drawMode == DrawMode.Mesh)
        {
            display.DrawMesh(MeshGenerator.GenerateTerrainMesh(heightMap.values, meshSettings, editorPreviewLevelOfDetail));
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            display.DrawTexture(TextureGenerator.TextureFromHeightMap(
                                    new HeightMap(FalloffGenerator.GenerateFalloffMap(meshSettings.numVerticesPerLine), 0, 1)));
        }
    }
예제 #25
0
        private void Start()
        {
            heightMapSettings.generate = m_GenerateHeightmaps;

            textureSettings.ApplyToMaterial(mapMaterial);
            textureSettings.UpdateMeshHeights(mapMaterial, heightMapSettings.MinHeight, heightMapSettings.MaxHeight);

            var maxViewDst = detailLevels[detailLevels.Length - 1].visibleDstThreshold;

            _meshWorldSize          = meshSettings.MeshWorldSize;
            _chunksVisibleInViewDst = Mathf.RoundToInt(maxViewDst / _meshWorldSize);

            StartCoroutine(WaitUntilGeneratorIsReady());
        }
예제 #26
0
    void Start()
    {
        textureSettings.ApplyToMaterial(meshMaterial);
        textureSettings.UpdateMeshHeights(meshMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);

        float maxViewDistance = detailLevels [detailLevels.Length - 1].visibleDistanceThreshold;

        meshWorldSize = meshSettings.meshWorldSize;
        chunksVisibleInViewDistance = Mathf.RoundToInt(maxViewDistance / meshWorldSize);

        // Always update visible chunks at the start since in the Update()
        // method we don't do so until the viewer has moved a bit
        UpdateVisibleChunks();
    }
    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)));
        }
    }
예제 #28
0
    void Start()
    {
        instance     = this;
        voronoi.Seed = heightMapSettings.noiseSettings.seed;

        textureSettings.ApplyToMaterial(mapMaterial);
        textureSettings.UpdateMeshHeights(mapMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);

        float maxViewDst = detailLevels[detailLevels.Length - 1].visibleDstThreshold;

        meshWorldSize          = meshSettings.meshWorldSize;
        chunksVisibleInViewDst = Mathf.RoundToInt(maxViewDst / meshWorldSize);

        StartCoroutine(UpdateVisibleChunks());
    }
예제 #29
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)));
        }
    }
    void Start()
    {
        //give all the data to the shader
        textureSettings.ApplyToMaterial(mapMaterial);
        //update the material with new min and max height values
        textureSettings.UpdateMeshHeights(mapMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);

        //setting the maxViewDist
        float maxViewDist = detailLevels[detailLevels.Length - 1].visibleDistThreshhold;

        meshWorldSize           = meshSettings.meshWorldSize;
        chunksVisibleInViewDist = Mathf.RoundToInt(maxViewDist / meshWorldSize);

        UpdateVisibleChunks();
    }