public void Cycle(Internode internode, SimulationStateSnapshot stateSnapshot, float height)
 {
     if (ShouldAddNewNode(internode, stateSnapshot, height))
     {
         internode.UpperNode = CreateNewUpperNode(internode);
     }
 }
    private void draw_internode(Internode internode, int coe)
    {
        Vector3    startPos  = internode.start_node.position + this.transform.position;
        Vector3    endPos    = internode.end_node.position + this.transform.position;
        Bud        bud       = internode.start_node.node_bud;
        Vector3    T         = bud.get_direction();
        Vector3    N         = Quaternion.Euler(0.0f, 0.0f, 90.0f) * T;
        Vector3    B         = Vector3.Cross(T, N);
        int        start_age = internode.start_node.node_bud.age;
        int        end_age   = internode.end_node.node_bud.age;
        Mesh       my_mesh   = Create_My_Mesh(T.normalized, N.normalized, B.normalized, startPos, endPos, start_age, end_age);
        GameObject s         = new GameObject("Textured Mesh");

        s.transform.position = this.transform.position;
        s.AddComponent <MeshFilter>();
        s.AddComponent <MeshRenderer>();
        s.GetComponent <MeshFilter>().mesh = my_mesh;
        Renderer rend = s.GetComponent <Renderer>();

        s.transform.parent = this.transform;
        if (curveUpward == false)
        {
            rend.material.color = new Color(Random.value, 1.0f, 1.0f, 1.0f);
        }
        else if (curveUpward == true)
        {
            rend.material.color = new Color(1.0f, Random.value, 1.0f, 1.0f);
        }
    }
        public Stem CreateStem(Vector3 center, Node nodeConnection)
        {
            // Since the node connection is the branching node, this stem will be a new branch and therefore + 1
            int stemBranchCount = nodeConnection.BranchCount + 1;

            Internode internode = CreateInternode(center, stemBranchCount);

            return(new GenericStem(internode, stemBranchCount));
        }
        private Node CreateNewUpperNode(Internode internode)
        {
            //var node = new GenericNode(internode);

            // var newLower = new GenericInternode(cellCreator.CreateCell(10), node);

            //node.UpperInternode = newLower;

            //return node;

            throw new NotImplementedException();
        }
Beispiel #5
0
 public void DrawInternode(Internode i)
 {
     if (i.Length < 1)
     {
         Turtle.SetColor(0, 1, 0);
     }
     else if (i.Length < 3)
     {
         Turtle.SetColor(0, 0.5, 0);
     }
     else
     {
         Turtle.SetColor(0.2, 0.1, 0);
     }
     Turtle.Thickness = System.Math.Pow(i.Area, 0.5);
     Turtle.Forward(i.Length, true);
 }
        public GenericNode CreateNode(Internode lowerInternode, IPlantPartDescriptor descriptor, bool withOptions)
        {
            var cells = CreateNodeCells(descriptor);

            var node = new GenericNode(lowerInternode, cells, lowerInternode.BranchCount);

            // If the node is created according to the options, then
            // the created stems and petioles will be added to the lists
            // above, otherwise they will just be empty lists.
            if (withOptions)
            {
                node.Stems    = CreateStems(descriptor, node);
                node.Petioles = CreatePetioles(descriptor);
            }

            return(node);
        }
        private bool ShouldAddNewNode(Internode internode, SimulationStateSnapshot snapshot, float height)
        {
            if (internode.HasUpperNode())
            {
                return(false);
            }

            var maxLength = Options.Plant.MaxInternodeLength.RandomNumberBetween();

            if (height >= maxLength)
            {
                return(true);
            }

            uint due = (uint)Options.Plant.NewNodeTickCount.RandomNumberBetween();

            if (due >= snapshot.CurrentTime)
            {
                return(true);
            }

            return(false);
        }
Beispiel #8
0
 public object InternodeGrow2(Internode i, Internode i2)
 {
     return(new Internode(i.Length * LengthGrowRate, i2.Area));
 }
Beispiel #9
0
 public object InternodeGrow1(Internode i, LSystems.StartBranchModule sb, Internode i2, LSystems.EndBranchModule eb, Internode i3)
 {
     return(new Internode(i.Length * LengthGrowRate, i2.Area + i3.Area));
 }
Beispiel #10
0
 public GenericNode(Internode lowerInternode, IEnumerable <IPlantCell> cells, IEnumerable <Stem> stems, IEnumerable <Petiole> petioles, int branchCount) : base(
         lowerInternode, cells, stems ?? new Stem[0], petioles ?? new Petiole[0], branchCount)
 {
 }
Beispiel #11
0
 public GenericNode(Internode lowerInternode, IEnumerable <IPlantCell> cells, IEnumerable <Petiole> petioles, int branchCount) : base(lowerInternode, cells, petioles, branchCount)
 {
 }
Beispiel #12
0
 public GenericNode(Internode lowerInternode, IEnumerable <IPlantCell> cells, IEnumerable <Stem> stems, int branchCount) : base(lowerInternode, cells, stems, branchCount)
 {
 }
 public object InternodeGrow2(Internode i, Internode i2)
 {
     return new Internode(i.Length * LengthGrowRate, i2.Area);
 }
 public object InternodeGrow1(Internode i, LSystems.StartBranchModule sb, Internode i2, LSystems.EndBranchModule eb, Internode i3)
 {
     return new Internode(i.Length * LengthGrowRate, i2.Area + i3.Area);
 }
 public void DrawInternode(Internode i)
 {
     if (i.Length < 1) Turtle.SetColor(0, 1, 0);
     else if (i.Length < 3) Turtle.SetColor(0, 0.5, 0);
     else Turtle.SetColor(0.2, 0.1, 0);
     Turtle.Thickness = System.Math.Pow(i.Area, 0.5);
     Turtle.Forward(i.Length, true);
 }
Beispiel #16
0
 public GenericStem(Internode internode, int branchCount) : base(internode, branchCount)
 {
 }
Beispiel #17
0
 public GenericNode(Internode lowerInternode, IEnumerable <IPlantCell> cells, int branchCount) : base(lowerInternode, cells, new Stem[0], new Petiole[0], branchCount)
 {
 }