void Square5(SubMesh data, CardShape shape, Vector3 v0, Vector3 v1, Vector3 v2, Vector3 v3, Vector3 v4, Color color, bool flip) { int vi = data.VertexList.Count; Vector2 t0 = shape.UV0; Vector2 t1 = shape.UV1; Vector2 t2 = shape.UV2; Vector2 t3 = shape.UV3; Vector2 t4 = (t0 + t3) / 2; if (!flip) { data.AddVertex(v0, t3, color); data.AddVertex(v1, t2, color); data.AddVertex(v2, t1, color); data.AddVertex(v3, t0, color); data.AddVertex(v4, t4, color); } else { data.AddVertex(v0, t0, color); data.AddVertex(v1, t1, color); data.AddVertex(v2, t2, color); data.AddVertex(v3, t3, color); data.AddVertex(v4, t4, color); } data.AddTriangle(vi + 4, vi + 0, vi + 1); data.AddTriangle(vi + 4, vi + 1, vi + 2); data.AddTriangle(vi + 4, vi + 2, vi + 3); }
void Square(SubMesh data, CardShape shape, Vector3 pos, Vector2 size, Color color) { int vi = data.VertexList.Count; Vector2 t0 = shape.UV0; Vector2 t1 = shape.UV1; Vector2 t2 = shape.UV2; Vector2 t3 = shape.UV3; data.AddVertex(pos + new Vector3(-size.x, +size.y, 0), t0, color); data.AddVertex(pos + new Vector3(+size.x, +size.y, 0), t1, color); data.AddVertex(pos + new Vector3(+size.x, -size.y, 0), t2, color); data.AddVertex(pos + new Vector3(-size.x, -size.y, 0), t3, color); data.AddTriangle(vi, vi + 1, vi + 2); data.AddTriangle(vi, vi + 2, vi + 3); }
void BuildCorner3(SubMesh data, CardShape shape, Vector3 v0, Vector3 v1, Vector3 v2) { CardStock Stock = Definition.Stock; int smooth = Stock.Smooth; int vbase = data.VertexList.Count; this.VertexUV(data, shape, v0, UV(shape, 0, 1)); this.VertexUV(data, shape, v1, UV(shape, 0, 1)); this.VertexUV(data, shape, v2, UV(shape, 1, 0)); float deltaAngle = 0.5f * Mathf.PI / (smooth + 1); int prev = vbase + 1; Vector3 vy = v1 - v0; Vector3 vx = v2 - v0; for (int i = 0; i <= smooth; ++i) { if (i < smooth) { float angle = (i + 1) * deltaAngle; float tu = Mathf.Sin(angle); float tv = Mathf.Cos(angle); Vector3 xyz = v0 + tu * vx + tv * vy; Vector2 uv = UV(shape, tu, tv); data.AddVertex(xyz, uv, Color.white); } int vn = vbase + 3 + i; int vprev = (i == 0) ? vbase + 1 : vn - 1; int vnext = (i < smooth) ? vn : vbase + 2; data.AddTriangle(vbase, vprev, vnext); prev = vn; } }
void Square4(SubMesh data, CardShape shape, Vector3 v0, Vector3 v1, Vector3 v2, Vector3 v3, Color color, bool vflip, bool hflip) { int vi = data.VertexList.Count; Vector2 t0 = shape.UV3; Vector2 t1 = shape.UV2; Vector2 t2 = shape.UV1; Vector2 t3 = shape.UV0; if (!vflip) { if (hflip) { data.AddVertex(v0, t2, color); data.AddVertex(v1, t3, color); data.AddVertex(v2, t0, color); data.AddVertex(v3, t1, color); } else { data.AddVertex(v0, t3, color); data.AddVertex(v1, t2, color); data.AddVertex(v2, t1, color); data.AddVertex(v3, t0, color); } } else { if (hflip) { data.AddVertex(v0, t1, color); data.AddVertex(v1, t0, color); data.AddVertex(v2, t3, color); data.AddVertex(v3, t2, color); } else { data.AddVertex(v0, t0, color); data.AddVertex(v1, t1, color); data.AddVertex(v2, t2, color); data.AddVertex(v3, t3, color); } } data.AddTriangle(vi, vi + 1, vi + 2); data.AddTriangle(vi, vi + 2, vi + 3); }