Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 13 Next capture
2021 2022 2023
1 capture
13 Jun 22 - 13 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by sgoodrow · May 19, 2014 at 06:02 AM · animationimportblenderblendkeyframes

Import Blender Animation without Unnecessary Keyframes?

This question pertains to importing animations into the legacy Animation system.

Whenever I import an animated mesh from Blender, be it using the built-in Unity FBX Importer (importing a .blend file), or the built-in Blender FBX Exporter (importing a .fbx file), the resultant AnimationClips have keyframes defined for all bones, even those that are not being animated. These bones have keyframes associated with their localPosition/localRotation/localScale and are flat linear curves -- they do nothing but hold the bone stationary.

Holding bones stationary breaks animation blending. All animation clips define animation states for every bone, so animations cannot fall through to lower layers. (Additive blending works fine, of course.)

Is there something I am missing in my export pipeline? In my import pipeline?

EDIT: I did some more research and tracked down a Blender Developer a lot more knowledgeable than me about this process. Ultimately, he told me that its not really possible if you're using IK. The IK propogate to other bones, which can themselves be under the effects of IK, and propogate further, etc, to the point where you have to distinguish between tiny floating point values and zero to know if the bone is being animated in an action or not.

He mentioned other constraints in the form of additional ways for a bone to be indirectly animated (drivers, unusual parenting with hinges, "etc"), which I did not understand but figured was worth mentioning.

So what are my options? I can duplicate an animation and remove the bones I don't think are animated in a given animation, and set up a Unity AssetPostProcessor which copies my imported animations to the target duplicate, inheriting the same bone rejection as before, or I can forfeit animation blending and depend on additive blending instead. For now, I think I will go with the latter, though I'm not happy about it.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Owen-Reynolds · May 19, 2014 at 02:40 PM 0
Share

A hack, if you can't get the import fixed (or if it just always animates all bones?), is to use Add$$anonymous$$ixingTransform. It tells an animation to only use certain bones.

1 Reply

· Add your reply
  • Sort: 
avatar image
0

Answer by Loius · May 19, 2014 at 02:58 PM

Back in blender 2.49 I had to rewrite their export script - it was export_fbx.py or something like that. Simple change once I figured out the language, just had to say "if no bone data continue" inside the bone's for-loop and everything worked out.

...

Looks like 2.6 still uses export_fbx.py. Might be able to find the issue by searching for 'animation' or 'bones'. I don't remember the specifics. :(

Edit: But I found them: http://answers.unity3d.com/questions/29802/playing-two-animations-from-one-armature.html

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image sgoodrow · May 20, 2014 at 07:47 PM 0
Share

Thanks Loius, this looks very promising. I am using a more recent version of Blender (2.7, 2014) than this refers to (??, 2010) and the export_fbx.py file has changed dramatically since then so I don't really know how to implement the suggested changes.

Any additional assistance would be greatly appreciated. :)

Here's the current export_fbx.py: http://pastebin.com/e0J3Gtx6

avatar image Loius · May 21, 2014 at 02:18 AM 0
Share

looks like this is replacement for the part i changed before:

            #for bonename, bone, obname, me, armob in ob_bones:
             for ob_generic in (ob_bones, ob_meshes, ob_null, ob_cameras, ob_lights, ob_arms):
  
                 for my_ob in ob_generic:
  
                     if ob_generic == ob_meshes and my_ob.fbxArm:
                         # do nothing,
                         pass
                     else:

It looks like blenName and blenAction still exist, soooo maaaaybe that last else could change to:

 elif ob_generic == ob_bones and my_ob.blenName in blenAction.getChannelNames():

crossed fingers

that'll probably disable all animation besides keyframed bones if it works

you need "if this bone's name is in the action's channel names"

avatar image sgoodrow · May 21, 2014 at 08:18 AM 0
Share

Thanks Loius, I appreciate the effort. That was the same conversion that I gathered to try, but getChannelNames is depreciated (no longer exists, to be precise). I tried to look around the API but didn't get much of anywhere.

Here is the Action object that blenAction represents, I think: http://www.blender.org/documentation/blender_python_api_2_68a_release/bpy.types.Action.html

Which has a collection member "groups", which has a collection member "channels". I tried to impart some python-fu to get at the same logic, assu$$anonymous$$g these channels are the same referenced by your getChannelNames (could be completely different), but ultimately couldn't figure it out.

avatar image Loius · May 21, 2014 at 03:02 PM 0
Share

It's possible that blenAction.groups' names is the old getChannelNames. Create a new array that is all of them together?

Unfortunately I barely know python. Something like this?

channelNames = [g.name for g in blenAction.groups]

If that's not it, it might be the .channels, which sould be something like this:

channelNames = [c.name for c in [g.channels for g in blenAction.groups]]

I just copied the syntax from that file, I hope it makes sense. x_x

avatar image sgoodrow · May 21, 2014 at 06:55 PM 0
Share

Did some more research and tracked down a Blender Developer a lot more knowledgeable than me about this process. Ultimately, he told me that its not really possible if you're using I$$anonymous$$. The I$$anonymous$$ propogate to other bones, which can themselves be under the effects of I$$anonymous$$, and propogate further, etc, to the point where you have to distinguish between tiny floating point values and zero to know if the bone is being animated in an action or not.

He mentioned other constraints in the form of additional ways for a bone to be indirectly animated (drivers, unusual parenting with hinges, "etc"), which I did not understand but figured was worth mentioning.

So what are my options? I can duplicate an animation and remove the bones I don't think are animated in a given animation, and set up a Unity AssetPostProcessor which copies my imported animations to the target duplicate, inheriting the same bone rejection as before, or I can forfeit animation blending and depend on additive blending ins$$anonymous$$d. For now, I think I will go with the latter, though I'm not happy about it.

Show more comments

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

22 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

importing destructible object from blender 0 Answers

Blender Scaling Import Problem. 1 Answer

Blender to Unity animations not importing correctly 1 Answer

Unity Partially Ignoring Blender Animation 1 Answer

Mecanim animation importing 2 Answers


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges