示例#1
0
        //Todo lo necesario para añadir una rama
        public void AddBranch(BranchContainer branch, BranchPoint originBranchPoint, Vector3 point, Vector3 normal)
        {
            BranchContainer newBranchContainer = ScriptableObject.CreateInstance <BranchContainer>();

            newBranchContainer.Init();

            newBranchContainer.AddBranchPoint(point, -normal);


            //newBranchContainer.grabVectors.Add (-normal);
            newBranchContainer.growDirection           = Vector3.Normalize(Vector3.ProjectOnPlane(branch.growDirection, normal));
            newBranchContainer.randomizeHeight         = Random.Range(4f, 8f);
            newBranchContainer.currentHeight           = branch.currentHeight;
            newBranchContainer.heightParameter         = branch.heightParameter;
            newBranchContainer.branchSense             = ChooseBranchSense();
            newBranchContainer.originPointOfThisBranch = originBranchPoint;
            //newBranchContainer.branchNumber = infoPool.ivyContainer.branches.Count;

            //Undo.RegisterCompleteObjectUndo(infoPool.ivyContainer, "Create new branch");
            //EditorUtility.SetDirty(infoPool.ivyContainer);

            //infoPool.ivyContainer.branches.Add(newBranchContainer);
            infoPool.ivyContainer.AddBranch(newBranchContainer);

            originBranchPoint.InitBranchInThisPoint(newBranchContainer.branchNumber);
        }
示例#2
0
        //Añadimos punto y todo lo que ello conlleva. Es ligeramente diferente a AddPoint. Está la posibilidad de spawnear una rama
        void AddFallingPoint(BranchContainer branch)
        {
            Vector3 grabVector = branch.rotationOnFallIteration * branch.GetLastBranchPoint().grabVector;

            branch.totalLenght += infoPool.ivyParameters.stepSize;
            branch.AddBranchPoint(branch.branchPoints[branch.branchPoints.Count - 1].point + branch.growDirection * infoPool.ivyParameters.stepSize,
                                  grabVector);


            if (Random.value < infoPool.ivyParameters.branchProvability && infoPool.ivyContainer.branches.Count < infoPool.ivyParameters.maxBranchs)
            {
                AddBranch(branch, branch.GetLastBranchPoint(), branch.branchPoints[branch.branchPoints.Count - 1].point, -branch.GetLastBranchPoint().grabVector);
            }
            AddLeave(branch);
        }
示例#3
0
        /*public void AddDrawingPoint(BranchContainer branch, Vector3 point, Vector3 normal, Vector3 paintDir)
         * {
         *      //Vector3 dir = branch.branchPoints[branch.branchPoints.Count - 1].point - branch.branchPoints[branch.branchPoints.Count - 2].point;
         *      //dir = dir.normalized;
         *
         *      branch.AddBranchPoint(point + normal * branch.currentHeight, -normal);
         *
         *
         *      branch.totalLenght += infoPool.ivyParameters.stepSize;
         *
         *      branch.GetLastBranchPoint().length = branch.totalLenght;
         *      branch.lenghts.Add(branch.totalLenght);
         *
         *      AddLeave(branch);
         * }*/

        //Añadimos punto y todo lo que ello conlleva. Está la posibilidad de spawnear una rama
        public void AddPoint(BranchContainer branch, Vector3 point, Vector3 normal)
        {
            branch.totalLenght     += infoPool.ivyParameters.stepSize;
            branch.heightParameter += infoPool.ivyParameters.stepSize;


            branch.AddBranchPoint(point + normal * branch.currentHeight, -normal);

            //Con este if lo que comprobamos realmente es si estamos en modo procedural o en modo pintado
            if (growing)
            {
                if (Random.value < infoPool.ivyParameters.branchProvability && infoPool.ivyContainer.branches.Count < infoPool.ivyParameters.maxBranchs)
                {
                    AddBranch(branch, branch.GetLastBranchPoint(), branch.branchPoints[branch.branchPoints.Count - 1].point, normal);
                }
            }
            AddLeave(branch);
        }