private void TriangulateRoadEdge(Vector3 centre, Vector3 ml, Vector3 mr, float index) { Roads.AddTriangle(centre, ml, mr); Roads.AddTriangleUV(new Vector3(1f, 0f), new Vector3(0f, 0f), new Vector3(0f, 0f)); var indices = new Vector3(index, index, index); Roads.AddTriangleCellData(indices, weights1); }
/// <summary> /// Creates the geometry for connecting different roads that converge on the cell center. /// </summary> void TriangulateRoadEdge(Vector3 center, Vector3 mL, Vector3 mR, float index) { Roads.AddTriangle(center, mL, mR); Roads.AddTriangleUV(new Vector2(1f, 0f), new Vector2(0f, 0f), new Vector2(0f, 0f)); Vector3 indices; indices.x = indices.y = indices.z = index; Roads.AddTriangleCellData(indices, weights1); }
private void TriangulateRoad( Vector3 centre, Vector3 ml, Vector3 mr, EdgeVertices e, bool hasRoadThroughEdge, float index) { if (hasRoadThroughEdge) { var indices = new Vector3(index, index, index); var mc = Vector3.Lerp(ml, mr, 0.5f); TriangulateRoadSegment(ml, mc, mr, e.v2, e.v3, e.v4, weights1, weights1, indices); Roads.AddTriangle(centre, ml, mc); Roads.AddTriangle(centre, mc, mr); Roads.AddTriangleUV(new Vector3(1f, 0f), new Vector3(0f, 0f), new Vector3(1f, 0f)); Roads.AddTriangleUV(new Vector3(1f, 0f), new Vector3(1f, 0f), new Vector3(0f, 0f)); Roads.AddTriangleCellData(indices, weights1); Roads.AddTriangleCellData(indices, weights1); } else { TriangulateRoadEdge(centre, ml, mr, index); } }
/// <summary> /// Creates road geometry for cell center. /// </summary> void TriangulateRoad(Vector3 center, Vector3 mL, Vector3 mR, EdgeVertices e, bool hasRoadThroughCellEdge, float index) { if (hasRoadThroughCellEdge) // Road in this direction ? { Vector3 indices; indices.x = indices.y = indices.z = index; Vector3 mC = Vector3.Lerp(mL, mR, 0.5f); TriangulateRoadSegment(mL, mC, mR, e.v2, e.v3, e.v4, weights1, weights1, indices); // Center connection triangles Roads.AddTriangle(center, mL, mC); Roads.AddTriangle(center, mC, mR); Roads.AddTriangleUV(new Vector2(1f, 0f), new Vector2(0f, 0f), new Vector2(1f, 0f)); Roads.AddTriangleUV(new Vector2(1f, 0f), new Vector2(1f, 0f), new Vector2(0f, 0f)); Roads.AddTriangleCellData(indices, weights1); Roads.AddTriangleCellData(indices, weights1); } else { // Then road exists in cell but not at this edge so draw auxiliary road geometry TriangulateRoadEdge(center, mL, mR, index); } }