ZBrushCentral

Rotating an subtool to same angle as transpose line

Hi there,

I’m trying to script a tool that will figure out the angle in 3D space of the transpose line and then rotate a subtool to that same angle. I figured I would get the transpose start and end coordinates, use the pythagorean theorem to get the angle and then use the rotate deformer first in the Y axis from finding the angle on the XZ plane and then on the X axis on the YZ plane. However, this approach doesn’t actually seem to be working. I can’t seem to get the correct angle and even if I could, it seems that rotating on one axis and then another manually doesn’t actually get exactly the correct angle. here’s the code I have so far. I tried 2 different methods of getting the angle as you’ll see:

//get start, end and length of line
[If,[TransposeIsShown], [TransposeGet,StartXPos,StartYPos,StartZPos,EndXPos,EndYPos,EndZPos,ActionLineLength]
]

//find y angle
[varset,opplen,(startxpos-endxpos)]
[varset,adjlen,(startzpos-endzpos)]
[varset,yangle,atan(opplen-adjlen)]

//[IModSet,Tool:Deformation:Rotate,2]//rotate y
//[iset,tool:deformation:rotate,yangle]

//find x angle
[varset,xangle,acos(startypos-endypos/actionlinelength)]
[if,endypos<startypos,
[varset,xangle,neg(xangle)]
]
[IModSet,Tool:Deformation:Rotate,1]//rotate x
[iset,tool:deformation:rotate,xangle]

Any thoughts on how to get this to work? thanks

Hi Ryan,

Apologies for the delay in replying.

I think you might find Dargelos’ answers in this thread useful:

-Marcus