Пример #1
0
        void OnMapDataReceived(MapData data)
        {
            this.mapData       = data;
            hasRecievedMapData = true;

            recievedTexture = TextureGenerator.GenerateColorTexture(mapData.noiseMap, mapData.colorMap);
            artifactManager = new TCArtifactManager(mapData, biome, ArtifactGenerationManager._LODforArtifacts, scaledWorldPosition, _meshChunkScale, relativeCoord);

            UpdateVisibilityOrLOD(); //TO start rendering our chunk now
        }
    private void GenerateMesh()
    {
        ArrayMesh mesh = MeshGenerator.GenerateMesh(noiseMap, MeshHeightMultiplier, MeshHeightCurve, LevelOfDetail);
        MeshInstance meshInstance = GetNode<MeshInstance>("MeshInstance");
        meshInstance.Mesh = mesh;
        meshInstance.CreateTrimeshCollision();

        SpatialMaterial material = new SpatialMaterial();
        material.AlbedoTexture = TextureGenerator.GenerateColorTexture(noiseMap, RegionThresholds, RegionColors);
        mesh.SurfaceSetMaterial(0, material);
    }
Пример #3
0
    public void DrawMesh(Mesh terrainMesh, Color[,] colorValues)
    {
        int width  = colorValues.GetLength(0);
        int height = colorValues.GetLength(1);

        // Construct a texture from the color values.
        TextureGenerator textureGenerator = FindObjectOfType <TextureGenerator>();
        Texture2D        colorTexture     = textureGenerator.GenerateColorTexture(colorValues, width, height);

        meshFilter.sharedMesh = terrainMesh;
        meshRenderer.sharedMaterial.mainTexture = colorTexture;
    }
Пример #4
0
    public void DrawColorMap(Color[,] colorValues)
    {
        int width  = colorValues.GetLength(0);
        int height = colorValues.GetLength(1);

        // Construct a texture from the color values.
        TextureGenerator textureGenerator = FindObjectOfType <TextureGenerator>();
        Texture2D        colorTexture     = textureGenerator.GenerateColorTexture(colorValues, width, height);

        // Apply the noise texture to the texture renderer and scale it properly.
        textureRenderer.sharedMaterial.mainTexture = colorTexture;
        textureRenderer.transform.localScale       = new Vector3(width, 1, height);
    }
Пример #5
0
    //Called by MapGenerator's custom editor script
    public void DrawMapInEditor()
    {
        if (!biome)
        {
            return;
        }
        GetComponent <biomeAmbienceManager>().setAmbience();
        MapData mapData = GenerateMapData(Vector2.zero, editorNormalizeMode);

        if (editorDrawMode == EditorDrawMode.raw)
        {
            GetComponent <mapDisplayer>().DrawTexture(TextureGenerator.GenerateRawTexture(mapData.noiseMap));
        }
        else if (editorDrawMode == EditorDrawMode.color)
        {
            GetComponent <mapDisplayer>().DrawTexture(TextureGenerator.GenerateColorTexture(mapData.noiseMap, mapData.colorMap));
        }
        else
        {
            GetComponent <mapDisplayer>().DrawMesh(MapMeshGenerator.GenerateMesh(mapData.noiseMap, editorMeshLevelOfDetail, biome.heightMultiplierCurve, biome.heightMultiplier), TextureGenerator.GenerateColorTexture(mapData.noiseMap, mapData.colorMap));
        }
    }
 private void GenerateColorTexture()
 {
     SpatialMaterial material = GetNode<CSGMesh>("Plane").Material as SpatialMaterial;
     material.AlbedoTexture = TextureGenerator.GenerateColorTexture(noiseMap, RegionThresholds, RegionColors);
 }