DarklightGames / io_scene_psk_psa

A Blender extension for importing and exporting Unreal PSK and PSA files
GNU General Public License v3.0
378 stars 24 forks source link

Shrek 2 Animation Import causes model displacement and sometimes bones are not properly included. #83

Closed Karpai closed 6 months ago

Karpai commented 6 months ago

Versions Blender: 4.0 io_scene_psk_psa: 6.2.0

Describe the bug Character animations in Shrek 2 sometimes are missing bones and get positioned diagonally. Other characters from this game have similar issues. PIB's bones are all intact but Shrek's jaw is stretched.

To Reproduce Steps to reproduce the behavior:

  1. Import Shrek.psk
  2. Import Shrek.psa with one or more animations.
  3. Dope Sheet>Action Editor>Imported Animation.
  4. See Shrek rotated in a very odd way with his jaw stretched.

Expected behavior Shrek should be facing in a single direction when his animations are imported. Whether it should be X or Z axis I don't know. His jaw should be properly animated as well.

Screenshots Снимок экрана (57) Снимок экрана (58) Снимок экрана (59)

Files PSK and PSA files that I am using to encounter the bug: IssuesWithShrek2.zip

cmbasnett commented 6 months ago

The issue of the incorrect orientation is to do with how the add-on is interpreting the base bone's orientation. It doesn't just affect this particular rig. Any root bone that isn't facing down +X with +Z up will have issues. I believe I've fixed it locally, but will have to test it against more rigs before I push it up (probably will coincide with the Blender 4.1 compatibility release).

As for the face issues, I think there may be a couple missing pieces of the puzzle here. First off, the mouth bone itself is not named the same for some reason. The one in the rig (PSK) is called Mouth__joint, and the one in the animations (PSA) is called body_mouth_joint.

How was this PSK/PSA generated? Is there a .config file that goes along with this? If so, the .config file may be the key to fixing the mouth.

Karpai commented 6 months ago

configsandqr.zip All of the config files that I have exported with UModel seem to be empty. Umodel plays animations correctly without any issue despite still having Mouth__joint bone on the mesh.

cmbasnett commented 6 months ago

What's interesting about the mouth issues is that, if you rename the mouth_joint bone, the bone expression actions (AI, U etc.) all look correct. Only animations where the there isn't supposed to be face animations have the bones in the wrong spot. I would normally expect the config file to write out that these bones should be skipped for those animations.

I'm interested as to why there is a QC file, honestly. The QC file is a Source engine format. Is that being created by UModel as well?

Karpai commented 6 months ago

Yes .qc was generated by Umodel. Look at .qc file in notepad. It has all animation names, number of frames and framerates. MetallicaFan from Harry Potter Discord, the one who fixed 3ds Max plugin for ActorX says this: "KnowWonder somehow has duplicate bone names in their animations, and the script doesn't account for this. Unreal just ignores this and uses the first bone listed (the correct one) while the script effectively uses the last bone listed, so the scene bones are getting the wrong transformations." I don't know if this is relevant. 3ds max with his fix displays models correctly. This program is too heavy for my pc, so I can't work with it.

cmbasnett commented 6 months ago

@Karpai Are you using a special version of UModel to export this file? Like this one? (https://www.gildor.org/smf/index.php?topic=8304.0)

Karpai commented 6 months ago

If it is ACL 2.1 by spiritovod, it didn't make any difference when exporting. Config files are empty.

cmbasnett commented 6 months ago

I've fixed at least the issue of the root bone being in the wrong position with v6.2.1. Please give it a shot and let me know how it works for you.

I don't believe that I can really fix the other issue of the bones not actually being properly mapped between the PSK and PSA; this seems like an issue with the files themselves.

Karpai commented 6 months ago

https://github.com/DarklightGames/io_scene_psk_psa/issues/85#issuecomment-2016641742 As Spantle has mentioned. This plugin fixes the bone but has displacement. pls-fix Can you incorporate whatever is there to fix the issue?

cmbasnett commented 6 months ago

I had a look at their logic vs. this add-on and I think I've discovered the issue and why it works on the other add-on.

In this add-on, because the name of the face mouth bone fails the look-up, it treats all the child bones of the mouth joint bone as a root bone (one with no parent). This is technically incorrect. The other add-on, however, simply uses the parent bone from the armature imported in the PSK, even though the names don't match. This is arguably also incorrect, but at least it's incorrect in a way that achieves the desired result in this case (and probably most other cases as well).

The offending code is here:

https://github.com/DarklightGames/io_scene_psk_psa/blob/master/io_scene_psk_psa/psa/importer.py#L191-L192

I'll look at fixing this as soon as possible.

cmbasnett commented 6 months ago

Please download and try out the latest pre-release version (v6.2.1, I updated it to include the fix for this). Let me know if it all looks good. I checked it myself and the mouth now looks mostly correct except some of the expressions look a bit over-exaggerated but I don't know if there's anything I can do about that.

Karpai commented 6 months ago

I checked other models and while most of them work great, some have errors: IssuesWithShrek2.zip

Donkey and Steed are especially bad. And it seems like the other plugin does not fix this issue. Steed

cmbasnett commented 6 months ago

The remaining issues here seem like they are problems with the files to begin with and not the addon, so I'm going to close this issue. Thank you for the report!