The first thing I'd try is changing transformFunc.setRotation(quat) at the end to set to the whole matrix rather than just setting rotation:
transformFunc.set(tm) If I'm understanding right, the effect you want is that if the cube is at tx=10, and then you run the code, the cube will rotate around the origin. But the cube is only one node, it doesn't have a parent. Without a parent, rotating it around the origin means touching its translate as well. Beyond that there may be issues computing the matrix itself, but that's where I'd start. -e On Wed, Oct 3, 2012 at 2:23 AM, ianwaters <[email protected]> wrote: > Hi all, > > I am trying to rotate an object around world zero regardless of where the > object itself is, this is the code I have, it rotates the point around it's > centre, I'm clearly doing something wrong when it comes to setting the > rotate pivot to world zero... > > Just create a cube in an empty scene, and run the code below. > Any glaring errors? > > node = 'pCube1' > > selList = om.MSelectionList() > > selList.add(node) > > mDagPath = om.MDagPath() > > selList.getDagPath(0, mDagPath) > > transformFunc = om.MFnTransform(mDagPath) #node as transform function > > mTransformMtx = transformFunc.transformation() > > tm = om.MTransformationMatrix(mTransformMtx) #now we have a transformation > matrix > > worldZero = om.MVector(0,0,0) #place to move the rotate pivot > > tm.setRotatePivot( worldZero, om.MSpace.kWorld, 0 ) #move the rotate pivot > to worldZero > > quat = om.MQuaternion() #create a quaternion > > rotateValue = 60 #how far to rotate > > newTheta = math.radians( rotateValue ) #in radians > > quat.setToXAxis( newTheta ) #set rotation in the quaternion > > tm.addRotationQuaternion( quat.x, quat.y, quat.z, quat.w, > om.MSpace.kTransform ) #add to the transformation matrix > > > transformFunc.setRotation(quat) #set it > > > Cheers! > Ian > > -- > view archives: http://groups.google.com/group/python_inside_maya > change your subscription settings: > http://groups.google.com/group/python_inside_maya/subscribe -- view archives: http://groups.google.com/group/python_inside_maya change your subscription settings: http://groups.google.com/group/python_inside_maya/subscribe
