public override bool enterStem(CS_Stem stem)
 {
     return true;
 }
 public override bool leaveStem(CS_Stem stem)
 {
     return true;
 }
Example #3
0
 public override bool leaveStem(CS_Stem stem)
 {
     return(true);
 }
Example #4
0
 public override bool enterStem(CS_Stem stem)
 {
     // add leaves of this stem
     leafCount += stem.getLeafCount();
     return(true);
 }
Example #5
0
 public override bool enterStem(CS_Stem stem)
 {
     stemCount++; // one more stem
     return true;
 }
Example #6
0
 public override bool enterStem(CS_Stem stem)
 {
     return(true);
 }
 /**
  * going into a Stem
  *
  * @param stem
  * @return when false, stop traversal at this level
  */
 public abstract bool enterStem(CS_Stem stem);
 /**
  * coming out of a Stem
  *
  * @param stem
  * @return when false, stop traversal at this level
  */
 public abstract bool leaveStem(CS_Stem stem);
Example #9
0
 public override bool enterStem(CS_Stem stem)
 {
     stemCount++; // one more stem
     return(true);
 }
Example #10
0
        public override bool enterStem(CS_Stem stem)
        {
            foreach (CS_SegmentImpl seg in stem.getSections())
            {
                if (seg.getSubsegmentCount() == 1)
                {
                    DXSKV v0, v1;
                    Vector3 cv0 = seg.getLowerPosition();
                    Vector3 cv1 = seg.getUpperPosition();

                    // the tree is caculated in openGL coordinates with Z "up" so...
                    v0.P = new Vector3(cv0.X, cv0.Z, cv0.Y);
                    v1.P = new Vector3(cv1.X, cv1.Z, cv1.Y);
                    v0.C = colors[Math.Min(3, stem.getLevel())];
                    v1.C = colors[Math.Min(3, stem.getLevel())];

                    BBox.Maximum = Vector3.Max(BBox.Maximum, v0.P);
                    BBox.Maximum = Vector3.Max(BBox.Maximum, v1.P);
                    BBox.Minimum = Vector3.Min(BBox.Minimum, v0.P);
                    BBox.Minimum = Vector3.Min(BBox.Minimum, v1.P);

                    Vertices2[Math.Min(stem.getLevel(),3)].Add(v0);
                    Vertices2[Math.Min(stem.getLevel(),3)].Add(v1);
                }
                else
                {
                    Vector3 currPos = seg.getLowerPosition();

                    for (int subindex = 0; subindex < seg.getSubsegmentCount(); subindex++)
                    {
                        DXSKV v0, v1;

                        v0.P = new Vector3(currPos.X, currPos.Z, currPos.Y);

                        v1.P = new Vector3(0, 0, 0);
                        v1.P = seg.subsegments[subindex].getTransformation().apply(v1.P);
                        currPos = v1.P;
                        v1.P = new Vector3(v1.P.X, v1.P.Z, v1.P.Y);

                        v0.C = colors[Math.Min(3, stem.getLevel())];
                        v1.C = colors[Math.Min(3, stem.getLevel())];

                        Vertices2[Math.Min(stem.getLevel(),3)].Add(v0);
                        Vertices2[Math.Min(stem.getLevel(),3)].Add(v1);

                        BBox.Maximum = Vector3.Max(BBox.Maximum, v0.P);
                        BBox.Maximum = Vector3.Max(BBox.Maximum, v1.P);
                        BBox.Minimum = Vector3.Min(BBox.Minimum, v0.P);
                        BBox.Minimum = Vector3.Min(BBox.Minimum, v1.P);
                    }
                }
            }

            return true;
        }
            public override bool enterStem(CS_Stem stem)
            {
                // 1. Create the first section
                Vector3[] section_base = stem.getSections()[0].getSectionPoints();
                List<DXBaseArbaroTreeMesh.DXVertex> dxvv1 = new List<DXBaseArbaroTreeMesh.DXVertex>();
                foreach (Vector3 v in section_base)
                {

                    DXBaseArbaroTreeMesh.DXVertex dxv = _meshes[stem.getLevel()].Vertices.Add(new DXArbaroVertexTrait(v));
                    dxvv1.Add(dxv);
                }

                // 2. for each section but the last one - generate the upper part of the section
                //      and connect it with triangles to the previous section
                //      we use the lower section of next segment as upper section of current segment
                for (int i = 0; i < stem.getSections().Count; i++)
                {
                    if (stem.getSections()[i].getSubsegmentCount() == 1 && i != stem.getSections().Count - 1)
                    {
                        Vector3[] section_next = stem.getSections()[i + 1].getSectionPoints();
                        List<DXBaseArbaroTreeMesh.DXVertex> dxvv2 = new List<DXBaseArbaroTreeMesh.DXVertex>();
                        foreach (Vector3 v in section_next)
                        {
                            DXBaseArbaroTreeMesh.DXVertex dxv = _meshes[stem.getLevel()].Vertices.Add(new DXArbaroVertexTrait(v));
                            dxvv2.Add(dxv);
                        }
                        AddRangeVertex(_meshes[stem.getLevel()], dxvv1, dxvv2);
                        dxvv1 = dxvv2;
                    }
                    else
                    {
                        CS_SegmentImpl seg = stem.getSections()[i];
                        for (int j = 0; j < seg.getSubsegmentCount(); j++)
                        {
                            CS_SubsegmentImpl subseg = seg.subsegments[j];
                            Vector3[] section_next = subseg.getSectionPoints();
                            List<DXBaseArbaroTreeMesh.DXVertex> dxvv2 = new List<DXBaseArbaroTreeMesh.DXVertex>();
                            foreach (Vector3 v in section_next)
                            {
                                DXBaseArbaroTreeMesh.DXVertex dxv = _meshes[stem.getLevel()].Vertices.Add(new DXArbaroVertexTrait(v));
                                dxvv2.Add(dxv);
                            }
                            AddRangeVertex(_meshes[stem.getLevel()], dxvv1, dxvv2);
                            dxvv1 = dxvv2;
                        }
                    }
                }

                // 3. The last section I don't know how it gets calculated in initial Arbaro implementation :-(
                //      So I modified getSectionPoints to retrieve explicitely this last section
                if (stem.getSections()[stem.getSections().Count - 1].getSubsegmentCount() == 1)
                {
                    Vector3[] section_last = stem.getSections()[stem.getSections().Count - 1].getSectionPoints(false);
                    List<DXBaseArbaroTreeMesh.DXVertex> dxvv2 = new List<DXBaseArbaroTreeMesh.DXVertex>();
                    foreach (Vector3 v in section_last)
                    {
                        DXBaseArbaroTreeMesh.DXVertex dxv = _meshes[stem.getLevel()].Vertices.Add(new DXArbaroVertexTrait(v));
                        dxvv2.Add(dxv);
                    }
                    AddRangeVertex(_meshes[stem.getLevel()], dxvv1, dxvv2);
                }

                return true;
            }
 /**
  * coming out of a Stem
  *
  * @param stem
  * @return when false, stop traversal at this level
  */
 public abstract bool leaveStem(CS_Stem stem);
 /**
  * going into a Stem
  *
  * @param stem
  * @return when false, stop traversal at this level
  */
 public abstract bool enterStem(CS_Stem stem);
Example #14
0
        public override bool enterStem(CS_Stem stem)
        {
            // 1. Create the first section
            bool first = true;
            Vector3[] section_base = stem.getSections()[0].getSectionPoints();
            AddRangeVector3(section_base, stem.getLevel(), first); first = false;

            // 2. for each section but the last one - generate the upper part of the section
            //      and connect it with triangles to the previous section
            //      we use the lower section of next segment as upper section of current segment
            for (int i = 0; i < stem.getSections().Count; i++)
            {
                if (stem.getSections()[i].getSubsegmentCount() == 1 && i != stem.getSections().Count -1)
                {
                    Vector3[] section_next = stem.getSections()[i + 1].getSectionPoints();
                    AddRangeVector3(section_next, stem.getLevel(), first);
                }
                else {
                    CS_SegmentImpl seg = stem.getSections()[i];
                    for (int j = 0; j < seg.getSubsegmentCount(); j++)
                    {
                        CS_SubsegmentImpl subseg = seg.subsegments[j];
                        Vector3[] section_next = subseg.getSectionPoints();
                        AddRangeVector3(section_next, stem.getLevel(), first);
                    }
                }
            }

            // 3. The last section I don't know how it gets calculated in initial Arbaro implementation :-(
            //      So I modified getSectionPoints to retrieve explicitely this last section
            if (stem.getSections()[stem.getSections().Count-1].getSubsegmentCount() == 1)
            {
                Vector3[] section_last = stem.getSections()[stem.getSections().Count - 1].getSectionPoints(false);
                AddRangeVector3(section_last, stem.getLevel(), first);
            }

            return true;
        }
Example #15
0
 public override bool enterStem(CS_Stem stem)
 {
     // add leaves of this stem
     leafCount += stem.getLeafCount();
     return true;
 }