PDA

View Full Version : 'rotate pivot only' for dummy(rdg)


rdg
07-05-2005, 07:23 PM
Hello,

I went almost insane this afternoon trying to rotate only the pivot of an object via maxScript. After hours of pain caused by offsetobjectrotation-matrix3-paranoias, I found
worldalignpivot (), which was in this particular case just the right answer [3].

But during my travels through the waste land of Node Transform Properties, I stumbled across this:

Given you have an object which has a already translated pivot and this pivot doesn't fit your needs [1].
You want to set the rotation of the pivot to an absolute value and this value is not same as woldalignpivot().

I searched high and low in this forum and the maxhelp files, but haven't found a solution:
The script posted by LFShade [2] rotates the pivot, but also displaces the object.
The script in the maxhelp file "RotatePivotOnly" works with relative cummulative rotations.

I don't have inverse quats for breakfast, so my workaround is propably unaestithic, but it here it is:



-- this is the fn from the helpfile
fn RotatePivotOnly obj rotation= (
local rotValInv=inverse (rotation as quat)
animate off in coordsys local obj.rotation*=RotValInv
obj.objectoffsetrot*=RotValInv
obj.objectoffsetpos*=RotValInv
)

-- this is the extension:
fn RotatePivotOnlyAbsolute obj rotation = (
-- capture current rotation
currentRot=obj.objectoffsetrot as eulerangles
-- not performance oriented readablity step
wishRot=rotation
-- calculate the difference
needRot=(currentRot as quat - wishRot as quat) as eulerangles
-- rotate only the pivot
rotatepivotonly obj needRot
)



To test it:
c=cylinder()
move c [10,20,50]
c.pivot=[5,23,34]
RotatePivotOnlyAbsolute $ (eulerangles 23 0 0)
RotatePivotOnlyAbsolute $ (eulerangles 0 0 0)


I am still very intersted in Node Transform Properties and someday I will understand how to manipulate the transform matrix.

In the meantime this will maybe help someone else.

Georg


[1] Someone in your workflow chain imports splines from autocad, rotates them from top-view to front-view and aligns the pivot in x to an special vertex. You have 3990 of these splines. You need to align all these splines to be perpendicular to another spline in specified steps with offsets to that spline. You ask yourself why there is this strange rotation offset ...
[2] LFShade's script: http://www.cgtalk.com/showthread.php?t=148364&highlight=rotate+pivot
[3] which gives prove that I didn't do my homework ...

CGTalk Moderation
07-05-2005, 07:23 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.