Esempio n. 1
0
    //TODO 切り出し

    //TODO 樹木を生成
    public static Mesh generateTree(TreeInfo info)
    {
        float radius = info.getRadius();
        float height = info.getHeight();
        float bdh    = info.getBranchDownHeight();

        Mesh mesh = new Mesh();

        //幹を作成
        for (float a = 0; a < height; a += 1f)
        {
            Mesh mesh_a = cylindrical_surface(Mathf.Lerp(radius, 0f, a / height), Mathf.Lerp(radius, 0f, (a + 1) / height), a + 1f < height ? 1f : height - a, 12);
            if (a != 0)
            {
                Vector3[] verts = mesh_a.vertices;
                mesh_move(verts, Vector3.up * a);
                mesh_a.vertices = verts;
            }
            mesh = mesh_combine(mesh, mesh_a);
        }

        //枝を作成
        for (float a = bdh; a < height; a += 0.2f)
        {
        }

        return(mesh);
    }