Example #1
0
 void send_tetris_mesh_to_mesh(tetris_mesh src, Mesh dst)
 {
     dst.Clear();
     dst.vertices  = src.pos;
     dst.triangles = src.indices;
     dst.uv        = src.uvs;
     dst.colors32  = src.colors;
     dst.Optimize();
     dst.RecalculateNormals();
 }
Example #2
0
    void compute_mesh(tetris_mesh m, int row_c, int col_c, float base_y, float base_x, float base_z,
                      float scale, Color32 color)
    {
        float pos_y = base_y;
        float pos_z = base_z;

        for (int y = 0; y < row_c; ++y, pos_y += scale)
        {
            float pos_x = base_x;
            int   row   = (int)(y * col_c);
            for (int x = 0; x < col_c; ++x, pos_x += scale)
            {
                int ind_0 = (x + row) * 4;
                int ind_1 = (x + row) * 6;

                m.pos[ind_0 + 0] = new Vector3(pos_x, pos_y, pos_z);
                m.pos[ind_0 + 1] = new Vector3(pos_x, pos_y + scale, pos_z);
                m.pos[ind_0 + 2] = new Vector3(pos_x + scale, pos_y, pos_z);
                m.pos[ind_0 + 3] = new Vector3(pos_x + scale, pos_y + scale, pos_z);

                m.indices[ind_1 + 0] = ind_0 + 0;
                m.indices[ind_1 + 1] = ind_0 + 1;
                m.indices[ind_1 + 2] = ind_0 + 2;
                m.indices[ind_1 + 3] = ind_0 + 1;
                m.indices[ind_1 + 4] = ind_0 + 3;
                m.indices[ind_1 + 5] = ind_0 + 2;

                m.colors[ind_0 + 0] = color;
                m.colors[ind_0 + 1] = color;
                m.colors[ind_0 + 2] = color;
                m.colors[ind_0 + 3] = color;

                m.uvs[ind_0 + 0] = new Vector2(0, 0);
                m.uvs[ind_0 + 1] = new Vector2(0, 1);
                m.uvs[ind_0 + 2] = new Vector2(1, 0);
                m.uvs[ind_0 + 3] = new Vector2(1, 1);
            }
        }
    }