Home Website Youtube GitHub

Changing Joint Orientation on Components

Hi everyone,

I am using mGear to rig for a Unity project I am working on. We are using multiple plugins that require our skeleton to have all our joints oriented in Z forward, Y up, and X to the side. While my global joint, as well as the rest of my centrally located joints are conforming to this orientation after building from selection, my legs, feet, arms and hands are all using Y forward, X up, and Z to the side.

Is there any way for me to change this in the rig building process? And if not, is there an easy way for me to change it afterwards that doesn’t entail un-constraining all the controls, reorienting the joints, then re-constraining the controls?

Thanks in advance for the help!

Hi welcome,

What is your experience level with scripting?

Whether or not you have access to the code of your plugins, you do have access to the code of mGear. I don’t think many of the Shifter components have options like that in the guides. But inside the code, for example in chain_01/__init__.py you’ll find:

self.normal = self.guide.blades["blade"].z * -1
self.binormal = self.guide.blades["blade"].x

And later some different methods use those components to orient things relative to the blade orientations of the guides. example:

transform.getChainTransform

I’d recommend cloning the components you want to edit and renaming them as your own custom components. You can then load them using MGEAR_SHIFTER_COMPONENT_PATH = P:\Your\Path\Here\mgearCustomModules

Thank you! I have a bit of Python experience, but not much more than that. I’m mostly on the artist side, with more experience in visual coding. I understand what you’re talking about with the blade orientations, it was very useful on my spine, neck, and shoulder creation. If I understand you correctly, I will need to add

self.normal = self.guide.blades[“blade”].z * -1
self.binormal = self.guide.blades[“blade”].x

as well as any methods that reference the above to each duplicated component I want blades on. And in the correct location. Would I be able to mimic the location of these methods between chain_01/init.py and any other component, or do I need a more advanced understanding of the code to find the correct place?

Well I’m not sure what you mean by “add” or “mimic”. I’m talking about editing the existing components. You almost sound like you meant writing new ones?

In most, or all of the components, those are just some of the places to look where the orientation is set. So you can just edit them to get the orientation you need. “Just”. It might not be that easy. And you might have to edit lots of details throughout the script. But that is the first place to look. You might certainly need a more advanced understanding to do this. Or at least a lot of trial and error.

I can suggest one other hacky way that involves less scripting, but is less build friendly, and could be troublesome if you have tons of characters, or lots of rebuilds to do to your guides.

  • Duplicate every skinning joint and make a separate hierarchy of just bones.
  • Name them identically, but maybe put them in a namespace or use a suffix.
  • Orient them as you wish. They are not connected to anything in the rig.
  • Constrain them to the rig joints. Should be an easy script since the names should match.
  • Bake and export that separate skeleton to engine.

Oh, sorry for being a little confusing. When I say add or mimic, I mean copy various lines from the chain_01/init.py script and add them to a duplicated version of the existing components. Hopefully it doesn’t take too much trial and error to figure it out, but I guess I should expect a lot.

If I can’t get this to work, I’ll try the hacky way. Or post my changes and hopefully someone will be able to help me with the things I missed.

Thanks so much for your help! If you have any other tips for me, I’d welcome them with open arms!

Hi Chris,

So after a full day of searching and testing various solutions, I am still having problems with this working correctly. I have been able to add the blade itself to the leg_2jnt_01 component, but changing the Blade Roll Offset value just rotates the joints as a whole, and not the actual orients. I have also found the joint generation portion of the code in the shifter/component/init.py file, but was unable to find a way to alter the orients from there as well.

Do you have a better idea of where the orientations are being set in the leg components? transform.getChainTransform does not exist in this location, and there are quite a few different transform.“etc” that I have tried to switch up to change the orients, but to no avail.

Hi Nathan,

Sorry, there is really no easy answer to this. You are right. The blades cannot reorient the joints. They just spin them. But that isn’t what I was talking about.

The binormal and normal attributes in the component code create vectors relative to the blade. And those orientations are used to create transforms or matrices when orienting things in the rest of the code.

The kind of changes you would need to make would look more like this: (These are not values I am suggesting that would solve your problem! You would have to figure out the vectors relative to your blades, accordingly.)

Original:

self.normal = self.guide.blades[“blade”].z * -1
self.binormal = self.guide.blades[“blade”].x

Modified

self.normal = self.guide.blades[“blade”].x * 1
self.binormal = self.guide.blades[“blade”].y

And for some components that might just be the start of your work. Because there would be other stuff you’d need to orient as well.

Your other option is changing your Unity plugins to not require specific orientations. (Can you say what kind of plugin functionality needs to be aware of joint orientations? Maybe you can change or ditch that plugin.)

1 Like