Exemple #1
0
        void UpdateBranch(bool normalShader = false)
        {
            if (branchObject == null)
            {
                CreateBranchObject(normalShader);
            }

            CreateLeafMesh();
            MTree        branch = new MTree(branchObject.transform);
            TreeFunction trunkF = new TreeFunction(0, FunctionType.Trunk, null);

            float resolution = 20;

            Random.InitState(seed);

            branch.AddTrunk(Vector3.up, Vector3.forward, stemLength, AnimationCurve.Linear(0, 1, 1, .3f), radius, resolution, randomness / 3, 0, AnimationCurve.Linear(0, 1, 0, 0), 0, .01f, 1, 0);
            branch.AddBranches(0, length, AnimationCurve.Linear(0, 1, 1, 1), resolution, branchNumber, splitProba, AnimationCurve.Linear(0, 1, 1, 1),
                               angle, randomness, AnimationCurve.Linear(0, 1, 1, .4f), .9f, 0, 1, 0f, 2, .1f, 1f, 0.00001f);
            branch.AddLeafs(leafCovering, leafNumber, new Mesh[] { leafMesh }, leafSize, false, 0, 0, 1, leafAngle);

            Mesh mesh = CreateBranchMesh(branch, trunkF);

            branchObject.GetComponent <MeshFilter>().mesh = mesh;

            if (cameraObject == null)
            {
                CreateCameraObject();
            }
            RenderCamera();

            DestoyObjects();
        }
Exemple #2
0
        public override void Execute(MTree tree)
        {
            base.Execute(tree);

            Random.InitState(seed);
            int selection = parent == null ? 0 : parent.id;

            tree.AddBranches(selection, length, lengthCurve, resolution, number, splitProba, splitProbaCurve, angle
                             , randomness, shape, radius, upAttraction, id, start, gravityStrength, 0f, 0.001f);
        }
        public void Execute(MTree tree)
        {
            int selection = parent == null ? 0 : parent.id;

            Random.InitState(seed);


            if (type == FunctionType.Trunk)
            {
                tree.AddTrunk(Vector3.down * TheightOffset, Vector3.up, Tlength, Tradius, TradiusMultiplier, Tresolution, Trandomness
                              , id, TrootShape, TrootRadius, TrootHeight, TrootResolution, ToriginAttraction);
            }


            if (type == FunctionType.Grow)
            {
                tree.Grow(Glength, GlengthCurve, Gresolution, GsplitProba, GsplitProbaCurve, GsplitAngle, GmaxSplits, selection
                          , id, Grandomness, Gradius, GsplitRadius, GupAttraction, GgravityStrength, 0f, 0.001f);
            }

            if (type == FunctionType.Split)
            {
                tree.Split(selection, Snumber, SsplitAngle, id, SsplitRadius, Sstart, Sspread, 0f);
            }

            if (type == FunctionType.Branch)
            {
                tree.AddBranches(selection, Blength, BlengthCurve, Bresolution, Bnumber, BsplitProba, BsplitProbaCurve, Bangle
                                 , Brandomness, Bshape, Bradius, BupAttraction, id, Bstart, BgravityStrength, 0f, 0.001f);
            }

            if (type == FunctionType.Leaf)
            {
                tree.AddLeafs(LmaxRadius, Lnumber, LleafMesh, Lsize, LoverrideNormals, LminWeight, LmaxWeight, selection, 70, Lprocedural, Llength, Lresolution, LuLoops, LgravityStrength);
            }
        }