static public Mesh2DSubmesh CreateBox(float size) { Mesh2DSubmesh result = new Mesh2DSubmesh(6); result.vertices[0] = new Vector3(-size, -size, 0); result.vertices[1] = new Vector3(size, -size, 0); result.vertices[2] = new Vector3(size, size, 0); result.vertices[3] = new Vector3(size, size, 0); result.vertices[4] = new Vector3(-size, size, 0); result.vertices[5] = new Vector3(-size, -size, 0); result.uv[0] = new Vector2(uv0, uv0); result.uv[1] = new Vector2(uv1, uv0); result.uv[2] = new Vector2(uv1, uv1); result.uv[3] = new Vector2(uv1, uv1); result.uv[4] = new Vector2(uv1, uv0); result.uv[5] = new Vector2(uv0, uv0); return(result); }
public void Add(Mesh2DSubmesh m) { submeshes.Add(m); verticesCount += m.vertices.Length; }
static public Mesh2DSubmesh CreateLine(Pair2D pair, Vector3 transformScale, float lineWidth, float z = 0f) { Mesh2DSubmesh result = new Mesh2DSubmesh(18); float xuv0 = 0; float xuv1 = 1f - xuv0; float yuv0 = 0; float yuv1 = 1f - yuv0; float size = lineWidth / 6; float rot = (float)Vector2D.Atan2(pair.A, pair.B); A1.x = pair.A.x; A1.y = pair.A.y; A2.x = pair.A.x; A2.y = pair.A.y; B1.x = pair.B.x; B1.y = pair.B.y; B2.x = pair.B.x; B2.y = pair.B.y; Vector2 scale = new Vector2(1f / transformScale.x, 1f / transformScale.y); A1.Push(rot + pi2, size, scale); A2.Push(rot - pi2, size, scale); B1.Push(rot + pi2, size, scale); B2.Push(rot - pi2, size, scale); result.vertices[0] = new Vector3((float)B1.x, (float)B1.y, z); result.vertices[1] = new Vector3((float)A1.x, (float)A1.y, z); result.vertices[2] = new Vector3((float)A2.x, (float)A2.y, z); result.vertices[3] = new Vector3((float)A2.x, (float)A2.y, z); result.vertices[4] = new Vector3((float)B2.x, (float)B2.y, z); result.vertices[5] = new Vector3((float)B1.x, (float)B1.y, z); result.uv[0] = new Vector2(xuv1 / 3, yuv1); result.uv[1] = new Vector2(1 - xuv1 / 3, yuv1); result.uv[2] = new Vector2(1 - xuv1 / 3, yuv0); result.uv[3] = new Vector2(1 - xuv1 / 3, yuv0); result.uv[4] = new Vector2(yuv1 / 3, xuv0); result.uv[5] = new Vector2(xuv1 / 3, yuv1); A3.x = A1.x; A3.y = A1.y; A4.x = A1.x; A4.y = A1.y; A3.Push(rot - pi2, size, scale); A3.x = A1.x; A3.y = A1.y; A4.x = A2.x; A4.y = A2.y; A1.Push(rot, size, scale); A2.Push(rot, size, scale); result.vertices[6] = new Vector3((float)A3.x, (float)A3.y, z); result.vertices[7] = new Vector3((float)A1.x, (float)A1.y, z); result.vertices[8] = new Vector3((float)A2.x, (float)A2.y, z); result.vertices[9] = new Vector3((float)A2.x, (float)A2.y, z); result.vertices[10] = new Vector3((float)A4.x, (float)A4.y, z); result.vertices[11] = new Vector3((float)A3.x, (float)A3.y, z); result.uv[6] = new Vector2(xuv1 / 3, yuv1); result.uv[7] = new Vector2(xuv0, yuv1); result.uv[8] = new Vector2(xuv0, yuv0); result.uv[9] = new Vector2(xuv0, yuv0); result.uv[10] = new Vector2(yuv1 / 3, xuv0); result.uv[11] = new Vector2(xuv1 / 3, yuv1); A1.x = B1.x; A1.y = B1.y; A2.x = B2.x; A2.y = B2.y; B1.Push(rot - Mathf.PI, size, scale); B2.Push(rot - Mathf.PI, size, scale); result.vertices[12] = new Vector3((float)B1.x, (float)B1.y, z); result.vertices[13] = new Vector3((float)A1.x, (float)A1.y, z); result.vertices[14] = new Vector3((float)A2.x, (float)A2.y, z); result.vertices[15] = new Vector3((float)A2.x, (float)A2.y, z); result.vertices[16] = new Vector3((float)B2.x, (float)B2.y, z); result.vertices[17] = new Vector3((float)B1.x, (float)B1.y, z); result.uv[12] = new Vector2(xuv0, yuv1); result.uv[13] = new Vector2(xuv1 / 3, yuv1); result.uv[14] = new Vector2(xuv1 / 3, yuv0); result.uv[15] = new Vector2(xuv1 / 3, yuv0); result.uv[16] = new Vector2(yuv0, xuv0); result.uv[17] = new Vector2(xuv0, yuv1); return(result); }