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); }
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); }