Saturday, 9 April 2022

Vertex IDs & Vertex Order

Polymesh objects in Maya are made up of components, like faces, and edges, and such. And the king of components - the most fundamental - is vertices.

Every vertex in a mesh has a unique identifier called an ID that helps Maya tell them apart.
And it's important to understand a few things about these IDs...


Vertex IDs

The reason Maya is able to tell one vertex from another is because every single vertex in a mesh object has a unique number assigned to it called a vertex ID.
The quickest way to see a vertex's ID is to select that vertex and look up at the very top of the Maya window. The name of the object will be displayed followed by a number enclosed in brackets:

If you select multiple vertices at once AND there's no break in between those verts you have selected, it will look like this:

^ This indicates that vertices [0] to [97] have all been selected.

But if there is a break in your vertex selection - like say you have selected verts [0]-[45] and [53]-[97] - then in becomes infeasible for Maya to show you, up top, which vertices specifically you have selected, so it just trails off with an ellipsis:


If all else fails, you can always check the script editor for a read out of your selections:

You can also expose all vertex IDs for an object in the viewport by going Display > Polygons > Component IDs > Vertices.


Vertex Order

There are some very important rules about the order of Vertex IDs.

Every mesh's list of vertices starts at [0], and counts upward, without any gaps. And no repetition either; Every ID must be unique. 
 
So if a mesh has 58 vertices, their IDs will necessarily be [0] to [57]

This must always be the case. Maya won't allow otherwise.
But don't worry. We don't actually have to do anything about this. Maya handles it all for you.

But consider what it would means if in a mesh with 58 vertices, you went and deleted vertex[15].


Clearly this is allowed. We delete vertices all the time. Does this mean we end up with a mesh containing vertices[0] to [57] but vert[15] is missing?
No.
That isn't allowed. There can be no gaps in the ID numbers.

So remember this, because it's very important when it comes to understanding and controlling vertex order...

Any time you change the number of vertices in a mesh object, Maya automatically reorders the vertices!

It reorders the vertices so that the numbers start at [0] and so that there are no gaps in the numbers.

Don't believe me? Let's try it out.
Here I have a mesh:

As you can see, vertex [0] is here:
 

I'm feeling destructive. So now I'm going to delete that vertex. Pay attention to the IDs of the remaining vertices:
 



Maya automatically reassigns IDs so here will still be a vertex[0] on the mesh (there can't not be) but where each ID is after the vertices are reordered is up to Maya.

How Maya arranges the vertex IDs across the surface of the Mesh doesn't really follow any logic that we, the user, particularly care about. But Maya's pretty good at not shuffling things around more than is necessary. In the above example, since we deleted vert[0], Maya just subtracted 1 from every remaining vertex to fill in the gap.

Controlling vertex order

Maya does offer some tools to generally influence how you'd like the vertices to be laid out across an object's geometry. Such as Edit Mesh > Reorder Vertices, which allows you choose where Vertex[0] is and suggest a general directionality to the rest of the ID layout.

Rarely do we care that this vertex is vertex[42] specifically and that vertex is vertex[116] specifically. What do we care what number is assigned to a vertex? It doesn't effect its functionality. One vertex is as good as any other.

The only thing we do often care about is where the vertex order starts. That is to say, where vertex[0] is.

Why would we care about that?
Well please. Step right this way for the grooviest of examples...


No comments:

Post a Comment