[Closed] PathDeform (OSM) – move object to path
Hi,
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?
I just solved this one on Friday.
I can send you my solution on Monday (your Sunday)
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
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])
)
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.