z64utils / z64convert

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

(MM Models) Masks appear in the wrong place

MoriyaFaith opened this issue · comments

When a model is converted from objex2 to zobj by z64convert, something happens where masks in MM get attatched to the wrong place, being located at the base of the neck rather than the head. I know this isn't an issue with my model since a template for MM models (admittedly made for the old pipeline) has the same effect. This could also be an issue with the Objex2 exporter, since zzconvert also seemed to caused this problem, but I'm putting the issue here to at least have it get looked at in some regard.

Here's some images for reference.
image
image

Thanks for reaching out @MoriyaFaith! A working example you can reference right away is TP Link, which you can find in the z64playerRenderInit repo here: https://github.com/z64me/z64playerRenderInit/blob/master/example/tpLink/tpLink.blend It showcases (almost?) all of z64convert's (current?) feature set.

And here is how the Iron Boot is configured (screenshot + explanation):

image

  1. The Iron Boot is rigged to the player skeleton.
  2. In the Object Data tab...
    2.a NOSPLIT is enabled, which tells z64convert to convert the mesh as a single display list.
    2.b NOSKEL is enabled, which tells z64convert to not generate a skeleton from this mesh that is rigged to a skeleton.
    2c. LIMBMTX is enabled, which tells z64convert to write a matrix command which will adhere the mesh to the limb from the skeleton without relying on draw order or a skeleton.

Much like the Iron Boots, masks are anchored to bones using matrices. Which bone is referenced by which matrix depends on two things:

  1. The structure of the skeleton.
  2. Which bones within the skeleton have meshes assigned to them.

The latter is especially important when dealing with player skeleton replacements. As an optimization, bones without meshes assigned to them will not have matrices generated for them. This can lead to unexpected results regarding the matrix stack.

image

Returning to the TP Link example, you'll notice that certain limbs in the skeleton have placeholder triangles assigned to them. For instance, he doesn't have a torso or hat mesh, but triangles are used in place of these. This is to guarantee the matrix stack remains in the same order the game expects.

image

These triangles are discarded during the conversion process because they have "empty" materials assigned to them, so they don't appear in-game. However, the game still treats them as if meshes were assigned to them, and as a result, the matrix stack remains identical to what the game expects. But you don't have to manage your triangles this way. You can opt for infinitesimally small triangles that the player won't be able to see instead.

With all of that said: when doing a player model replacement, there are certain bones that the game expects meshes to be assigned to, and certain bones that it doesn't. If you happen to accidentally assign the Torso geometry to the UpperControl bone, for example, it may look fine both in Blender and in-game, but due to the matrix stack being shifted, things like masks may misbehave.

Try vetting your model against the TP Link sample file, or comparing the steps you followed to those in this tutorial: https://old.z64.me/guides/new-blender-play-as.html

If you're still having difficulty, feel free to upload your .blend file here so I can take a look.

Happy importing! 🥳 🎈

I already understood what to do about triangles. I had already made those dummy triangles for the Hat and Sheath, which were the main 2 bones I knew that needed to be there.
image
I also checked my bone assignments, which leave RootControl, LowerControl, and UpperControl unassigned, I think. Is there anything else that I would be missing? This specifically applies to most masks from Majora's mask, which aren't featured in .blend files. The masks that do appear in the right place are transformation masks and the bunny hood, most likely due to being handled differently.

Also, I've provided the .blend file in case that might have effected anything.

It's at https://github.com/MoriyaFaith/Z64O_Models/blob/main/Saria/adult/object_link_boy_new.blend.
There doesn't seem to be anything wrong with it on my end.

Upon inspecting your model, the culprit may be the Collar bone. Please try the following:

  • Unassign the vertices currently assigned to Collar.
  • Assign them to Torso.
  • Create a dummy triangle specifically for the Collar bone and assign its vertices accordingly.

That did not seem to work.
image
also, https://github.com/MoriyaFaith/Z64O_Models/blob/main/Saria/adult/object_link_boy.blend should work with z64 playas, since I'm testing with ModLoader64. Nothing there seemed to be an issue, so i was double checking here.

So me and z64me debugged this. It's something to do with z64convert and/or objex2. Theres nothing we can do atm to repair this issue, as the bug doesn't happen under the old pipeline