Hello,
I'm trying to mirror a Character Object pose on the XY plane. I would like to assign the rotation of each shoulder to the other. The script in effect would look like this: Mirror.gif
I have read the API documentation on Matrix Fundamentals. Here's what I've tried so far:
- Setting the matrices of each shoulder with the other shoulder multiplied in X by -1. The rotations were incorrect because (I think) the shoulders' Z axes are different.
import c4d
def main(doc):
doc.StartUndo()
lShoulder = doc.SearchObject("L_FK_Shoulder_con+")
rShoulder = doc.SearchObject("R_FK_Shoulder_con+")
rMat = rShoulder.GetMg()
lMat = lShoulder.GetMg()
rMat.v1 = c4d.Vector(lMat.v1[0]*-1,lMat.v1[1],lMat.v1[2])
rMat.v2 = c4d.Vector(lMat.v2[0]*-1,lMat.v2[1],lMat.v2[2])
rMat.v3 = c4d.Vector(lMat.v3[0]*-1,lMat.v3[1],lMat.v3[2])
rMat.off = c4d.Vector(lMat.off[0]*-1,lMat.off[1],lMat.off[2])
lMat.v1 = c4d.Vector(rMat.v1[0]*-1,rMat.v1[1],rMat.v1[2])
lMat.v2 = c4d.Vector(rMat.v2[0]*-1,rMat.v2[1],rMat.v2[2])
lMat.v3 = c4d.Vector(rMat.v3[0]*-1,rMat.v3[1],rMat.v3[2])
lMat.off = c4d.Vector(rMat.off[0]*-1,rMat.off[1],rMat.off[2])
doc.AddUndo(c4d.UNDOTYPE_CHANGE, lShoulder)
lShoulder.SetMg(rMat)
doc.AddUndo(c4d.UNDOTYPE_CHANGE, rShoulder)
rShoulder.SetMg(lMat)
c4d.EventAdd()
doc.EndUndo()
if __name__=='__main__':
main(doc)
- I found Matrix.invert(), but that seems to be inverting every item in the Matrix.
- I tried the code in this example from the forum, but it mirrors all axes and keeps adding rotation to the original matrix (ending up with rotations of thousands of degrees).
Mirror a matrix over a defined plane.
Can anyone help me to understand how to mirror on XY with two objects please?
Thank you!!