Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix object positioning and other tweaks. #2

Merged
merged 3 commits into from Apr 13, 2019
Merged

Conversation

angavrilov
Copy link
Contributor

In order to place the objects it is necessary to properly accumulate
bone rest pose transforms in a matrix and apply it verbatim to the
objects. Also, even objects attached to bone 0 need this matrix.

To avoid decomposing, the matrix is directly baked into parent inverse.

Some especially bad cases this fixes:

evmap03_01.mxe (Varrot's office), evmap09_02.mxe (castle corridor),
evmap12_01.mxe (Bruhl mill plaza), evmap18_06.mxe (Marmota & castle)
valcC01aB_h.mlx, valcC04aB_h.mlx (head parts of some characters)
They have mixed case filenames, so try the original name first.
@gomtuu
Copy link
Owner

gomtuu commented Apr 8, 2019

Thanks! I'll take a look.

I've been working on import_valkyria recently to add VC4 support. I intended to revisit the bone calculations and normal vectors as well, but I hadn't gotten to them yet, so this is great timing!

@angavrilov
Copy link
Contributor Author

Basically it seems the most straightforward way of interpreting xform data works: convert it all to 4x4 matrices, multiply parent chains, and use the resulting matrix to place objects. It seems you were already doing it for location and rotation, but many environment objects depend on scale and it broke down. Also, the 0 bone was for some reason excluded for parenting, which broke trees and the mill tower.

@gomtuu
Copy link
Owner

gomtuu commented Apr 13, 2019

That makes sense! Not sure why I ignored scale.

Thanks again for the pull request!

@gomtuu gomtuu merged commit 0a8a076 into gomtuu:master Apr 13, 2019
@angavrilov
Copy link
Contributor Author

From the code it seems you may have been trying to "naturally" place the objects via transforms of bones themselves, and rest pose has no scale. I changed it to just compute the correct matrix in python and force objects to have that transformation no matter how the bone itself is placed.

gomtuu added a commit that referenced this pull request Apr 13, 2019
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.

None yet

2 participants