View Full Version : deform by curve with twist
TBart
08-12-2008, 10:59 PM
Ok, so I'm trying to deform a mesh (a tentacle) with a curve, which is already a supplied deformer, but I also want to be able to twist it using nulls. Hopefully I'll get some help on this because I have a lot of questions.
Right now I'm trying to figure out how to use the "get closest point to line segment" node. I've been having problems getting data from bezier curves to work with mesh geometry data. For example, I can't get the mesh point position vector to plug into the "get closest point to line segment" node along with the curve point position vector. Maybe I have my curve terms confused? Obviously I'm doing something wrong but I don't know what.
Haamu
08-13-2008, 07:33 AM
I'm not XSI user so can't help with ICE specifics, but I have done this very same thing with maxscript (I believe you want to derive local upvectors from the nulls). You didn't mention what sort of questions you have besides icy, so hopefully this isn't too redundant to you.
-------------------------------
My approach is using second path instead of points.
x-axis is assumed to be longitude of the mesh and z axis up.
-Take x-coord. of a vertex.
-Find a point equal distance along the path (now called point p).
-Get normalized tangent of the curve at point p. (tangent)
-Find point on path2 closest to point p->create normalized vector directed there. (Normal)
(you might also want to do Normalize[Normal-dot(Normal, Tangent)*Tangent] to make sure it is the curve's normal. The closest point may not be "above" the path)
-Take normalized cross product of tangent and normal. (Yvector)
Your new mesh point will be p+(original-z*Normal)+(original-y*Yvector)
--------------------------------
That's my technical method. ICE might have some shortcuts for it though.
ThE_JacO
08-13-2008, 08:29 AM
not sure what you're trying to do, why are you trying to get the point of a mesh to find the closest point on a point on a curve? :)
Curve geometry in the geometry input, get data>self.pointposition in the position input, and for each point on your mesh it will return the closest point on the curve in the geo input.
Unless I misunderstood what you were trying to do.
TBart
08-13-2008, 12:38 PM
Thanks Haamu, that is almost exactly what I was trying to do, but the normalize bit you mentioned I didn't think of.
Jaco, I want to find the closest point on the curve so that I can use the tangent of that point, get the cross product of the tangent and the vector that points from the tangent point to the point on the mesh. The cross product will give me the direction to rotate. That's correct, isn't it?
The only thing that I'm worried about is that I will get double transforms between the nulls controlling twist and the "deform by curve".
ThE_JacO
08-13-2008, 02:25 PM
ok, maybe you were using the closest point to line or segment nodes?
Those are for lines and segments, that's not the same of a curve.
A segment is described by two points, a curve is a piece of geometry
get data(curve) > (geometry port) Get closest location
pointPosition > (position) Get closest location
That will return a location on the curve you can use.
You were using the wrong node.
Once you have the location another get data node picking it up can give you the tangent, normal, binormal, position, U etc at that location.
TBart
08-13-2008, 03:57 PM
Thanks Jaco, but you what I love most about ICE? Being completely ignorant and having solutions fall into your lap. I disconnected all of the tangent stuff I was trying to do, and it worked perfectly :o.
To control the twist, all I have now is "get point position" for the mesh, and that is plugged into a rotate vector node with the null local rotation. That's it. The rotation amount is controlled by a weight map, so it's really easy to add more control nulls. Also, the null location doesn't matter, just the local rotation so it can be constrained to curve. AND, (can you tell I'm having fun with this?), there isn't any pinching when rotating. It looks exactly like a quaternion rotation.
The only problem I have right now is that it flips past 180 degrees. I guess that's the next thing to fix. This might make a really nice spine at some point too.
camer
08-13-2008, 04:04 PM
то: ThE_JacO
please show the ICE Tree
TBart
08-13-2008, 04:19 PM
Me or Jaco?
camer
08-13-2008, 06:13 PM
TBard, show the ICE Tree to :)
Haamu
08-18-2008, 01:28 PM
So...I got me the XSI trial. So, some more ice specifics from me then. I'm attaching a compound and a scene with mesh deformed by 2 curves. It took me several hours to put together with zero experience in xsi, which is pretty good compared to few days in max with couple of years scripting experience :P. Granted that I had to figure out the math involved when I scripted it.
Mesh longitude is assumed to be on its local x-axis. I haven't made any fancy controls for it yet. Connect up your mesh and 2 curves and it should work. Offset value is for moving the mesh further along the curves.
There's one problem though. UV coordnates of a curve aren't normalized to its length, and apaprently uv to location is the only way to interpolate curve data. As a result there is stretching along the longitude of the mesh, if curve segment lengths aren't equal. I think ICE is currently lacking data access nodes for geometry.
Anyway, take a look.
TBart
08-18-2008, 05:51 PM
Thanks for taking the time to do all that Haamu. I'm not quite sure how you did it, but I will definitely look closer at the math involved. Here is my contribution:
scaron
08-19-2008, 12:17 AM
upload these to compound database?
Haamu
08-23-2008, 02:25 PM
I decided I didn't like the stretching that was going on so I tried to make a little improvement. It's a bit of a hack, but I managed to remove most of it. There's still some though, and I'm not sure why. Probably a flaw in my reasoning there as it's purely maths based. It's far more complicated than the original and took me quite a while to get working. Most of the time was spent on getting the contexts to match. Not that much fun :).
As said, it's a hack and needs few specific things:
1.Must be applied to a POINTCLOUD and not a mesh, cause I couldn't figure how to do some needed stuff on curves/mesh. (still works with meshes, pointcloud is just a middleman)
2.All knots of the Primary Curve must be BEZIER type.
3.Bring the 3 actual objects into the pointcloud tree and connect up.
there's also a switch for the old and new type of deform.
[edit] Old version here, scroll down for better one.
colintheys
09-03-2008, 04:55 PM
Hey Guys,
This is awesome work! I was just trying to tackle this precise problem a few days ago and was directed to this thread. I know precious little about scripting, but this example really demonstrated to me the awesome things you can do with this system. I've been experimenting with using the normalized script by Haamu and it's been working great. The only problem I had was when the curve crosses itself. I think it has to do with the proximity to knots. When the curves get too close maybe it finds a closer point on the other part of the curve that it is crossing? I have to experiment more, but it seems like placing more control points right around the cross prevents any weird twisting. I'm working on a video for an AIDS benefit and I'm supposed to animate this flowing ribbon twisting through people in a crowd and then forming the AIDS ribbon shape. It's been trickier than i expected and this just might be my saving grace.
Thanks for the great work!
-Colin
PhilTaylor
09-11-2008, 04:50 AM
Ok so I got curious and had a go at solving this issue.
I built some nodes for converting between U parameters and distance values and then back again. This is only one step away from calculating a normalized U value. Just divide the distance by the curve length to get a normalized U value. In this case I didn't need a normalized U, I just wanted the distance along the curve.
There are 2 operators running. One which looks at a reference curve and calculates a Distance value per point along the curve. Then another operator deform the mesh by re-parametrizing a 2nd curve.
There are 2 curves and 2 operators for performance reasons. Only one of the operators should evaluate per frame. The one in the animation region of the stack. Note: you could freeze the modeling region of the stack and the 2nd operator will keep working.
This is just another example of what you can do in ICE. Until we officially support a normalized U value, you could use a compound much like this one.
I forgot to point out the significance of calculating length values from U parameters and back again... When the length of the curve changes, the tail does not stretch. Open the scene and press 'M' and edit the curve. Notice how the tail slides up and down the curve without compressing.
I use and approximation technique to calculate the length values. in this example I am only sampling the curve 10 times, but you should probably up that to at least 20 for better accuracy.
And the nulls are what you use for the twisting. Rotate the null at the end of the tail to twist up the tail. The next step would be to deform the curve using the nulls and then you only have one set of controls for the tail shape.
Phil
Haamu
09-11-2008, 10:49 AM
Really nice Phil. Thanks a lot for that.
I also revamped my path deformer using those nodes. It now works nicely without any hacks or restrictions.
Place inside a tree in the mesh and plug your curves.
thiago
09-11-2008, 01:00 PM
please guys, don't forget to upload these things to the compounds section, thanks.
Even if you gonna work more on that you should upload, then update when you have the chance.
TBart
09-22-2008, 01:38 AM
Wow Phil, thanks, this is exactly what I needed. Are nodes like CurveLocationDistance documented? Some of the descriptions are a little vague and make it difficult for me learn what tools I have at my disposal. I know some stuff isn't supported, so I don't expect documentation for everything, but maybe it's there and I just can't find it in the help docs.
vBulletin® v3.7.0, Copyright ©2000-2008, Jelsoft Enterprises Ltd.