PDA

View Full Version : poleVectorConstraint moving target object problem...


seven6ty
02-10-2005, 11:32 AM
Hey, has anyone else had this problem???

I move my poleVector constraint object into place, so that the ikHandle's pole vector is pointed directly at it. Then I run:

poleVectorConstraint -w 1. $circle3 $ikName;

...to do a pole vector constraint to this object. It points at it, however, as soon as I make the constraint, my target object suddenly moves, causing the whole ik joint chain to point a different direction. Anyone know why it's causing my target object to move like that? I tried locking the translates on the object, but that didn't stop it from being moved.

digones
02-10-2005, 03:01 PM
hi

create a locator, freeze it's transformations and then parent the ikhandle to this locator.

now create the pole vector object, freeze it's transformations also and THEN you can make the PV constraint just like you did before, but this time do it to the parent locator instead of the ikhandle itself...

sorry for my bad english.


cheers,

seven6ty
02-10-2005, 08:12 PM
No go bro...

// Error: line 1: Target locator1 not valid. Targets must be of type ikHandle. //

...Is what I get when I try to do the pole vector constraint on that locator.

Anyone???

digones
02-10-2005, 09:19 PM
ups my fault, dude! :)

Here's the right steps:

1) create the joints using the right view port (make sure there's a slight bend in them)

2) create an ikRP solver, click on the first joint then on the third one.

3) create a locator, put it in front of the "knee" joint, select the locator. Select the ik handle and the "constrain>pole vector"

Now if you move the locator everything must be ok, if not send me your file and I'll be glad to help.

cheers,

digones
02-10-2005, 09:22 PM
adendum:

you can freeze locator's transformations before constraining to easily go back to the bind position... and obviously after the contrain you can parent any kind of object to the locator.

that's it... but if you are still having the same problem just send me your maya file...

seven6ty
02-11-2005, 05:18 AM
Ok, here's the deal...

I know how to get the IK to snap the pole vector to a control shape, but I'm doing a bit of a special set up so that the leg joints won't move when you apply the pole vector. This is all done by MEL scripting, so really I should be able to just show you the code and let you try it out if you want.

Here's what it's doing: Creating three circles and using these to control the pole vector attribute. Each one is smaller than the next, and parented underneath the larger circle around it. The outside circle is point constrainted between the beginning and ending joints of the IK chain, so it will always sit in the middle of it. The smallest circle is moved to the location of the top joint of the IK chain and it's translates are frozen. The pole vector setting of the IK chain is read, and applied to the small circle, so that it moves so it is perfectly in line with where the pole vector is pointing.

From here, is where you constrain the pole vector to this smallest circle, only every time I do, it causes the small circle to change location, even though no values change in it's translates, and none of it's parent circles have changed either. This design makes it so you can simply rotate the middle sized circle, and since the small one is a child of it, it causes this small circle/PV control object, to rotate the knee properly... Which can all be driven by a "KneeRotate" control on the foot, without giving you the pain of having to translate this PV control object around. Anyways, I'll brush up the code right now and post it in the next post so you can just copy and paste it into your script editor and see if you might know how to go about setting it up, thanks!

seven6ty
02-11-2005, 05:53 AM
ok, here's my code:

// The following procedure is still under construction, but it is designed to automatically
// create a leg IK knee direction control, with a controlling attribute added to a nurbs
// foot control.
proc createCircles(string $name)
{
// Create 3 circles, which each decreasing in size from the previous:
circle -c 0 0 0
-nr 1 0 0
-sw 360
-r 1
-d 3
-ut 0
-tol 0.01
-s 6
-ch 1
-name ($name + "_Constrain");
string $circle1 = $name + "_Constrain";
circle -c 0 0 0
-nr 1 0 0
-sw 360
-r .75
-d 3
-ut 0
-tol 0.01
-s 6
-ch 1
-name ($name + "_Rotate");
string $circle2 = $name + "_Rotate";
circle -c 0 0 0
-nr 1 0 0
-sw 360
-r .5
-d 3
-ut 0
-tol 0.01
-s 6
-ch 1
-name ($name + "_pVector");
string $circle3 = $name + "_pVector";
// Parent the circles:
parent $circle2 $circle1;
parent $circle3 $circle2;
}

// Procedure lineUpPoleVector will line up a pole vector control object with an ikRPsolver IK chain so that it does not
// offset or rotate your original joints at all.
// This procedure must start out with your pole vector object point constrained to the joint at the top of the
// IK hierarchy, with it's transformations froozen.
proc lineUpPoleVector(string $ikName, string $circle1, string $circle3)
{
// Find joint at top of IK chain:
string $sJoint[] = `listConnections -d off -s on ($ikName + ".startJoint")`;
string $startJoint = $sJoint[0];
string $eJoint[] = `ikHandle -q -jl $ikName`;
select -r $eJoint[`size $eJoint` - 1];
string $EJoint[] = `pickWalk -d down`;
string $endJoint = $EJoint[0];
select -cl;
// Constrain control curve to top & bottom joints of the IK chain, orientConstraint it to the top joint:
pointConstraint -w .1 $startJoint $endJoint $circle1;
orientConstraint -skip y $startJoint $circle1;
// Constrain pVector circle to top ikJoint, delete constraint, and freeze transforms:
pointConstraint $startJoint $circle3;
pointConstraint -e -rm $startJoint $circle3;
makeIdentity -apply true -t 1 -r 0 -s 0 -n 0 $circle3;
// Get attributes to use from the IK handle's pole vector settings and multiply by 10 to give a useful offset:
float $Xval = (`getAttr ($ikName + ".poleVectorX")` * 10);
float $Yval = (`getAttr ($ikName + ".poleVectorY")` * 10);
float $Zval = (`getAttr ($ikName + ".poleVectorZ")` * 10);
// Move pVector circle into place to line up with the IK's Pole Vector:
xform -r -t $Xval $Yval $Zval $circle3;
}

global proc ikRotateSetup()
{
// Get selection and check for errors:
string $selection[] = `ls -sl`;
if (`size $selection` == 0)
error ("Please select a control curve and then an IK handle.");
if (`nodeType $selection[0]` != "transform")
error ("Please select your control shape first, then the IK handle.");
if (`nodeType $selection[1]` != "ikHandle")
error ("Please select an IK handle after your control shape.");
if (`size $selection` > 2)
error ("Please select a control shape and then an IK handle.");
if (`size $selection` == 0)
error ("Please select a control shape and then an IK handle.");
string $ikName = $selection[1];
string $circName = $ikName + "_circ";
// Create and name 3 circles, grouped under each other.
createCircles($circName);
string $circle1 = $circName + "_Constrain";
string $circle2 = $circName + "_Rotate";
string $circle3 = $circName + "_pVector";
select -r $circle1;
lineUpPoleVector($ikName, $circle1, $circle3);
}

You can copy this and paste it into your script editor, execute it, and then just simply select your hand/foot control first, and then the ikHandle for your leg/arm, then run "ikRotateSetup();" in the script editor, without the quotes. From here, you should just simply have select the smallest circle, and then the ik handle and do a pole vector constraint, but you should see what I talk about, as this is where the small circle changes it's position completely and causes the joint chain to move with it as well. :-S

seven6ty
02-11-2005, 08:59 AM
Oh...

I can just connect the IK "twist" attribute and do the same thing. Oops.

Hmm, I knew about that attribute, but I just figured there had to be some kind of benefit to doing this the hardest way possible. Doh.

digones
02-13-2005, 06:50 AM
hahahhaah

wow, man, now I can see the real issue, and I agree with you, it's too complicated for such a simple task... :)

it's good to know that you finally figured the right way to go



cheers!

seven6ty
02-13-2005, 01:19 PM
Actuallyyyyyy... No!

Hahaha, I thought I could just connect the twist attribute, but it doesn't work properly. Whenever you rotate the foot, the knee begins to dip or turn with it as well. So, with this way, it should stay lined up. More R&D shall be done this weekend, yippie.

digones
02-13-2005, 06:31 PM
hehehe okay... just let me understand this clearly :) I know your trying to get a nice "special" knee setup :) but don't you think that this kind of control will complicate things more than helping you to animate? :cool:


Why do you need such control over the knee? I can obviously see the logic of your desired setup, but when I make my animations I have never been in need of this kind of control... I think it will be a problem solver just parenting the knee pole vector control to the foot control, so everytime you move foot's ctrl the knee will folow, and any other "extra" movement can be easily achieved by directly moving the knees... you can do pretty much everything with this simple setup... :P

I hope this could help :thumbsup:

digones
03-09-2005, 02:20 AM
ohhh. I know this thread is a lil' bit old..... but I just figured out how easy the solution is :D

try just grouping your poleVector constraint object under itself before you do the constraint.... oh, but do the constraint with the group

I bet it won't move anymore :deal:

CGTalk Moderation
03-09-2005, 02:20 AM
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.