Looking for a way in mel to constrain a transform to a vert.

Looking for a way in mel to constrain a transform to a vert.

malcolm_341
Collaborator Collaborator
2,299 Views
29 Replies
Message 1 of 30

Looking for a way in mel to constrain a transform to a vert.

malcolm_341
Collaborator
Collaborator

Hi there, I'm looking for a way to constrain a locator or other transform to a vert, I've tried all the constraints, but those only work on meshes that have non-overlapping UVs, I need this to work on meshes with overlapping UVs. Is there some secret mel trick to get the vert to drive the locator's transform?

Accepted solutions (1)
2,300 Views
29 Replies
Replies (29)
Message 2 of 30

malcolm_341
Collaborator
Collaborator

For clarity what I'm actually trying to do is constrain a CV from a curve to a vert from a mesh if anyone knows a solution. The mesh has overlapping UVs.

0 Likes
Message 3 of 30

zewt
Collaborator
Collaborator

Proximity Pin should be able to do that for you.  It takes an input locator and a deformed mesh, finds where the input locator is against the deformed mesh's original (undeformed) geometry, and gives you a locator that follows that position as the mesh deforms.  It's more complicated than uvPin which simply pins against a UV, but it doesn't require non-overlapping UVs.

 

Another option is to create a new UV set with non-overlapping UVs, and use that with uvPin.  You don't need to spend much time on the UV set since it's never used for rendering (it doesn't need to be pretty), just create a quick UV map and unwrap, and set the UV set name on the uvPin node.

 

0 Likes
Message 4 of 30

malcolm_341
Collaborator
Collaborator

Thanks for your suggestions, unfortunately the script needs to work in Maya 2017 so proximity pin and UVpin don't exist. As well, before posting I had tried creating a dummy UV set so the point on poly constraint would work, but that tool is hard coded to map1 which is not useful because the artist will do UVs there later, and if you copy the old UVs back after constraining it breaks the constraint. It's crazy to me that all these tools are UV based, how do animators make anything work in the games industry we use lots of overlapping UVs.

0 Likes
Message 5 of 30

mspeer
Consultant
Consultant

Hi!

 

You could add a cluster deformer on the vertex, then you have a transform node that can easily be controlled by an expression or a custom node network based on the position of any input like the CV of a curve.

(If you use an expression you don't need the cluster deformer.)

0 Likes
Message 6 of 30

malcolm_341
Collaborator
Collaborator

Thanks I tried that a couple days ago, but I need the cluster to be controlled by the vert so when I move the vert the cluster moves, cluster work the opposite way unfortunately where they move the vert, I couldn't find a hook up to do the opposite.

0 Likes
Message 7 of 30

mcw0
Advisor
Advisor

This is easy.  Convert your vert to edges.  Then pick any edge and convert to curve.  Now use the curve as a motion path for your locator.  Delete the uValue anim curve and set the correct value.  Done.

0 Likes
Message 8 of 30

mspeer
Consultant
Consultant

Hi!

 

The cluster controls the vertex of the mesh, sure, but then you can input the control vertex position of the curve to control the cluster by using the Node Editor.

It's a bit more complex, but it works.

Message 9 of 30

mcw0
Advisor
Advisor

I think he's trying to do the opposite.  Controlling the cv of a curve with a vertex on a mesh.  But definitely, expressions is one way to do this without any other nodes.  But expressions need to be evaluated.  I always prefer a node based solution over expressions.

0 Likes
Message 10 of 30

malcolm_341
Collaborator
Collaborator

@mcw0 

That just makes a locator on a curve, it doesn't help make the vertex drive the locator?

 

@mspeer 

I'm looking in the node network, it's quite complex, hooking up the verts transform to the locator doesn't have any affect or makes the locator jump to some random location.

0 Likes
Message 11 of 30

mcw0
Advisor
Advisor

The locator is on a curve, yes.  But the curve was derived from an edge.  And the edge is controlled by your vertex.  Move the vertex and the edge moves, changing the shape of the curve, moving the locator.

0 Likes
Message 12 of 30

malcolm_341
Collaborator
Collaborator

Oh wait, there was another curve in the scene it's attached now.

0 Likes
Message 13 of 30

mcw0
Advisor
Advisor

Keep history on.  You should get a polyEdgeToCurve node.  If not, you can create the node and set the inputComponents value to e.[your edge index] and connect the mesh shape as the input and the output to a nurbsCurve node.

0 Likes
Message 14 of 30

mcw0
Advisor
Advisor

This has been an issue for quite some time it appears.  🙂  
Here is a solution using an emitter node.

http://forums.cgsociety.org/t/vertex-world-position/1282241/19

0 Likes
Message 15 of 30

malcolm_341
Collaborator
Collaborator

Well I explored the curve method and that won't work because a curve has two points so the locator gets stuck to the wrong point.

0 Likes
Message 16 of 30

mcw0
Advisor
Advisor

You have to set the uValue of the motionPath.  Either 0 or 1.

0 Likes
Message 17 of 30

mcw0
Advisor
Advisor

If you don't want to use a motionPath, you can use a pointOnCurveInfo node.  That would eliminate the addDoubleLinear nodes that accompany the motionPath.  But you'd still have to set the parameter value.  Again, either 0 or 1.

0 Likes
Message 18 of 30

malcolm_341
Collaborator
Collaborator

The U value is impossible because I need that value to in x, y, z to be in the right spot, not zero or one?

0 Likes
Message 19 of 30

mcw0
Advisor
Advisor

Not sure I understand the issue.  If you are using the motionPath, the locator's translates are driven by the motionPath.  You only need to set the uValue of the motionPath so that the locator either is at one end or the other of the curve.

 

If you use the pointOnCurveInfo method, you connect the "position" output to the locator's translate.  Again, set the parameter value to get either the curve start position or the end position.

0 Likes
Message 20 of 30

malcolm_341
Collaborator
Collaborator

I'm trying to parent a locator or a curve CV under a vert, either will work, actually being able to parent anything under a vert would work.

 

I guess I'll need to write code to find the vert location, then do the curve thing, then move the u value and query this to see if the locator is in the right spot, if not move the u value again etc. What a lot of work just to have a vert control a transform.

0 Likes