//rightCell最高 Low left Right呈现顺时针方向 void GenCornerTriangle_SCCR(Vector3 low, HexCell lowCell, Vector3 left, HexCell leftCell, Vector3 right, HexCell rightCell) { BridgeType oppsite = HexMetrics.GetBridgeType(rightCell.Elevation, leftCell.Elevation); Vector3 disturb_low = HexMetrics.DisturbXZ(low); Vector3 disturb_left = HexMetrics.DisturbXZ(left); Vector3 disturb_right = HexMetrics.DisturbXZ(right); float t = (disturb_left - disturb_low).y / (disturb_right - disturb_low).y; Vector3 junction = Vector3.Lerp(disturb_low, disturb_right, t); if (oppsite == BridgeType.Slope) { AddTriangleUndisturbed(disturb_low, disturb_left, junction); Vector3 v1 = left; for (int i = 1; i <= HexMetrics.StepAmount; i++) { Vector3 v2 = HexMetrics.StepLerp(left, right, i); AddTriangleUndisturbed(v1.DisturbXZ(), v2.DisturbXZ(), junction); v1 = v2; } } else { AddTriangleUndisturbed(disturb_left, disturb_right, junction); Vector3 v1 = low; for (int i = 1; i <= HexMetrics.StepAmount; i++) { Vector3 v2 = HexMetrics.StepLerp(low, left, i); AddTriangleUndisturbed(v1.DisturbXZ(), v2.DisturbXZ(), junction); v1 = v2; } } }
void GenCornerTriangle(Vector3 low, HexCell lowCell, Vector3 left, HexCell leftCell, Vector3 right, HexCell rightCell) { BridgeType ToLeft = HexMetrics.GetBridgeType(lowCell.Elevation, leftCell.Elevation); BridgeType ToRight = HexMetrics.GetBridgeType(lowCell.Elevation, rightCell.Elevation); BridgeType Opposite = HexMetrics.GetBridgeType(leftCell.Elevation, rightCell.Elevation); //0-Flate,1-Slope,2-Cliff int[] type = new int[3]; type[(int)ToLeft]++; type[(int)ToRight]++; type[(int)Opposite]++; if (type[1] == 2 && type[0] == 1) { GenCornerTriangle_SFS(low, lowCell, left, leftCell, right, rightCell); } else if (type[1] == 2 && type[2] == 1) { GenCornerTriangle_SSC(low, lowCell, left, leftCell, right, rightCell); } else if (type[2] == 2 && type[1] == 1) { if (leftCell.Elevation > rightCell.Elevation) { GenCornerTriangle_SCCL(low, lowCell, left, leftCell, right, rightCell); } else { GenCornerTriangle_SCCR(low, lowCell, left, leftCell, right, rightCell); } } else { GenCornerTriangle_Flat(low, lowCell, left, leftCell, right, rightCell); } }
public BridgeType GetBridgeType(HexCell hexcell, Direction dir) { return(HexMetrics.GetBridgeType(hexcell.Elevation, hexcell.GetNeigbors(dir).Elevation)); }