Tail Oscillation help


#1

I’m using Maya 2011 and have a model of a horse with a long tail. I’m trying to set up a rig for it that has the ability to oscillate automatically without the need of keyframes but at the same time be able to tweaked using keyframed controllers. I can set up both systems relatively well but can’t bring them together.

In testing to set up an oscillating tail I set up three attributes, called ZOscillateStrength ZOscillateSpeed and ZOscillateBend for oscillating in the Z axis, onto a control object and then put this expression onto the root joint

joint1.rotateZ = sin(frame * joint1.ZOscillateSpeed)* joint1.ZOscillateStrength;

the following expressions were applied to the the rest of the joints in the chain

joint2.rotateZ = joint1.rotateZ * joint1.ZBend
joint3.rotateX = joint1.rotateX * joint1.XBend
etc

When values are put into all of my attributes this creates the effect of the tail wagging similar to how a fish would travel through water and is what I’m looking for.

In my actual rig I have set up a spline IK from the second joint in the chain all the way to the end, clustered the curve and parent constrained all but the first cluster to a controller. The first expression has been applied to the first joint in the chain and the tail can wag rigidly and then be keyframed using the controllers.

My problem is that with all but the first joint in the chain being controlled by a splineIK curve I cannot put my second set of expressions into place because rest of the joints attributes are already being controlled. I have looked into trying to set up a broken hierarchy so that the control the splineIK has on the joints can be turned on and off but I has of yet been unable to find anything like this.

If anyone has any advice or suggestion on how to solve this problem it would be greatly appreciated.

Cheers


#2

One way I would tackle this is to create a new Attribute on the Base controller for my Spline Ik This expression would drive the controllers position, since I would not be writing the expression on every controller it would allow me to make subtle key frame tweaks to the animation.

I will post a verision of this later tonight.


#3

Thinking about this, what you should be doing is using the SetAttr command instead of directly controlling the joint or controller.

Since your setting the attribute you are not directly linked to the attribute Thus it will enable you to update / animate the controller at any time.

A good example of this is shown in the makeRoll command

  
float $diameter = 1;

Bob.translateY = $diameter * 0.5 + 0;

float $tx = Bob.translateX;

float $tz = Bob.translateZ;

if( frame <= 1 ){

	float $rx = Bob.startRotX;

	float $ry = Bob.startRotY;

	float $rz = Bob.startRotZ;

	setAttr Bob.rx $rx;

	setAttr Bob.ry $ry;

	setAttr Bob.rz $rz;

  Bob.lastX = $tx;

  Bob.lastZ = $tz;

} else {

	float $lx = `getAttr "Bob.ltx"`;

	float $lz = `getAttr "Bob.ltz"`;

	float $x = $tx-$lx;

	float $z = $tz-$lz;

	float $d = sqrt($x * $x + $z*$z);

	if( $d > 0.00001 ){

		$x /= $d;

		$z /= $d;

		float $piD = 3.14 * $diameter;

		float $xrot = 360.0 * $d/$piD;

		float $yrot = rad_to_deg( atan2( $x, $z ));

			rotate -ws -r 0 (-$yrot) 0 Bob;

			rotate -ws -r ($xrot) 0 0 Bob;

			rotate -ws -r 0 ($yrot) 0 Bob;

		Bob.lastX = $tx;

		Bob.lastZ = $tz;

	}

}

 
 

This allows the expression to on a per frame basis to rotate the Sphere Named Bob, you can still rotate or key the sphere, to paricular rotation points.


#4

Thank you for getting back to me, sorry for me slow reply have been away from the internet for a couple of days.

Can’t say I fully understand everything in that code, very new to expressions and coding, but there is plenty for me to look into and read up on :slight_smile:

Cheers


#5

Depending on what you want it to be able to do, you could set up a dynamic curve controlling the Spline IK. You could also build a hand keyable Spline IK on top of this. If you set up three joint chains - dynamic, hand keyed, and skinned combo chain - you could create a control that allows you to use both, by affecting parent constraints…sort of like an adapted IK/FK switch…but rather a dynamics/hand keyed switch.


#6

There are a half dozen different ways to achieve the result, which is one of the things that I really like about maya. =)

It’s always a good thought exercise and sometimes a good practical exercise to see or try to do something in a different way. =)


#7

Thank you so much for all your help, apologises for the late reply again, I’m clearly not very good at it lately, In the end I went with Emorfer’s method and it worked perfectly but I’m looking into the SetAttr command for future rigs that I might set up.

The rig has been finished now and I just need to get some feedback on it for my final year project, If either of you are able to spend a couple of minutes playing with it and giving any critique of what does/doesn’t work and what I could add to make it better it would be a huge help.

My rig can be downloaded from
http://www.creativecrash.com/maya/downloads/character-rigs/c/fictional-quadruped-student-rig

But that said the file is still pending moderation so it might not be available just yet

Cheers


#8

Curious to check out the rig, but the link is not working?

Cheers,
Brian


#9

Yeah just checked and it is still apparently pending moderation, no idea how long this is going to take. If you’re still interested in helping me out I could send it to you personally.

You can pm your email address or email me at magumbobear@hotmail.com with your details

Cheers
Paul


#10

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.