TangoARScreen._MeshUpdateForIntrinsics C# (CSharp) Method

_MeshUpdateForIntrinsics() private static method

Update a mesh so it can be used for the Video Overlay image plane. The image plane is drawn without any projection or view matrix transforms, so it must line up exactly with normalized screen space. The texture coordinates of the mesh are adjusted so it properly clips the image plane.
private static _MeshUpdateForIntrinsics ( Mesh mesh, float uOffset, float vOffset ) : void
mesh Mesh Mesh to update.
uOffset float U texture coordinate clipping.
vOffset float V texture coordinate clipping.
return void
    private static void _MeshUpdateForIntrinsics(Mesh mesh, float uOffset, float vOffset)
    {
        // Set the vertices base on the offset, note that the offset is used to compensate
        // the ratio differences between the camera image and device screen.
        Vector3[] verts = new Vector3[4];
        verts[0] = new Vector3(-1, -1, 1);
        verts[1] = new Vector3(-1, +1, 1);
        verts[2] = new Vector3(+1, +1, 1);
        verts[3] = new Vector3(+1, -1, 1);

        // Set indices.
        int[] indices = new int[6];
        indices[0] = 0;
        indices[1] = 2;
        indices[2] = 3;
        indices[3] = 1;
        indices[4] = 2;
        indices[5] = 0;

        // Set UVs.
        Vector2[] uvs = new Vector2[4];
        uvs[0] = new Vector2(0 + uOffset, 0 + vOffset);
        uvs[1] = new Vector2(0 + uOffset, 1 - vOffset);
        uvs[2] = new Vector2(1 - uOffset, 1 - vOffset);
        uvs[3] = new Vector2(1 - uOffset, 0 + vOffset);

        mesh.Clear();
        mesh.vertices = verts;
        mesh.triangles = indices;
        mesh.uv = uvs;

        // Make this mesh never fail the occlusion cull
        mesh.bounds = new Bounds(Vector3.zero, new Vector3(float.MaxValue, float.MaxValue, float.MaxValue));
    }