private void AppendLeafBranchMesh(Branch branch, Vector3 branchStartingPoint, Vector3 branchEndingPoint) { var mainBranchMesh = _hexTubeMeshDataDirector.CreateHexTube( new MeshConnectorData( branchEndingPoint, branch.Radius, Quaternion.Euler(branch.ToDirection) //todo: might not actually be euler :) ), new MeshConnectorData(branchStartingPoint, branch.Radius, Quaternion.Euler(branch.FromDirection)) ); _meshDataBuilder.Append(mainBranchMesh); }
private void AppendHexTube(MeshConnectorData top, MeshConnectorData bottom) { var topCenter = top.Center; var topInnerRadius = top.InnerRadius; var topOrientation = top.Orientation; var bottomCenter = bottom.Center; var bottomInnerRadius = bottom.InnerRadius; var bottomOrientation = bottom.Orientation; if (Vector3.Distance(topCenter, bottomCenter) < ThresholdToDrawTube) { return; } var topHexRing = GetHexRingVertices(topInnerRadius, topCenter) .Select(v => RotateVectorAroundPivot(topCenter, topOrientation, v)) .ToArray(); var bottomHexRing = GetHexRingVertices(bottomInnerRadius, bottomCenter) .Select(v => RotateVectorAroundPivot(bottomCenter, bottomOrientation, v)) .ToArray(); for (var i = 0; i < 6; i++) { var rightIndex = i; var leftIndex = (i + 1) % 6; _meshDataBuilder.Append( CreateQuad( topHexRing[leftIndex], topHexRing[rightIndex], bottomHexRing[leftIndex], bottomHexRing[rightIndex] ) ); } }