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

 lechoo03-27-2009, 09:26 AMHi, 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 http://forums.cgsociety.org/showthread.php?f=98&t=326704 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?
Dubbie
03-27-2009, 10:02 PM
I just solved this one on Friday.
I can send you my solution on Monday (your Sunday)

Dubbie
03-29-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
)
else
(
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
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])
)

lechoo
03-31-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-31-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.

1