Home Technical Talk

Autodesk 3DS Maxscript: Resort Vertex Indexes While Retaining The Same Triangles?

polycounter lvl 6
Offline / Send Message
MrQuetch polycounter lvl 6
Hello, there.

I have noticed that there are already other threads that deal with sorting vertex indices in a specific order. But, these are meant to work from different axes or camera angles. I appear to have a different situation, although similar in this regard. Currently, I have a custom rollout in which I can select vertices and append them to a "bone". It's not a real bone, just an array containing those vertex indices. So, after I have appended specific vertices to specific "bones", I can then "build" the final data.

This part may sound a bit confusing, so I hope that I am making sense. Bare with me, as I will do my best to explain what is going on. Basically, the final built data creates Point Helpers in the positions of the vertices on the model, and are named depending on what their "bone" index is, the original vertex index of the mesh, and finally the actual numbered vertex index of the "bone".

Let's say I have three "bones" in my model. If I wanted to reference the second bone, the original vertex in the mesh pointing to the bone, and the last vertex index of the bone, the Pointer Helper's name would be "new_vertex_2_16_8" - where the bone index is 2, the vertex from the original mesh is 16, and the last vertex index in that bone is 8. That may not be clear, so I have another example. To reference just bone 3, the Point Helper's name would be "new_vertex_3..." and the original vertex index and the bone vertex index afterward. Now, one more example. If you wanted to reference the 4th bone, it's vertex index, and the 3rd vertex index of that bone, the Point Helper's name would be "new_vertex_4_2_3". In this case, the 2 is the current vertex index in the mesh.

What I want to do, is get the differences between the original vertex indices of the mesh, so I can map the "new" vertices in the places of the "old" ones - while retaining the same triangles. If that does not work, how would I be able to create new triangles (with the new indices) that match the old indices nicely? I have been trying this on my own already, but have had no progress for the past couple days - and figured it would be a good time to post.

So, what does all of this mean? The end result would be to have an articulated model. So, if you had a human, the torso would be the 1st bone, and the vertices of the hips would be declared first. The second bone would be the chest, and the vertices of the chest would be declared next. The same would go for every other part of the body. The vertex indices need to go along with that "bone".

I'm working on a very simple test model - practically a box. Once I can get it working, I'll move onto more complex models.

I hope I made sense of my question, and if not, I'll gladly give more examples. Any help at all is greatly appreciated.



Edit (9/21/2018): For anyone reading this, I have managed to find a work-around. Basically, I wrote my own program in a different language. Although, it could be done in "C", I used "GML". Using my custom exporter, I can now switch the indices of the actual vertices, while retaining the original order of the triangles.

Replies

Sign In or Register to comment.