When I wrote a Maya importer for our custom assets, I was struck by how maya handles polygons. Basically as 3 arrays:
an XYZ point array,
an polyCounts int array of the number of verts per face
and polyConnects array of the XYZ point indices forming each face.
In my use case polyCounts was all 3’s because it’s all triangles.
It was an approach that took me a moment to wrap my brain around, not that I can think of an alternative. My lazy googling indicates that this is also how USD encodes polygon faces points, faceVertexIndices , and faceVertexCounts
So I’m wondering if this is just the way it’s always done for polygonal meshes, or if there are other possible approaches to poly face data?
There’s a couple ways I’ve come across, but they’re all similar.
For instance, .obj files do a kind of list of lists. Each line of the file starting with “f “ defines a face, and each space-separated item in the line contains a grouping of slash-separated “vertex/uv/normal“ indices.
Alembic, Usd, and the MFnMesh.getVertices() function do the counts/connects thing. And the reason for this structure has to do with how computers store data. If we were to store the data .obj style in the computer, it has to go through the list of lists one at a time and find the memory address of each sub-list (which could be anywhere) and then read that list. Processors like to grab big chunks of memory all at once, and this breaks things down into small random retrievals which can be slow. Storing two big arrays lets you get those big chunks that the processor likes from the RAM.
Oh, and XSI stored a combined counts/connects array that was [count, <idxs>, count, <idxs>, …]
But then you have the REAL way that maya stores its meshes. If you look in .ma files, or grab the binary data from .mb files, this is how they store the meshes. And there’s a good reason for it: The other ways of storing a mesh don’t explicitly keep track of edge indices, but that data needs to be available to Maya.
Then, once you have that data from memory, you can build more complicated structures like the Winged Edge:
The point array, face counts, and vertex indices approach seems very efficient and flexible for handling complex meshes. It’s always fascinating to learn how formats like Maya and USD organize geometry data behind the scenes. Understanding these structures feels a bit like learning the Snapchat Planets order—confusing at first, but much clearer once you see how everything connects.