Esempio n. 1
0
    void CreateTree()
    {
        if (oldSeed == null)
        {
            oldSeed = new Seed();
            oldSeed.InitBranch();
        }

        // If seed hasn't changed return;
        if (Seed.CompareSeeds(oldSeed, seed))
        {
            return;
        }

        if (seed.randomSeedFromObjectHash)
        {
            int hash = this.transform.GetHashCode();
            if (hash != seed.randomSeed)
            {
                seed.randomSeed = hash;
            }
        }

        Seed.CopySeedDataIntoOtherSeed(oldSeed, seed);

        //FIX: Might be for the better reduce function calls
        seed.InitBranch();

        BranchRung firstTreeRung = new BranchRung {
            pos = ZERO,
            rot = new Vector2(
                -transform.localEulerAngles.z * Mathf.Deg2Rad,
                transform.localEulerAngles.x * Mathf.Deg2Rad)
        };

        List <Branch> allBranches = new List <Branch>();

        // This draws whole Tree
        Branch tree = new Branch(firstTreeRung, seed, allBranches);

        // 3D Model Logic:
        DrawTreeDModel(allBranches);
    }