Search Unity

Loading and exporting .anim files at runtime

Discussion in 'Animation' started by smoketh, Jun 1, 2017.

  1. smoketh

    smoketh

    Joined:
    Sep 14, 2012
    Posts:
    29
    Alright, mecanim keeps giving me really hard time.
    But ranting aside. .anim format itself presents another challenge altogether, due to complete lack of documentation on internal workings of mecanim.
    Here's the current problem i have - Animator permits SetBoneLocalRotation. Which is fine, however - .anim (yaml serialization) format itself (humanoid one, not generic/legacy) contains a set of curves which are muscle set tensors such as
    Code (CSharp):
    1. Spine Front-Back
    2. Spine Left-Right
    3. Spine Twist Left-Right
    4. Chest Front-Back
    5. Chest Left-Right
    6. Chest Twist Left-Right
    7. UpperChest Front-Back
    8. UpperChest Left-Right
    9. UpperChest Twist Left-Right
    10. Neck Nod Down-Up
    11. Neck Tilt Left-Right
    12. Neck Turn Left-Right
    13. Head Nod Down-Up
    14. ...
    ...And no way of setting those to animator. Could you, perhaps, provide a table of translating these into direct bone rotations? And also explaining why mecanim is STILL so rigid and under-exposed to scripting, after all this time?

    p.s. I mean, I do suspect that you compile animations and state machines into bytecode for sake of speed optimization, but don't tell me you could've not added JIT recompiler for them. This goes completely against every other piece of flexibility unity3d has to offer.

    p.p.s. Or is SetBoneLocalRotation for legacy/generics only, and humanoid is completely sealed beyond a rigid wall?
     
    lacas8282 likes this.
  2. smoketh

    smoketh

    Joined:
    Sep 14, 2012
    Posts:
    29
    Desperate bump
     
  3. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
  4. smoketh

    smoketh

    Joined:
    Sep 14, 2012
    Posts:
    29
    Oh, hey. this is actually useful. however - there is another problem with this - you see - Left Upper Leg In-Out, Left Upper Leg Twist In-Out, Left Lower Leg Stretch - these are not directly compatible with Quaternion rotations. Can you explain how to convert from one to another? like to example. twist in-out for the left side of body is reverse of one in right side of body?
     
  5. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
  6. smoketh

    smoketh

    Joined:
    Sep 14, 2012
    Posts:
    29
    Yes, but what if i'm building a tool to mix animations? I mean sure - i already handle loading, thanks to your post i now fully handle everything. However - i cannot take that prototype outside of unity because you walled off your algorithm.

    I mean - does it really matter that you spill out that part of properitary information? it's still only compliant with unity mecanim. On the other hand it will help me (and potentially anyone else) to build a service system compliant with unity.
    Or even - build a better, more open mecanim for unity to begin with and sell it as 3rd party asset (because as I've mentioned - rigidness is awfull)

    p.s. and no you don't go out of work either, since you can suck-in all the improvements into your own system, just like unity3d does with most of the best assets (textmeshpro, ngui), you're still gonna have support and development role.
     
  7. smoketh

    smoketh

    Joined:
    Sep 14, 2012
    Posts:
    29
    Ok, i have few questions regarding yaml serialiation itself actually.
    1. m_ClipBindingConstant: what is this?
    2. Why does it mirror it's own curves with m_EditorCurves ?
     
  8. Mecanim-Dev

    Mecanim-Dev

    Joined:
    Nov 26, 2012
    Posts:
    1,675
    We have no plan to publish it and it not because it proprietary information but because it complex and would need a lot of love before it could be published and we simply don't have the bandwidth for this.

    this is all the baked bindings for a clip which tell us which animation curve map to which unity component attribute.

    Editor curve like the name imply are not serialized for standalone build, they are all stripped when we do build for the player
     
  9. smoketh

    smoketh

    Joined:
    Sep 14, 2012
    Posts:
    29
    Well. this all was successful. Biggest boon of unity3d serialized yaml format is that it can be stripped to bare minimum you require, and rest will be filled with default variables. i've been able to build a working .anim exporter. And it works quite alright. So thanks again.
     
    lacas8282 and Mecanim-Dev like this.
  10. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    What about importing .anim files at runtime? Is this possible?

    (I've been googling for a while now and so far the answer appears to be "no"... or at least, not without getting down and dirty with the yaml format, as you have done... but I hope I'm missing something.)
     
    kaifu2 likes this.
  11. CaptainZSC

    CaptainZSC

    Joined:
    Oct 13, 2016
    Posts:
    3
    Hello forerunner,I meet the same problem now,I need to export .anim files at runtime too. Could you explain how you did it. Thanks for your help!
     
  12. JudahMantell

    JudahMantell

    Joined:
    Feb 28, 2017
    Posts:
    476
    I second this @smoketh ! Would you be able to share any progress you made on exporting anim at runtime?
    Thanks!
     
  13. manoletre99

    manoletre99

    Joined:
    Aug 22, 2016
    Posts:
    1
    Any progress on this would reallly help me, I am quite desperate
     
  14. lacas8282

    lacas8282

    Joined:
    Apr 25, 2015
    Posts:
    139
    I need to export anim curves eith muscles too. How to do that?
     
  15. lacas8282

    lacas8282

    Joined:
    Apr 25, 2015
    Posts:
    139
    So you just create the anim text file yourself not? I am trying that too.
    In this way I can createvthe muscle data, so the anim file parser can parse it
     
  16. lacas8282

    lacas8282

    Joined:
    Apr 25, 2015
    Posts:
    139
    Wow I created the exporter too. LOL. It was'nt so Hard...