How to create a hollowed polygon in USD without using diving it into convex polygons or triangulation?

59 views Asked by At

I am using python API to write USDA scripts, a human-readable USD (Universal Scene Description) file format. The task is to render a polygon with holes in it. The closest attribute in the openUSD repository is holeIndices, as shown here: https://openusd.org/dev/api/class_usd_geom_mesh.html#a70e20683a4bdc2e3925cb2a4e9759702. The definition for the attribute is "The indices of all faces that should be treated as holes, i.e. made invisible." The problem is that, it only made the referred polygon composed of inner vertices invisible but doesn't hide or "cut out" the display of the large polygon composed of outer vertices. Therefore, it makes no contribution to visually "forming a hole" on the existing polygon. I can prove it with the example I provided below.

def Xform "Plane"
{
    def Mesh "Mesh"
    {
        int[] faceVertexCounts = [4, 4]
        int[] faceVertexIndices = [0, 1, 2, 3, 5, 6, 7, 4]
        int[] holeIndices = [1, 0]
        point3f[] points = [(-1, -1, 0), (-1, 1, 0), (1, 1, 0), (1, -1, 0), (-0.5, -0.5, 0), (0.5, -0.5, 0), (0.5, 0.5, 0), (-0.5, 0.5, 0), (-0.8, -1, 0), (-0.4, -0.5, 0)]
    }
}

My question is, to achieve such a simple effect of displaying a hollowed polygon in USD, why isn't there a useful function or attribute to subtract the existing polygon to achieve it except this useless holeIndices attribute? If there really isn't a built-in function in openUSD to easily achieve that, another option is to triangulate the polygon into many small convex polygons before feeding into the USD file, which would take lots of unnecessary computation. This procedure seems silly and redundant if just for displaying polygons with holes. Any advice for displaying hollowed polygons in USD or about this unfathomable openUSD's design of holeIndices?

0

There are 0 answers