nogalo

Mesh weight data transfer from 3d software

Recommended Posts

Hi, 

I have a scene with three different characters (which can be switched based on what user pick), and I have about 17 animations (skeleton bones) which I need to be able to also switch based on user input. Now, to achieve that, I need to import different mesh for every animation, because I need correct weight data for those animated skeletons to work. Meaning I need to import 1st character * 17 times, 2nd*17, 3rd*17. Which becomes a lot, especially because I think there will be more animations in the future.  

Here is a demo version of the app. 
https://www.productexample.com/kittyTest/index.html

My question would be Is there a way, and if not would it be possible to somehow transfer only weight data from 3d software (3ds max in my case) so I can load for example only one 1st character mesh and then just change weight data when needed. 

Or if you have any suggestion on how can I do this without loading a bunch of meshes? 

Thank you.

Share this post


Link to post
Share on other sites

@nogalo, what you are describing is a common organizational issue in games. There are a couple of things you can do depending on your assets to load only three meshes total for all of your needs. 

If your characters are similar in form, say all humanoid bipeds, and share some animations you will want to use animation retargeting to reduce your mesh load. What this means is that all of your meshes need to share the same skeletal structure, both in heirarchy and naming, and you can pass an animation from one skeleton to another. That means you only need to include the animations in one of your incoming characters and then pass the animation clips to any other skeleton and the rotational information from the skeleton will work. You could even import a default character with all the animations that never is rendered on screen but allows you to add more character styles independently of your animation rig. Each individual character carries their own skin weighting so the joints on target models can even be in a different proportion than the default model so long as the animations take this variance into account (say one model has a longer torso or shorter legs). This is the most forward thinking path because it separates your animation pipeline from your character pipeline. 

The key to this is that you need to pack all of your animations in one timeline for export. I would leave blank frames in between each clip to eliminate interpolation errors, maybe 10 unkeyed frames between clips, in any order that makes sense to you. Once you have your timeline filled with all animations you will need (51 in your case if none are similar like walk or idle) export the file as normal. If you are using Maya, you can author your clips on export with the clip tool in Maya which you can find under the Babylon Menu:

MayaBabylonAnimations.png.3e7c1fe88cf1cb498ac689ae734b9619.png

Create a new clip for each animation, giving it a name and start/end frame. If you then drop your model into the Babylon.js sandbox, you will see the first animation in the list playing and have the ability to change to any animation with the drop down on the footer bar. 

If you aren't using Maya, you can manually create your clips as variables in your code which can be found in our animation docs. The best example of this is the animation blending example: https://www.babylonjs-playground.com/#BCU1XR#0

The other way to do this if you don't have shared animations is to keep each character's animation in their own file. This is the best path if you don't share character structure, as in one is a biped and another is a quadruped. This makes each character file individually larger as you carry the curve information in each file so you have a trade off for download of the characters. This makes the shared animation method more desireable if you can swing it, even if there is one more default mesh that holds all animations as your characters are more flexible and lighter on download.

This method is also useful if you want to vary up animations and have multiple idle animations that randomly sequence. Containing all clips in one file and randomly choosing one to play when the character idles will make your game feel more dynamic. 

I hope this helps point you in a direction that allows you to get the most flexibility out of your characters and still not have to load more meshes than you need. Please let us know if you have more questions or want us to take a look at a sandbox for you. Take care!

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

  • Recently Browsing   0 members

    No registered users viewing this page.