bvh import improvement - rotate 90 degrees on import #26599

Closed
opened 2011-03-24 19:33:37 +01:00 by Benjy Cook · 7 comments
Member

%%%A small fix, suggested by ideasman_42. Adds a check box to the import dialog if the user wants to rotate the animation around the X axis.
This is very useful, as most motion capture animations import sideways (see screenshots).
Works for both Armature and Object (empties) importing.

Attached is a diff file (created from \blender\release\scripts\addons, on main repo that's https://svn.blender.org/svnroot/bf-extensions/trunk/py/scripts/addons)
Also attached are the actual 2 script files I changed, in case you want to apply that way.
And a few screenshots showcasing the added functionality.

Cheers,
Benjy Cook%%%

%%%A small fix, suggested by ideasman_42. Adds a check box to the import dialog if the user wants to rotate the animation around the X axis. This is very useful, as most motion capture animations import sideways (see screenshots). Works for both Armature and Object (empties) importing. Attached is a diff file (created from \blender\release\scripts\addons, on main repo that's https://svn.blender.org/svnroot/bf-extensions/trunk/py/scripts/addons) Also attached are the actual 2 script files I changed, in case you want to apply that way. And a few screenshots showcasing the added functionality. Cheers, Benjy Cook%%%
Author
Member

Changed status to: 'Open'

Changed status to: 'Open'

%%%Looking over the patch a few things I noticed...

  • Looks like your using an older version of blender for development, please use recent graphicall build
(to_matrix() -> rotation_part(), registration changes).
  • The patch makes unrelated changes, eg:
  • bone.tail = bone.tail - ofs
  •                bone.tail = bone.tail + ofs
    
    • snip
  • print("\tzero length node found:", bvh_node.name)
    • snip
  • To support reload properly, try to access a package var, if it's there, reload everything

    • snip
  • bl_options = {'REGISTER', 'UNDO'}

This gives more work to review the patch because I cant tell what you modify is important or not, but UNDO for instance is important, some of the other changes too.

As for the actual patch, IMHO would be best if the import/export operators create a 3x3 matrix and pass this on, the 3x3 matrix can be created the same way you are doing now, but it allows for easier extending later on without having to add more keyword arguments, (FBX does it this way).%%%

%%%Looking over the patch a few things I noticed... * Looks like your using an older version of blender for development, please use recent graphicall build ``` (to_matrix() -> rotation_part(), registration changes). ``` * The patch makes unrelated changes, eg: - bone.tail = bone.tail - ofs + bone.tail = bone.tail + ofs - snip - print("\tzero length node found:", bvh_node.name) - snip - # To support reload properly, try to access a package var, if it's there, reload everything - snip - bl_options = {'REGISTER', 'UNDO'} This gives more work to review the patch because I cant tell what you modify is important or not, but UNDO for instance is important, some of the other changes too. As for the actual patch, IMHO would be best if the import/export operators create a 3x3 matrix and pass this on, the 3x3 matrix can be created the same way you are doing now, but it allows for easier extending later on without having to add more keyword arguments, (FBX does it this way).%%%
Author
Member

%%%Campbell,
Thank you for your detailed response.
I shall work on these notes and hope to have an updated patch in the next few days.%%%

%%%Campbell, Thank you for your detailed response. I shall work on these notes and hope to have an updated patch in the next few days.%%%
Author
Member

%%%Updated diff file and scripts uploaded, suffixed with _2.

I apologize for using an out-of-date version. Rookie mistake. All that is fixed now, I worked on the latest revision (1736).
Now a global matrix is created in the init script, according to user choice and applied later to the skeleton.
Scale is still done with the global_scale variable and not this matrix, unlike fbx. But that's for another patch.

Also, file.close() was added at the end of bvh_read.%%%

%%%Updated diff file and scripts uploaded, suffixed with _2. I apologize for using an out-of-date version. Rookie mistake. All that is fixed now, I worked on the latest revision (1736). Now a global matrix is created in the __init__ script, according to user choice and applied later to the skeleton. Scale is still done with the global_scale variable and not this matrix, unlike fbx. But that's for another patch. Also, file.close() was added at the end of bvh_read.%%%
Author
Member

%%%Updated diff file, suffixed with _3.

Now rest pose is changed, and object export supports the fix.
The code is slightly bulkier, because other approaches resulted in many bugs and artifacts across different bvh files.
For objects, root bones receive the transform.
For armatures, at the end of the original process, all bones are disconnected from their parents, rotated around their center, and reconnect to the original parent.
While sounding strange, this copies the animation perfectly.

For your review, Benjy%%%

%%%Updated diff file, suffixed with _3. Now rest pose is changed, and object export supports the fix. The code is slightly bulkier, because other approaches resulted in many bugs and artifacts across different bvh files. For objects, root bones receive the transform. For armatures, at the end of the original process, all bones are disconnected from their parents, rotated around their center, and reconnect to the original parent. While sounding strange, this copies the animation perfectly. For your review, Benjy%%%

%%%the functionality is in trunk now. closing.%%%

%%%the functionality is in trunk now. closing.%%%

Changed status from 'Open' to: 'Archived'

Changed status from 'Open' to: 'Archived'
Sign in to join this conversation.
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender-addons#26599
No description provided.