View Full Version : PathDeform (OSM) - move object to path

03 March 2009, 09:26 AM
I have object with PathDeform modifier (object space) applied. Now I want to move object to path. Just like move to path in wsm PathDeform works. I've found similar problem here but this solution doesn't work in my case.

I know that I have to align objects transform with path's tangent at 0 like this:
dirVect = (pathTangent mySpline 1 0.0)
splineMat = MatrixFromNormal (normalize dirVect)

but there's always some unknown rotation around Z axis. I've tried different ways to calculate this rotation but no success. Any ideas how to solve this problem?

03 March 2009, 10:02 PM
I just solved this one on Friday.
I can send you my solution on Monday (your Sunday)

03 March 2009, 05:28 AM
This solution works ok for when you have created the spline in the top viewport.
YMMV when working with other cases. I just needed it to work for my case.

You'll probably need to modify it so it works in your circumstances.

fn vecAngle ref v1 v2 =
v1 = normalize v1
v2 = normalize v2
theCross = cross v1 v2

if ((dot theCross ref) > 0.0) then
tmpang = -Acos(dot v1 v2)
return 360 + tmpang
return Acos (dot v1 v2)

oCyl = $Cylinder01

for spl in $ do
cyl = copy oCyl
zVector = pathTangent spl 1 0.0
yVector = [0,0,1]
xVector = -(cross zVector yVector)

theMatrix = matrix3 xVector yVector zVector (in coordsys world( getKnotPoint spl 1 1))

cyl.transform = theMatrix
pdef = (PathDeform())
pdef.path = spl
addModifier cyl pdef
cyl.height = curveLength spl 1

fudge = vecAngle [0,0,1] [1,0,0] cyl.transform.row3
rotate cyl (angleaxis fudge [0,0,1])
rotate cyl (angleaxis fudge [1,0,0])
rotate cyl (angleaxis -90 [1,0,0])
rotate cyl (angleaxis -fudge [0,0,1])

03 March 2009, 06:12 AM
Thanks for posting your script. I've already wrote a script which works in some cases, just like yours. Problem is that it doesn't work in ALL cases.

CGTalk Moderation
03 March 2009, 06:12 AM
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.