This is part 2 of "A Match Made in Bl00dy H3ll."
I've touched on the interaction of obj and bvh formats before, but now I'm really starting to use it more and more. Not really by choice, mind you, but two of the worlds i'm spending a lot of time with are using it.
To recap, Second Life uses the bvh format for creating custom animations, and Transmutable's Tomorrow Space is using a combination of obj and bvh files for its avatars. Since I'm building their avatars, I'm getting to know the format quite well. :)
So yeah, one of the quirks of this has always been the fact that the mesh is in a file on its own and the skeleton is in the same file as the keyframes. This is woogy. That's a technical term...Woogy.
So a big question mark that popped into my brainhole was "But how does the client handle vertex to bone assignments, how do you bind skin? With second life you can just assume that it's in the binary somewhere, but if you're doing something on your own you have to come up with your own solution.
So here comes the SMAP file. This is a small textfile that Trevor came up with to define the vertex to bone assignments. It's not complicated at all really, what I'm doing is using maya to bind the mesh to the skeleton using rigid bind, then exporting the bound skin as an obj file. This has advantages because the process of binding skin assigns the mesh vertices to a series of Sets based on the names of the joints they're assigned to. In the export process, the sets are interpreted as groups within the obj itself. And there you go, a bunch of tidy little groups that are created when the mesh is drawn.
Small problem with that though, the vertices are all assigned numbers after they're imported into the client, so if you need to call the specific numbers of vertices and bind them to the skeleton you're going to have a rough time.
Aint no thang but a chicken wang.
You can do two things in Maya to pull that list. The best way is to use a mel command that lists the members of the sets. You'll need to listSets, then listSetMembers in a loopyloop, then just paste that output into a text file.
Another way is a little more hacky and not too tidy. You'll have to turn on the Edit Membership tool and select a joint. As you know, the edit membership tool is a visual way in Maya to assign vertices to the bones using just shift to add and ctrl to remove vertices from the list. The key to that is that when you select a bone with the tool enabled the appropriate vertices. Then you can just do a ls -sl; to get the list of selected points. I did a thing that selects each bone in order and spit out the list without having to worry about doing it manually.