Notifications
Clear all

[Closed] Path constraint : flipping problem

Hello again everybody

I come with another tricky set-up problem. It deals with rigging but I think that perhaps my messiah could be maxscript or C++ so…

I try to make a cool spine for hours and I can’t find a way to do it. Actually I want to clone the spine rig I’ve made for XSI.

To make it simpler let’s take a spine composed of three dummies controlling a curve (by linked x-forms (fig. A in attachment). On the curve we have points as spine-divisions that are driven by a custom controller. Basically this controller constraints the spine-division position to the curve at a certain path percentage, constraints his x and y rotations to the curve tangent at this particular point and constraints the z rotation to a combination of the rotations of the three spine controllers. As a result, the spine-divisions can follow the curve deformation and tangent to make a nice smoothly-distributed spine (fig. B in attachment).

Finally, the scale is driven in « volume conservation » behaviour, that means It’s squashing and stretching with the curve squash&strech (fig. C in attachment).

So to make a spine rig with Max who reach this type of behaviour, I first tried to begin with a path constraint, then I realize that this controller consider the world Z-axis as an upnode for the transformation. Unfortunately, having this kind of “static” upnode always pose problems when the constrained object passing through this orientation (remember what happen when you want to make a 360 degrees circular path with a camera with target. When it comes to the 180 degrees, aligned with the “upnode” or “upvector”, the camera roll becomes crazy because this there is nothing anymore to say where the top is for the camera, when you pass 180 degrees, the camera can find the upnode and flips to orient the camera with the right top reference again, see fig. D in attachment).

As I can’t find a way to assign a new upnode for Path constraint, I then tried to develop a scripted controller to drive the divisions positions on a curve by an other way that a path constraint.

So I found some interesting functions to use with C++ or maxscript: interpCurve3D to get a position on the curve at the specific path percentage and tangentCurve3D for the tangent

Once again, it can’t solve my problem,:shrug: because the values returned by interpCurve3D & tangentCurve3D are correct for baseobject level (Line). In my case, there is a linkedXform on each vertex of the curve.

Since the functions are designed for base object level, it works perfectly when just moving the points “by hand” at Line level, but it can’t get the curve position and tangent when the vertices are driven by modifiers at sub-object level.

Here you are
I really need help because I just don’t see how I can smartly drive this spine-divisions. I will search if there is a way to drive the points directly at baseobject level regarding to the controllers position (in a way re-write a linkedXform that is not a modifier but simply drives the points realtime) but if I have to do that, I will need help too.

Maybe a Splineshape plugin in C++ ?

Sorry for being so long but I think that if you want to help me you will need to know all this stuff .

Thanks in advance

4 Replies

So the general gist is you’re trying make a different form of max’s spline-IK? I got a bit lost in the middle there.

In a way, yes.

Actually my problem could be reduced at a path constraint flipping problem. I have several objects path-constrained to the curve (without any animation, to make them stick at a particular path percentage).

These objects have to be skinned to the body to form vertebraes. But as exposed in my original post, I can’t avoid the flipping problem when passing the world Z-axis.

Try it if you don’t know this problem .

 PEN

Well I do spine rigs like this all the time. You need to use lookat constraints and orientation contraints in there as well. The spline IK in Max isn’t very good and I never use it. My second DVD covers how I deal with it in detail if you are interested.

Firstly, for a total solution I recommend Paul’s DVD.

Beyond that, I’ve been playing with your idea of directly controlling verts on a spline for several hours now – mainly getting it all to come together in maxscript. It was quite hard to figure out and I end up getting there in a less than desireable way but the code is still fairly short and the main part is it works! Here’s what I’ve come up with:

if selection.count == 1 AND $.category == #Splines do
(
	animateVertex $ #all --give all verts animation controllers
	--access to the controllers is by newly created properties
	--so we get all properties and filter for the ones we want
	props = getPropNames $ 
	pat = "Spline_1___Vertex_*"
	for g in props do
	(
		temp = g as string
		if (matchPattern g pattern:pat) do
		(
			--get the vertex number of the each vert
			num = (replace temp 1 18 "") as integer
			--create a point at each vert
			p = point pos:(getKnotPoint $ 1 num)
			--create a script controller for each vert
			setPropertyController $ g (point3_script())
			--add some variables and the new script
			c = getPropertyController $ g
			c.addTarget "pos" p.pos.controller
			c.addNode "par" $
			c.script = "pos * inverse par.transform"
		)
	)
)

Hopefully the commenting is descriptive enough for you. Any questions be sure to ask.