public MeshData CreateHexTube(MeshConnectorData top, MeshConnectorData bottom) { _meshDataBuilder.Reset(); AppendHexTube(top, bottom); return(_meshDataBuilder.Build()); }
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] ) ); } }