I need to place a bunch of object copies along the mesh edge loop (to model stitches). So I suppose the “attach to motion path” with “follow path object” is a potentially a good solution for that. Now I am trying to find a manual way to create an automatic tool for that later.
In practice, the lattice is twisted randomly and produce unusable results (I am using World Up set to Normal).
As far as I understand that is caused by messed curve normals. Is there a way to fix this? There is a solution for curve normals in Houdini, but I am not sure if the normals is a reason and how to deal with curve normals in Maya if it is…
If I had to place things along a curve on a mesh I would create a curve from the edge loops.
From this curve you can query evenly spaced positions and from those positions you can query the normal on the mesh. This normal and the curve tangent on that position can then be used to generate a rotation.
Hello, Joosten!
Can you explain a bit more in depth, please?
You are not supposing to use motionPath with lattice, correct? So the stitches would be only rotated, but not deformed? I am looking for a solution with the deformation of each stitch.
Also, how can I get evenly spaced positions from the curve? And how can I query a mesh normal from a certain position in space?
Sorry, I must have misunderstood. I was under the assumption you’d be placing x amount of duplicates along the curve.
Principle still applies I think even with a lattice. You would just position and rotate a lattice point based on the point and normal.
If you want the stitches to be applied on a deforming mesh you can create follicles on the mesh. In that case all you need is the closest UV point of the position on the curve. This follicle can then drive a cluster that controls the lattice points of a row.
Right, I am placing x amount of duplicates along the curve. The mesh is not deforming, it’s static, but I need to deform copied objects (so they replicate the curvature of the mesh ideally). That’s why I use motionPath - it can build a lattice around the curve with “Follow Path” constraint tool.
Maybe there is another way how I can create a lattice using surface normals and tangents… Will research this topic.
the lattice itself would get created as normal. But you would position it’s rows, using the points and normals you queried from the curve. This will place your stitches along the curve. Is your plan to also deform the individual stitches to be wrapped around the mesh?
This is what I am thinking about… If I will go with placing individual stitches along the curve without Motion Path I have no idea how to create a lattice (either for all combined stitches or for each stitch individually) around the curve.
The curve you generate will have a length. So if you want to place all stitches at once you can generate a straight strip of stitches that is the same length as your curve. You can then create a lattice around all of those stitches. You can create divisions on your lattice based on the length of the curve and the amount of stitches.
For example if you have 5 lattice rows. You can split up the points and normals you query on the curve based on increments of 0.25. You query curve parameter 0, 0.25, 0.5, 0.75 and 1. You have created clusters for each of the rows on your lattice. You can translate and rotate those clusters based on your curve parameter position and normal.
I hope that will do the trick. Another more advanced solution would be to use a radial basis function to place the stitches on a vertex level. If you would go that route all you have to do is generate a curve the rest is just code to set the vertices positions directly.
I suppose this happens because of uneven points location and rebuilding will fix it, but rebuilding curve also change it shape dramatically, so its not an option.
If I have a lattice (S=10, T=2, U=2), how can I get 4 lattice points for each of S divisions to create 10 clusters?
UPD
lattice = pm.PyNode('ffd2Lattice')
numberOfRowsS = lattice.sDivisions.get()
for i in range(numberOfRowsS):
pm.cluster(lattice.pt[i][0:1][0], lattice.pt[i][0:1][1])
Here what I have for now from left to right: source curve, test arrow object cloned along the curve and lattice deformed with clusters (and it is obviously wrong)
Ok, since the issue was that each cluster was away from the origin I got some sort of double transformations. So before creating clusters I just scale lattice to zero on the X axis, then create clusters and move them to a proper position on the curve.