uv

  • public void Верстка(ref Mesh m)
    {

    Vector2[] uvs = new Vector2[m.vertices.Length];
    var ts_x = (from t in Триугольники orderby t.x select t.x).ToList();
    var ts_z = (from t in Триугольники orderby t.z select t.z).ToList();
    var ts_y = (from t in Триугольники orderby t.y select t.y).ToList();

    var max_x = ts_x.Last();
    var max_y = ts_y.Last();
    var max_z = ts_z.Last();

    var dx = 0.0f;
    var dy = 0.0f;
    var dz = 0.0f;
    if (ts_x[0] < 0)
    {dx = Mathf.Abs(ts_x[0]);
    max_x += Mathf.Abs(ts_x[0]);}
    if (ts_y[0] < 0)
    {dy = Mathf.Abs(ts_y[0]);
    max_y += dy;}
    if (ts_z[0] < 0){dz = Mathf.Abs(ts_z[0]);
    max_z += dz;}
    for (int i = 0; i < uvs.Length; i++){uvs[i] = new Vector2((m.vertices[i].x + dx)/ max_x, (m.vertices[i].z + dz) / max_z);}
    m.uv = uvs;
    }