Jump to content
  • Advertisement
Sign in to follow this  
ldeej

Maya API (setting bone weights)

This topic is 4611 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Not sure if this is the right forum for this, but maybe my chance of getting an answer here is higher since I assume that graphics programmers had to create the importers for their graphical assets :-) Here is my problem. I am writing a Maya importer for some assets on an intermediate format. Meshes and bones are imported correctly, but now I am dealing with setting bone weight data into the vertices. I build the node hierarchy and then try to deal with skinning. Unfortunately it does not seem like there is an easy way to do this from the C++ Maya API. I end up calling a MEL command (newSkinCluster) to create the cluster, and start setting the weights on the vertices doing some crazy work, and resetting weights for bones that Maya had set automatically. Does anybody know of a better way to do this?

Share this post


Link to post
Share on other sites
Advertisement
yeah, i ignore Function sets when importing skin weights. The easiest (and AFAIK only reliable) way of doing it is to manually create the data on the skin cluster attributes.

Just check the node and attribute reference for info about how the weights are stored, use MPlugs and MFnDependency node to create the arrays. You'll still need mel script though (ie, resizing attribute arrays via setAttr -s).

As a side note, it's pretty much impossible to avoid mel script when importing data. You *can* do it without mel, but it'll take you a long time to get right (i.e. never). It's also worth noting that mel does save you an awful lot of time, for example, i could create the skin cluster nodes manually, and then connect up all attributes, or i could just use the skinCluster mel command.... (newSkinCluster is a GUI mel proc, not a good idea to use it if you intend to run batch processes at any point without the GUI).

Another little trick that may be of some use, is to disable mel's undo queue during the import, and re-enable after import has finished. It gets around the rare (but ever so painful) occasions when people have an infinite undo queue set (lets just say that the individual calls to mel commands to say import a skinned mesh creates a hell of a lot of undo info - basically a huge memory leak).

But yeah, generally importing is harder to get right than exporting....

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!