Community
Maya Animation and Rigging
Welcome to Autodesk’s Maya Forums. Share your knowledge, ask questions, and explore popular Maya animation topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Offset Parent Matrix automatically updating rotation values

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
aklapkaVPH49
948 Views, 7 Replies

Offset Parent Matrix automatically updating rotation values

aklapkaVPH49
Explorer
Explorer

Hi,

I am attempting to set up an FK leg rig using the new offset parent matrix feature in Maya 2023. I used Anthony Ward's video to set it up on my left leg and it works fine. However, when I mirror, I am unable to properly place my controllers as every time I try to input the correct rotational values to the joint, it will change other rotation values in the matrix automatically. I didn't run into this problem on the left limb and I have found no documentation or even mentions of this at all. Screenshots below.

 

I assume it has something to do with the orientation of my joints, the rotation order of my controllers, or maybe the rotational values of my curve are hitting gimbal lock. No idea how to fix it or even go about diagnosing the issue. Seems like right now I'm just going to have to go back to the old way of using offset groups.

 

aklapkaVPH49_0-1666848260736.png

aklapkaVPH49_1-1666848288782.png

 

Offset Parent Matrix automatically updating rotation values

Hi,

I am attempting to set up an FK leg rig using the new offset parent matrix feature in Maya 2023. I used Anthony Ward's video to set it up on my left leg and it works fine. However, when I mirror, I am unable to properly place my controllers as every time I try to input the correct rotational values to the joint, it will change other rotation values in the matrix automatically. I didn't run into this problem on the left limb and I have found no documentation or even mentions of this at all. Screenshots below.

 

I assume it has something to do with the orientation of my joints, the rotation order of my controllers, or maybe the rotational values of my curve are hitting gimbal lock. No idea how to fix it or even go about diagnosing the issue. Seems like right now I'm just going to have to go back to the old way of using offset groups.

 

aklapkaVPH49_0-1666848260736.png

aklapkaVPH49_1-1666848288782.png

 

7 REPLIES 7
Message 2 of 8
RPYTHON
in reply to: aklapkaVPH49

RPYTHON
Advocate
Advocate

Same trouble, eulers are automatically updated. Maya 2022.4

 

I have attached a simple scene as an example. Just try copying the rotate values into an offset parent matrix.

 

Is this problem solvable?

0 Likes

Same trouble, eulers are automatically updated. Maya 2022.4

 

I have attached a simple scene as an example. Just try copying the rotate values into an offset parent matrix.

 

Is this problem solvable?

Message 3 of 8
aklapkaVPH49
in reply to: aklapkaVPH49

aklapkaVPH49
Explorer
Explorer

So far, the only solution that I've found is to plug in the rotational values before adding the translate values. It's a bit silly and wonky, but it works.

0 Likes

So far, the only solution that I've found is to plug in the rotational values before adding the translate values. It's a bit silly and wonky, but it works.

Message 4 of 8
RPYTHON
in reply to: aklapkaVPH49

RPYTHON
Advocate
Advocate

This was the first thing I tried, as was change the rotation order. Doesn't work for me 😞

0 Likes

This was the first thing I tried, as was change the rotation order. Doesn't work for me 😞

Message 5 of 8
RPYTHON
in reply to: aklapkaVPH49

RPYTHON
Advocate
Advocate

Ok, it looks like there is a solution: just set key to the rotation channel. Then copy values to OPM, break connection, remove double transforms, etc.

Of course, then need cleanup 3 unnecessary animation curves, but these are trifles, all the same, it is more convenient to use MEL for setup things like this.

0 Likes

Ok, it looks like there is a solution: just set key to the rotation channel. Then copy values to OPM, break connection, remove double transforms, etc.

Of course, then need cleanup 3 unnecessary animation curves, but these are trifles, all the same, it is more convenient to use MEL for setup things like this.

Message 6 of 8
aklapkaVPH49
in reply to: RPYTHON

aklapkaVPH49
Explorer
Explorer

Interesting, I'll have to try this next time I'm working with the OPM. Hopefully we get a better solution from Autodesk soon.

0 Likes

Interesting, I'll have to try this next time I'm working with the OPM. Hopefully we get a better solution from Autodesk soon.

Message 7 of 8
RPYTHON
in reply to: aklapkaVPH49

RPYTHON
Advocate
Advocate

I wrote a little uh... "macro" that copies the transform values into the OPM. The idea is to pass the transformations to the OPM through holdMatrix node, which will avoid creating a looped graph. Surely better way to do this via xform, but I don't know how yet.

 

How to use: copy the contents of the file into the script editor as MEL, then drag it to the shelf as button. Select an object and click button.

Note: target object must have zero OPM values.

I wrote a little uh... "macro" that copies the transform values into the OPM. The idea is to pass the transformations to the OPM through holdMatrix node, which will avoid creating a looped graph. Surely better way to do this via xform, but I don't know how yet.

 

How to use: copy the contents of the file into the script editor as MEL, then drag it to the shelf as button. Select an object and click button.

Note: target object must have zero OPM values.

Message 8 of 8
Kahylan
in reply to: RPYTHON

Kahylan
Advisor
Advisor
Accepted solution

Hi!

 

As you mentioned, there has to be a better way using xform. And it looks like this:

import maya.cmds as mc
import numpy as np

sel = mc.ls(sl = True)

for s in sel:
    lM = mc.xform(s,q= True, m= True, ws= False)
    oM = mc.getAttr("{0}.offsetParentMatrix".format(s))
    lM = (lM[0:4],lM[4:8],lM[8:12],lM[12:16])
    oM = (oM[0:4],oM[4:8],oM[8:12],oM[12:16])
    mM = np.matmul(lM,oM)
    
    mM = [mM[0][0],mM[0][1],mM[0][2],mM[0][3],mM[1][0],mM[1][1],mM[1][2],mM[1][3],mM[2][0],mM[2][1],mM[2][2],mM[2][3],mM[3][0],mM[3][1],mM[3][2],mM[3][3]]
    
    
    mc.xform(s, t= (0,0,0), ro = (0,0,0), s= (1,1,1), os = True)
    mc.setAttr("{0}.offsetParentMatrix".format(s),*mM, type = "matrix")

 

Basically to find the values to put into your OPM, you just need to Multiply the local xform matrix of the object with it's current OPM.

 

This script will find those values and overwrite the OPM as well as zero out the transforms. It's a pythons script so it has to be run from a python tab.

 

I hope it helps!

Hi!

 

As you mentioned, there has to be a better way using xform. And it looks like this:

import maya.cmds as mc
import numpy as np

sel = mc.ls(sl = True)

for s in sel:
    lM = mc.xform(s,q= True, m= True, ws= False)
    oM = mc.getAttr("{0}.offsetParentMatrix".format(s))
    lM = (lM[0:4],lM[4:8],lM[8:12],lM[12:16])
    oM = (oM[0:4],oM[4:8],oM[8:12],oM[12:16])
    mM = np.matmul(lM,oM)
    
    mM = [mM[0][0],mM[0][1],mM[0][2],mM[0][3],mM[1][0],mM[1][1],mM[1][2],mM[1][3],mM[2][0],mM[2][1],mM[2][2],mM[2][3],mM[3][0],mM[3][1],mM[3][2],mM[3][3]]
    
    
    mc.xform(s, t= (0,0,0), ro = (0,0,0), s= (1,1,1), os = True)
    mc.setAttr("{0}.offsetParentMatrix".format(s),*mM, type = "matrix")

 

Basically to find the values to put into your OPM, you just need to Multiply the local xform matrix of the object with it's current OPM.

 

This script will find those values and overwrite the OPM as well as zero out the transforms. It's a pythons script so it has to be run from a python tab.

 

I hope it helps!

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report