コード例 #1
0
    // Initialization code.  Must be called directly, sets up the component
    public void Generate(int width, int height)
    {
        plane = gameObject.GetComponent<PlaneMesh>();
        plane.Generate(width, height);

        Width = plane.Width;
        Height = plane.Height;

        Grid = new float[Width, Height];
        SwapGrid = new float[Width, Height];
    }
コード例 #2
0
    // Initializes the terrain generator
    public void Generate(int width, int height)
    {
        plane = gameObject.GetComponent<PlaneMesh>();
        plane.Generate(width, height);

        Width = plane.Width;
        Height = plane.Height;

        HeightMap = new float[Width, Height];
        GenerateHeightMap();

        // Alter the heightmap to reflect the terrain
        plane.UpdateHeights(HeightMap);
        plane.mesh.Optimize();

        // Add the newly generated mesh to the mesh collider
        // (for some reason it can't find it otherwise?)
        gameObject.GetComponent<MeshCollider>().sharedMesh = plane.mesh;
    }