[Closed] lookat constraint with path constraint
Hello again,
I have the following code:
(
delete $*_Clone_*
theSource = cylinder radius:1 height:15 sides:18 pos:[90, -90, 0] wirecolor:[255, 0, 0]
theMesh = snapshotAsMesh (plane width:100 length:100 widthsegs:5 lengthsegs:5 wirecolor:[0, 255, 0])
theAttractor = Sphere radius:3.5 wirecolor:[0, 0, 255] pos:[0, 0, 50]
vecLength = 5.0; theWeight = 200.0
undo off
(
for v = 1 to theMesh.numverts by 1 do
(
newObj = instance theSource
newObj.name = uniquename (theSource.name +"_Clone_")
theNormal = (getNormal theMesh v)
theX = normalize (cross theNormal theSource.dir)
theY = normalize (cross theNormal theX)
newObj.transform = matrix3 theX theY theNormal (getVert theMesh v)
theConstraintParam = LookAt_Constraint lookat_vector_length:vecLength pickUpNode: theAttractor upnode_world:false relative:false
theConstraintParam.target_axis = 2
theConstraintParam.upnode_axis = 0
theConstraintParam.StoUP_axis = 2
theConstraintParam.appendTarget theAttractor1 theWeight
newObj.rotation.controller = theConstraintParam
)
)
)
It populates a plane’s surface (on every vertex) with a series of instances of a custom object (a cylinder). Then it applies a lookatconstraint so that each object’s rotation is constained according to an attractors position (in this case the attractor is a sphere).
The code works fine. Then I wanted to add a path constraint modifier to the sphere so that I could animate the position of the sphere more interactively and have the cylinders rotate accordingly. But once I create a custom spline/path, and add a path constraint modifier to the sphere, the previous dependency (created because of the lookatconstraint) between the sphere, and the cylinder’s rotation, is lost. How can I preserve this dependency ?
what is the Path Constraint Modifier?
probably we talk about controller
and it works fine for me
(
delete objects
theSource = createinstance cylinder radius:1 height:15 sides:18 wirecolor:[255, 0, 0]
theMesh = snapshotAsMesh (plane width:100 length:100 widthsegs:5 lengthsegs:5 wirecolor:[0, 255, 0])
theAttractor = Sphere radius:3.5 wirecolor:[0, 0, 255] pos:[0, 0, 50]
spline = circle radius:40 pos:theAttractor.pos wirecolor:red
vecLength = 5.0; theWeight = 200.0
for v = 1 to theMesh.numverts by 1 do
(
newObj = cylinder baseobject:theSource
newObj.name = uniquename "Chilinder_Clone_"
theNormal = (getNormal theMesh v)
theX = normalize (cross theNormal newObj.dir)
theY = normalize (cross theNormal theX)
newObj.transform = matrix3 theX theY theNormal (getVert theMesh v)
theConstraintParam = LookAt_Constraint lookat_vector_length:vecLength pickUpNode:theAttractor upnode_world:false relative:false
theConstraintParam.target_axis = 2
theConstraintParam.upnode_axis = 0
theConstraintParam.StoUP_axis = 2
theConstraintParam.appendTarget theAttractor theWeight
newObj.rotation.controller = theConstraintParam
)
theAttractor.pos.controller = path path:spline
)
oh i’m sorry. I actually meant Path deform modifier !
Well yes, that is exactly what I wanted. As for me, I first run the code, then, I created a spline, and then I applied a pathDeform modifier to the attractor/sphere in order to do, what you just did with a single line of code. As a result, the previous dependency created by the code, was lost. For some reason, the cylinders ignored the existence of the sphere once I applied the modifier to the sphere. Why is that ?
it’s probably wrong using of things.
path deform modifier doesn’t change node’s transform, it changes node’s object (by moving its vertices)
check:
(
delete objects
theSource = createinstance cylinder radius:1 height:15 sides:18 wirecolor:[255, 0, 0]
theMesh = snapshotAsMesh (plane width:100 length:100 widthsegs:5 lengthsegs:5 wirecolor:[0, 255, 0])
theAttractor = Sphere radius:3.5 wirecolor:[0, 0, 255] pos:[0, 0, 50]
spline = circle radius:40 pos:theAttractor.pos wirecolor:red
vecLength = 5.0; theWeight = 200.0
for v = 1 to theMesh.numverts by 1 do
(
newObj = cylinder baseobject:theSource
newObj.name = uniquename "Chilinder_Clone_"
theNormal = (getNormal theMesh v)
theX = normalize (cross theNormal newObj.dir)
theY = normalize (cross theNormal theX)
newObj.transform = matrix3 theX theY theNormal (getVert theMesh v)
theConstraintParam = LookAt_Constraint lookat_vector_length:vecLength pickUpNode:theAttractor upnode_world:false relative:false
theConstraintParam.target_axis = 2
theConstraintParam.upnode_axis = 0
theConstraintParam.StoUP_axis = 2
theConstraintParam.appendTarget theAttractor theWeight
newObj.rotation.controller = theConstraintParam
)
addmodifier theAttractor (PathDeform path:spline axis:1)
theAttractor.pos.controller = path path:spline
)
probably you can animate vertices and use Point Master controller, but… there has to be a reason to complicate the rig
I think for my case there is no reason. The position controller is the best choice.
So, with lookatconstraint a transform dependency is established between two nodes. But pathDeform does not affect a node’s transform, thus the dependent nodes will not detect any change in order to act accordingly, right ?
the modifier should not change a node’s transform… that’s why you can do both animate and modify objects.
so no transform change – no transform change notification message – no lookat controller reaction.