maxdeelb4 / blender-smd

Automatically exported from code.google.com/p/blender-smd
0 stars 0 forks source link

changing bone rotation in edit mode offsets animation exported to source filmmaker #49

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Import pyro_reference.dmx found in the source sdk content, with Y up axis
2. Rotate a bone in edit mode, using its head as the pivot center.
3. In pose mode, key one of the bones to create an action to export.
4. Export this action with Y up axis with target "Source Filmmaker."
5. Import player\hwm\pyro.mdl from tf_movies into source filmmaker.
6. Import the exported action.

What is the expected output? What do you see instead?
Expected: Pyro will be in the same reference pose in SFM as seen in blender
Instead: Pyro in SFM is in the reference pose, except for the bone that was 
rotated in edit mode.

What version of the product are you using? On what operating system?
Blender SMD Tools 1.5.1 on Windows 7 32bit

Please provide any additional information below.
Ideally you would somehow account for this bone rotation in edit mode before 
exporting. If that's not possible, I propose a different kind of "fix" that 
will work better than the current situation but won't work for people who want 
to modify bone rotation in edit mode.

Proposal:
It would be convenient if the bone tails pointed to children by default. It 
would make IK rigs easier to deal with, since there would (usually) be no need 
to rotate the bone in edit mode. My idea for bone tails would be something like 
this:

bone with no children: bone's tail points in same direction as its parent
bone with no children and no parent: bone's tail points in up axis
bone with one child: bone's tail points to its child's head
bone with multiple children: bone's tail points to the average of the vectors 
from the bone's head to each child's head

The right hand side bones of the tf2 dmx characters I import already show this 
kind of behavior. The left hand side bones seem to point in the direction of 
the parent instead of the child, which creates issues when trying to make IK 
rigs.

The length of the bone does not matter for this problem; it is only rotation of 
the bone (using its head as the pivot) in edit mode.

Thank you for all the hard work you put into this project. It really amazes me 
to see how many features are included in this addon.

Original issue reported on code.google.com by invitem...@gmail.com on 12 Sep 2012 at 5:56

GoogleCodeExporter commented 8 years ago
I can't compensate for changes to an skeleton against an unknown other skeleton.

I also can't realistically start doing crazy things with bone rotation. I used 
to rotate and connect bones with only one child, but then I realised how bad 
doing that was. The fact that rigging requires bones to be pointing in a 
certain direction is a flaw in Blender and it can't be overcome with an export 
script. :(

If you really want to fix this, your best bet is to keep an unmodified version 
of the "real" skeleton alongside your modified one. Then you would write some 
code which compensates for the differences, exports via the SMD Tools, and 
lastly undoes all of its changes.

Original comment by cont...@steamreview.org on 12 Sep 2012 at 6:27

GoogleCodeExporter commented 8 years ago
In case anyone is wondering what I did:
I have attached a script that adds a panel in the Armature tab of the 
Properties Window to copy animation between armatures.

How I set up the animation environment:
I duplicate the armature right after import and set it up with IK 
constraints/connected bones/etc. (Just don't change the hierarchy or bone 
names) It is important not to change the bone head positions (in edit mode) in 
your duplicated armature.

The transfer process is quite slow due to all the matrix multiplication and 
scene updates.

It's my first time writing a blender script, so I'm sure it can be improved.

Original comment by invitem...@gmail.com on 14 Sep 2012 at 6:34

Attachments:

GoogleCodeExporter commented 8 years ago
Wow, nice work!

Original comment by cont...@steamreview.org on 14 Sep 2012 at 7:30

GoogleCodeExporter commented 8 years ago
Thanks! :)

Original comment by invitem...@gmail.com on 14 Sep 2012 at 8:03

GoogleCodeExporter commented 8 years ago
My script was going so slow because of all the keyframe_insert calls. I 
modified your script (attached) to account for the differences in bone tail 
locations. 

Workflow:
Import dmx file (e.g. medic_morphs_high.dmx).
Duplicate the armature upon import, and name it whatever the old one was with a 
_ref at the end. (e.g. 'pyroInfo' becomes 'pyroInfo_ref') Hide it so it doesn't 
interfere with selecting bones.
Select the original armature in object mode and run rig_biped_simple.py 
(attached) on it. (You can rig it however you want as long as the hierarchy, 
bone names, and bone heads stay the same.)
Animate the armature.
Bake the animation using Blender's "Bake Action" feature.
Export the action on the armature. 

This is much faster than using my script.
Perhaps you can add a button in the export panel that says "Reference 
armature:" and then a drop down box to select a reference armature. Of course, 
this drop down box can be left blank.

Original comment by invitem...@gmail.com on 16 Sep 2012 at 2:52

Attachments:

GoogleCodeExporter commented 8 years ago
Sorry, but I'm still not keen on the idea of implementing this sort of generic 
functionality into a format-specific export script.

I've spent a bit of time looking into this problem today and there are already 
solutions provided by Blender: 
wiki.blender.org/index.php/User:Benjycook/GSOC/Manual

Original comment by cont...@steamreview.org on 16 Sep 2012 at 10:48

GoogleCodeExporter commented 8 years ago
I tried out the motion capture tools, but they seem too specialized for the 
simple task of recalculating bone matrices based on tail position. The 
animations were warped when I retargeted them. I guess I wasn't using it 
correctly.

I know you won't change your script or anything, but I have changed it again so 
that the user can edit the bone tails on the imported armature without having 
to do any additional work to fix the animation. I add some extra matrix data to 
the armature upon import (like this smd.a['ref_matrices'] = 
getReferenceMatrices()) I didn't change smd export, just DMX.

This should be useful for people trying to animate dmx characters for source 
filmmaker. If there were some faster alternative to keyframe_insert in my 
armature transfer script, I wouldn't bother changing your script in the first 
place.
This page explains why my armature transfer script was so slow:
http://web.archiveorange.com/archive/v/1bjALe7UdM9tp50ioV9i
aligorith encourages baking to go the other way, so that's what I did. 

Thanks for all your suggestions. I understand this change doesn't really fit in 
with the smd tools addon, but hopefully someone else will find this version of 
it useful.

Original comment by invitem...@gmail.com on 17 Sep 2012 at 12:35

Attachments: