ray help

hello,

i have a ray created from two points.
i want the pivot of an object to be oriented as the ray.
(the z axis of the pivot to be oriented as the ray)

please help!

thanks,
mihai

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
panaitsdv's picture

OK, i think i found the

OK, i think i found the answer myself:

---- rotate pivot only function

fn RotatePivotOnly obj rotation= (
local rotValInv=inverse (rotation as quat)
animate off in coordsys local obj.rotation*=RotValInv
obj.objectoffsetrot*=RotValInv
obj.objectoffsetpos*=RotValInv
)

---- new ray from 2 points

newpos1 = [0,0,0]
newpos2 = [20,20,20]
vector_dir = ray newpos1 newpos2

---- create a transformation matrix from the ray

rowZ = normalize vector_dir.dir
rowY = [0,0,1]
rowX = normalize (cross rowY rowZ)
rowY = cross rowZ rowX
trfm = matrix3 rowX rowY rowZ [1,1,1]

RotatePivotOnly obj (trfm)

----- end of script

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.