Created
April 12, 2015 11:01
-
-
Save petfactory/6380b20da20753a775cc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import maya.api.OpenMaya as om | |
import pymel.core as pm | |
rot_order = 5 | |
kRotateOrders = [om.MEulerRotation.kXYZ, | |
om.MEulerRotation.kYZX, | |
om.MEulerRotation.kZXY, | |
om.MEulerRotation.kXZY, | |
om.MEulerRotation.kYXZ, | |
om.MEulerRotation.kZYX] | |
# this matrix will: | |
# translate 1, 2, 3 | |
# rotate 10, 20 ,30 | |
m_list = [ [0.813797681349, 0.543838142482, -0.204874128703, 0.0], | |
[-0.469846310393, 0.823172944646, 0.318795777597, 0.0], | |
[0.342020143326, -0.163175911167, 0.925416578398, 0.0], | |
[1.0, 2.0, 3.0, 1.0]] | |
m = om.MMatrix(m_list) | |
# construct a transformation matrix | |
tm = om.MTransformationMatrix(m) | |
# get translation and rotation from the matrix | |
t = tm.translation(1) | |
r = tm.rotation().reorder(kRotateOrders[rot_order]) | |
c = pm.polyCube()[0] | |
c.translate.set(t) | |
c.rotateOrder.set(rot_order) | |
c.rotate.set(pm.util.degrees((r.x, r.y, r.z))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment