Example #1
0
    protected override void GeneratePlant()
    {
        BetterList <InitPoint> points = new BetterList <InitPoint>();

        InitPoint p = new InitPoint();

        p.pos      = Vector3.zero;
        p.is_fixed = true;
        points.Add(p);

        int num_links = Random.Range(min_links, max_links);

        int       attempt_count = 0;
        const int max_attempt   = 1000;
        int       link_count    = 0;

        while (link_count < num_links && attempt_count < max_attempt)
        {
            attempt_count++;

            InitPoint prev_point = points[link_count];

            p = new InitPoint();

            float link_height = Random.Range(min_link_height, max_link_height);

            float   offset = Random.Range(min_offset, max_offset);
            Vector3 rnd    = Random.insideUnitSphere * offset;

            p.pos = prev_point.pos + new Vector3(0f, link_height, 0f) + rnd;

            p.parent = link_count;

            p.soft_clamp = true;
            p.soft_min   = 0f;
            p.soft_max   = 0.1f;
            points.Add(p);
            link_count++;
        }

        init_data = points.ToArray();
    }
Example #2
0
    protected override void GeneratePlant()
    {
        BetterList <InitPoint> points = new BetterList <InitPoint>();

        InitPoint p = new InitPoint();

        p.pos      = Vector3.zero;
        p.is_fixed = true;
        points.Add(p);

        float height    = Random.Range(min_height, max_height);
        int   num_fuzz  = Random.Range(min_fuzz, max_fuzz);
        float fuzz_dist = Random.Range(min_fuzz_dist, max_fuzz_dist);

        p            = new InitPoint();
        p.pos        = new Vector3(0f, height, 0f);
        p.parent     = 0;
        p.soft_min   = 0.05f;
        p.soft_max   = 0.05f;
        p.soft_clamp = true;
        points.Add(p);

        BetterList <Vector3> fuzz_points     = new BetterList <Vector3>();
        BetterList <Vector3> fuzz_directions = new BetterList <Vector3>();

        fuzz_directions.Add(-Vector3.up);

        int       attempt_count = 0;
        const int max_attempt   = 1000;
        int       fuzz_count    = 0;

        while (fuzz_count < num_fuzz && attempt_count < max_attempt)
        {
            attempt_count++;

            p = new InitPoint();
            Vector3 rnd = Random.insideUnitSphere * fuzz_dist;
            rnd  += rnd.normalized * 0.2f;
            p.pos = new Vector3(0f, height, 0f) + rnd;

            float min_angle = GetMinAngle(ref fuzz_directions, rnd);
            if (min_angle < 10f)
            {
                continue;
            }

            float min_dist = GetMinDist(ref fuzz_points, p.pos);
            if (min_dist < 0.5f)
            {
                continue;
            }

            p.parent     = 1;
            p.soft_clamp = true;
            p.soft_min   = 0.05f;
            p.soft_max   = 0.1f;
            points.Add(p);
            fuzz_count++;

            fuzz_directions.Add(rnd);
            fuzz_points.Add(p.pos);
        }

        init_data = points.ToArray();
    }