RP plane/ Joint orient problem

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

Thread Tools Search this Thread Display Modes
  03 March 2013
RP plane/ Joint orient problem

Hey all,
I have a rigging dilema that's driving me crazy. I am rigging a character with a wide stance and his knees are pointing outwards. Normally I would create a simple leg joint chain, reposition the joints (using only the translate) to fit in the geometry, and adjust the local rotation axis to make sure that everything is rotating in the correct axis. I would then add a IK handle and a pole vector constraint. No problem.

However, I was going through a tutorial on the proper way to setup an IK/RP handle on a 3 joint arm setup. The tutorial stresses the importance of having 3 vectors on the same plane when setting up our joints, IK handles, and pole vector constraints. This is obviously to avoid any flipping and get the most reliablity out of our RP solver. Furthermore, the tutorial goes on to explain that the proper placement of the vectors is dependent on the middle joint (elbow) having zeroed out joint orient rotations except in the bend axis, and the translates must be zeroed out except for the down the joint axis. So far I understand what the tutorial is saying, but when I go to create the leg chain for the character mentioned above, I cannot get the middle (knee) joint to get the proper joint orient values that are required for the vectors to be placed on the same plane, due to the legs going off on an angle and not going straight up and down. My question is how do I get the vectors to sit on the same plane while the joint chain is pointing off to the side, or how do I get the knee joint to have the proper values in the joint orient. I've got a link below to the tutorial I was following.

  03 March 2013
I'm a bit of a novice with Python, but I've been doing this in maxscript for a while so I wanted to try to translate it into pymel.

  import pymel.core as pm
  import pymel.core.datatypes as dt
  # I made three locators and positioned them where the thigh, knee, and ankle joints should be.
  b1 = pm.PyNode('locator1')
  b2 = pm.PyNode('locator2')
  b3 = pm.PyNode('locator3')
  # here are the raw vectors defining the thigh-knee, knee-ankle, and thigh-ankle
  thighVec = (b2.getTranslation() - b1.getTranslation())
  kneeVec = (b3.getTranslation() - b2.getTranslation())
  ikVec = (b3.getTranslation() - b1.getTranslation())
  # and I normalize them for mathy stuff
  thighVecN = thighVec.normal()
  kneeVecN = kneeVec.normal()
  ikVecN = ikVec.normal()
  # I'm thinking in max here, so the "X" axis is pointing along the bone. 
  # thighVec and ikVec are both in the plane we want the normal of
  # The "Y" axis for the thigh and knee is the cross product of them
  thighY = ikVecN.cross(thighVecN).normal() * -1
  # I reversed the normal with -1 to make the Z point "outward" as I made this a right leg
  # Then I cross thighVec and thighY to get the orthogonal axis for the thigh.
  thighZ = thighVecN.cross(thighY).normal()
  # since thighY is also the normal of the plane the lower leg is on, I only need to get the cross of kneeVec and thighY to complete the knee matrix
  kneeZ = kneeVecN.cross(thighY).normal()
  # thigh matrix: X axis vector, Y axis vector, Z axis vector, thigh locator position.
  thighTM = dt.Matrix( thighVecN.x, thighVecN.y, thighVecN.z, 0, thighY.x, thighY.y, thighY.z, 0, thighZ.x, thighZ.y, thighZ.z, 0, b1.getTranslation().x, b1.getTranslation().y, b1.getTranslation().z, 0 )
  # knee matrix: X axis vector, Y axis vector, Z axis vector, knee locator position
  kneeTM = dt.Matrix( kneeVecN.x, kneeVecN.y, kneeVecN.z, 0, thighY.x, thighY.y, thighY.z, 0, kneeZ.x, kneeZ.y, kneeZ.z, 0, b2.getTranslation().x, b2.getTranslation().y, b2.getTranslation().z, 0 )
  # get the point to project through the knee to find where the PV should go:
  pvproj = b1.getTranslation() + (ikVec * (thighVecN.dot(ikVecN) * (thighVec.length()/ikVec.length())))
  # project pvproj through b2 to find the PV. I used half the total leg length to position it from the knee.
  pvpos = b2.getTranslation() + ((b2.getTranslation() - pvproj).normal() ((thighVec.length()+kneeVec.length())/2))
  # build and position the PV
  pvLoc = pm.spaceLocator(n='pv')

I don't know why the code formatting is crazy. It's randomly inserting spaces and tabs and indenting.

Last edited by Rotu : 03 March 2013 at 01:14 PM. Reason: formatting
  03 March 2013
Thread automatically closed

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.
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
Thread Closed share thread

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Society of Digital Artists

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump

All times are GMT. The time now is 03:24 AM.

Powered by vBulletin
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.