コード例 #1
0
    /// <summary>
    /// Draws the preview map in the scene.
    /// </summary>
    public void DrawMapInEditor()
    {
        // applies the texture settings to the material
        textureSettings.ApplyToMaterial(terrainMaterial);
        textureSettings.UpdateMeshHeights(terrainMaterial, heightMapSettings.MinHeight, heightMapSettings.MaxHeight);
        // generates a height map from the mesh, height map and noise settings at location (0, 0)
        HeightMap heightMap = HeightMapGenerator.GenerateHeightMap(meshSettings.NumVertsPerLine, meshSettings.NumVertsPerLine, heightMapSettings, Vector2.zero);

        // draws a noise map on a texture
        if (drawMode == DrawMode.NoiseMap)
        {
            DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
        }
        // generates a mesh from the height map
        else if (drawMode == DrawMode.Mesh)
        {
            DrawMesh(MeshGenerator.GenerateTerrainMesh(heightMap.values, meshSettings, editorPreviewLOD));
        }
        // draws a falloff map on a texture
        else if (drawMode == DrawMode.FalloffMap)
        {
            // passes in a height map generated from the falloff generator
            DrawTexture(TextureGenerator.TextureFromHeightMap(new HeightMap(FalloffGenerator.GenerateFalloffMap(meshSettings.NumVertsPerLine), 0, 1)));
        }
    }
コード例 #2
0
    public void DrawMapInEditor()
    {
        textureSettings.ApplyToMaterial(terrainMaterial);
        textureSettings.UpdateMeshHeights(terrainMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);
        mHeightMap = new HeightMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine);

        if (drawMode == DrawMode.NoiseMap)
        {
            mHeightMap.GenerateHeightMap(heightMapSettings, Vector2.zero);
            DrawTexture(mHeightMap.GenerateTexture());
        }
        else if (drawMode == DrawMode.Mesh)
        {
            mHeightMap.GenerateHeightMap(heightMapSettings, Vector2.zero);
            DrawMesh(mHeightMap.GenerateMeshData(meshSettings, editorPreviewLOD));

            GenerateTree();
        }
        else if (drawMode == DrawMode.FalloffMap)
        {
            mHeightMap.minValue = 0;
            mHeightMap.maxValue = 1;
            mHeightMap.GenerateFalloffMap();
            DrawTexture(mHeightMap.GenerateTexture());
        }
    }
コード例 #3
0
    void Start()
    {
        CameraManager.Instance.onZoom -= OnZoom;
        CameraManager.Instance.onZoom += OnZoom;
        CameraManager.Instance.onMove -= OnMove;
        CameraManager.Instance.onMove += OnMove;

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

        UpdateViewChunk();
    }
コード例 #4
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);

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

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

        default:
            break;
        }
    }
コード例 #5
0
    public void DrawMapInEditor()
    {
        HeightMap heightMap = HeightMapGenerator.GenerateHeightMap(meshSettings.numVerticesPerLine, meshSettings.numVerticesPerLine, heightMapSettings, Vector2.zero);

        textureData.ApplyToMaterial(terrainMaterial);
        textureData.UpdateMeshHeights(terrainMaterial, heightMap.minValue, heightMap.maxValue);
        switch (drawMode)
        {
        case DrawMode.NOISE:
            DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
            break;

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

        case DrawMode.FALLOFF:
            DrawTexture(TextureGenerator.TextureFromHeightMap(new HeightMap(FalloffGenerator.GenerateFalloffMap(meshSettings.numVerticesPerLine), 0, 1)));
            break;
        }
    }
コード例 #6
0
ファイル: TerrainGenerator.cs プロジェクト: putyusz/Erosion
    void Start()
    {
        textureSettings.ApplyToMaterial(mapMaterial);
        textureSettings.UpdateMeshHeights(mapMaterial, heightMapSettings.MinHeight, heightMapSettings.MaxHeight);

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

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

        UpdateVisibleChunks();
    }
コード例 #7
0
        public void DrawMapInEditor()
        {
            textureData.ApplyToMaterial(terrainMaterial);
            textureData.UpdateMeshHeights(terrainMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);

            globalSettings.Initialize();

            var heightMap = HeightMapGenerator.GenerateHeightMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine, globalSettings, heightMapSettings, Vector2.zero);

            if (drawMode == DrawModes.NoiseMap)
            {
                DrawTexture(TextureGenerator.TextureFromHeightMap(heightMap));
            }
            else if (drawMode == DrawModes.Mesh)
            {
                DrawMesh(MeshGenerator.GenerateTerrainMesh(heightMap.values, meshSettings, editorPreviewLod));
            }
            else if (drawMode == DrawModes.FalloffMap)
            {
                DrawTexture(TextureGenerator.TextureFromHeightMap(new HeightMap(FalloffGenerator.GenerateFalloffMap(meshSettings.numVertsPerLine, meshSettings.numVertsPerLine), 0, 1)));
            }
        }
コード例 #8
0
    private void Start()
    {
        textureSettings.ApplyToMaterial(terrainMaterial);
        textureSettings.UpdateMeshHeights(terrainMaterial, heightMapSettings.minHeight, heightMapSettings.maxHeight);

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

        chunksVisibleInViewDistance = Mathf.RoundToInt(maxViewDistance / meshWorldSize);


        viewerPosition = new Vector2(viewer.position.x, viewer.position.z) / meshSettings.meshScale;
        UpdateVisibleChunks();
    }
コード例 #9
0
    /// <summary>
    /// Applies the texture settings to the map material and initialises chunks.
    /// </summary>
    private void Start()
    {
        // applies the texture settings to the material and passes the min and max height to the shader
        textureSettings.ApplyToMaterial(mapMaterial);
        textureSettings.UpdateMeshHeights(mapMaterial, heightMapSettings.MinHeight, heightMapSettings.MaxHeight);

        // calculates the max viewing distance from the visibile distance threshold of the last level of detail info
        float maxViewDist = detailLevels[detailLevels.Length - 1].visibleDistThreshold;

        // gets the mesh world size from the settings
        m_meshWorldSize = meshSettings.MeshWorldSize;
        // calculates what the view distance is for visible chunks
        m_chunkVisibleInViewDist = Mathf.RoundToInt(maxViewDist / m_meshWorldSize);

        // updates the visibility of the chunks, must occur in start because it is only called when the viewer has moved
        UpdateVisibleChunks();
    }