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

Reply via email to