Python maya.OpenMaya.MEulerRotation() Examples
The following are 3
code examples of maya.OpenMaya.MEulerRotation().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
maya.OpenMaya
, or try the search function
.
Example #1
Source File: spore_context.py From spore with MIT License | 5 votes |
def rotate_into(self, direction, rotation): """ slerp the given rotation values into the direction given by the brush_state @param direction MVector: the target direction @param rotation MVector: current euler rotation """ vector_weight = self.brush_state.settings['strength'] up_vector = om.MVector(0, 1, 0) local_up = up_vector.rotateBy(om.MEulerRotation(math.radians(rotation.x), math.radians(rotation.y), math.radians(rotation.z))) target_rotation = om.MQuaternion(local_up, direction, vector_weight) util = om.MScriptUtil() x_rot = np.radians(rotation.x) y_rot = np.radians(rotation.y) z_rot = np.radians(rotation.z) util.createFromDouble(x_rot, y_rot, z_rot) rotation_ptr = util.asDoublePtr() mat = om.MTransformationMatrix() mat.setRotation(rotation_ptr, om.MTransformationMatrix.kXYZ) mat = mat.asMatrix() * target_rotation.asMatrix() rotation = om.MTransformationMatrix(mat).rotation() return om.MVector(math.degrees(rotation.asEulerRotation().x), math.degrees(rotation.asEulerRotation().y), math.degrees(rotation.asEulerRotation().z))
Example #2
Source File: icon.py From mgear_core with MIT License | 5 votes |
def getPointArrayWithOffset(point_pos, pos_offset=None, rot_offset=None): """Get Point array with offset Convert a list of vector to a List of float and add the position and rotation offset. Arguments: point_pos (list of vector): Point positions. pos_offset (vector): The position offset of the curve from its center. rot_offset (vector): The rotation offset of the curve from its center. In radians. Returns: list of vector: the new point positions """ points = [] for v in point_pos: if rot_offset: mv = om.MVector(v.x, v.y, v.z) mv = mv.rotateBy(om.MEulerRotation(rot_offset.x, rot_offset.y, rot_offset.z, om.MEulerRotation.kXYZ)) v = datatypes.Vector(mv.x, mv.y, mv.z) if pos_offset: v = v + pos_offset points.append(v) return points
Example #3
Source File: sqSpaceSwitcher.py From dpAutoRigSystem with GNU General Public License v2.0 | 4 votes |
def _get_tm_offset(self, _nParent, _nDriven=None, _type="t"): """ Get the offset between the driven and a driver node """ if _nDriven is None: _nDriven = self.nSwConstRecept mStart = om.MMatrix() mEnd = om.MMatrix() wmStart = _nParent.worldMatrix.get().__melobject__() wmEnd = _nDriven.worldMatrix.get().__melobject__() om.MScriptUtil().createMatrixFromList(wmStart, mStart) om.MScriptUtil().createMatrixFromList(wmEnd, mEnd) mOut = om.MTransformationMatrix(mEnd * mStart.inverse()) if _type == "t": # Extract Translation vTran = om.MVector(mOut.getTranslation(om.MSpace.kTransform)) vTranPymel = [vTran.x, vTran.y, vTran.z] return vTranPymel if _type == "r": # Extract Rotation ro = _nDriven.rotateOrder.get() vRot = om.MEulerRotation(mOut.eulerRotation().reorder(ro)) vRotDeg = [math.degrees(vRot.x), math.degrees(vRot.y), math.degrees(vRot.z)] return vRotDeg