Exemplo n.º 1
0
    public override void _Ready()
    {
        // ----
        // GD.Print(heightTerrain.Name); // <--- ERROR HERE, PRODUCES A CRASH RUNNING IN EDITOR
        // ----
        for (int i = 0; i < this.GetChildCount(); i++)
        {
            Node child = this.GetChild(i);
            this.RemoveChild(child);
        }
        float [,] noiseMap = Noise.GenerateNoiseMap(noise, chunkSize, noiseScale);
        MeshInstance world = new MeshInstance();

        world.Name = "World";
        PlaneMesh       plane = MapGenerator.GeneratePlaneMesh(chunkSize);
        SpatialMaterial mat   = new SpatialMaterial();

        mat.AlbedoTexture       = MapDisplay.DrawNoiseMapToTexture(noiseMap);
        mat.AlbedoTexture.Flags = 1;
        plane.Material          = mat;
        ArrayMesh mesh = MapGenerator.AddNoiseToMesh(plane, noiseMap, chunkSize, heightMultiplier, heightCurve);

        world.Mesh = mesh;
        AddChild(world);
        world.Owner = this;
    }