Skip to content

Fix rotation problem#5

Open
TehLeo wants to merge 1 commit into
Nehon:masterfrom
TehLeo:patch-1
Open

Fix rotation problem#5
TehLeo wants to merge 1 commit into
Nehon:masterfrom
TehLeo:patch-1

Conversation

@TehLeo
Copy link
Copy Markdown

@TehLeo TehLeo commented Sep 18, 2018

The rotation was calculated as:
r.multLocal(rz).multLocal(rx).multLocal(ry);

Since it seems the order of the rotation matters, and it is specified in the bvh file, this line did not take that in account.
The proposed fix multiplies it in the order presented in the file.

The rotation was calculated as:
r.multLocal(rz).multLocal(rx).multLocal(ry);

Since it seems the order of the rotation matters, and it is specified in the bvh file, this line did not take that in account.
The proposed fix multiplies it in the order presented in the file.
@stephengold
Copy link
Copy Markdown
Contributor

I'll test this in my fork.

@stephengold
Copy link
Copy Markdown
Contributor

The BVH documentation specifies the order of rotation, so perhaps the order of presentation shouldn't matter:

A straightforward way to create the rotation matrix is to create 3 separate rotation matrices, one for
each axis of rotation. Then concatenate the matrices from left to right Y, X and Z.

vR = vYXZ

@stephengold
Copy link
Copy Markdown
Contributor

All my test cases present the rotations in Z-X-Y order. Where did you find a BVH using a different order?

@TehLeo
Copy link
Copy Markdown
Author

TehLeo commented Sep 18, 2018

I test the one here: https://sites.google.com/a/cgspeed.com/cgspeed/motion-capture/3dsmax-friendly-release-of-cmu-motion-database
Namely: Zip file for BVH directories 01-09

These files have both "Zrotation Yrotation Xrotation" and "Zrotation Xrotation Yrotation" within the same file.

@stephengold
Copy link
Copy Markdown
Contributor

I confirmed that 01_01.bvh uses different axis orders for different bones.

Then I tried loading 01_01.bvh both ways: using the classic/fixed axis order currently in this project and also with the axis order presented in the CHANNELS headers.

I expected to perceive a clear difference between the resulting animations. I expected one axis order to give plausible animation and the other to give garbage. But in fact both animations looked fine.

I'm puzzled. Perhaps I screwed up in my testing. Or perhaps there's something going on that I don't understand.

@TehLeo
Copy link
Copy Markdown
Author

TehLeo commented Sep 24, 2018

I was testing on the animations 09_**.bvh... eg 09_10.bvh

@stephengold
Copy link
Copy Markdown
Contributor

09_10.bvh also looks fine with either axis order. Still puzzled.

@TehLeo
Copy link
Copy Markdown
Author

TehLeo commented Sep 29, 2018

Let me make sure we are on the same page.

I ran TestBVHAnimation.java for file 09_10.bvh obtained from cgspeed 3ds Max friendly version.
I produced an image showing the results prior(left) and after the fix (right).

animtest

You can see a difference in leg motion. To see it more clearly, move/align your camera in front of the character.

@stephengold
Copy link
Copy Markdown
Contributor

Ah. I was expecting something less subtle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants