Ejemplo n.º 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);
        }
Ejemplo n.º 2
0
        //Creamos las estructuras de info para las ramas y asignamos las variables iniciales de la primera rama
        public void Initialize(Vector3 firstPoint, Vector3 firstGrabVector)
        {
            Random.InitState(infoPool.ivyParameters.randomSeed);

            BranchContainer newBranchContainer = ScriptableObject.CreateInstance <BranchContainer>();

            newBranchContainer.Init();
            newBranchContainer.currentHeight = infoPool.ivyParameters.minDistanceToSurface;


            infoPool.ivyContainer.AddBranch(newBranchContainer);
            infoPool.ivyContainer.branches[0].AddBranchPoint(firstPoint, firstGrabVector, true, newBranchContainer.branchNumber);
            infoPool.ivyContainer.branches [0].growDirection   = Quaternion.AngleAxis(Random.value * 360f, infoPool.ivyContainer.ivyGO.transform.up) * infoPool.ivyContainer.ivyGO.transform.forward;
            infoPool.ivyContainer.firstVertexVector            = infoPool.ivyContainer.branches [0].growDirection;
            infoPool.ivyContainer.branches [0].randomizeHeight = Random.Range(4f, 8f);
            CalculateNewHeight(infoPool.ivyContainer.branches [0]);
            infoPool.ivyContainer.branches [0].branchSense = ChooseBranchSense();
            randomstate = Random.state;
        }