View Full Version : Move IK mid point onto plane?
Rick Stirling 08-13-2008, 05:36 PM Like everyone else I'm building a script that creates a bone rig from a series of markers - however once I apply the IK to the legs the knees bow outwards. This is because the knee marker position doesn't lie directly on the plane between the thigh and ankle joints.
What's the best way to adjust the knee marker so that it meets this plane?
|
|
Rick Stirling
08-13-2008, 06:26 PM
Sorted it based on a maths function in a sticky:
fn pointPlaneProj pA pB pC pD = (
local nABC=normalize (cross (pB-pA) (pC-pA))
pD+((dot (pA-pD) nABC)*nABC)
)
I know two points on the plane, so the third point is easy to assume:
-- find a correct knee for IK
pointA = $'Marker L Thigh'.pos
pointB = $'Marker L Foot'.pos
pointC = $'Marker L Foot'.pos + [0,1,0]
My knee position is the one I want to move:
pointD = $'Marker L Calf'.pos
newpos = pointPlaneProj pointA pointB pointC pointD
$'Marker L Calf'.pos = newpos
Mine is a little more long winded as I did this years ago. I could do it far cleaner now.
fn projectSwivelAngle A B C multi:2=
(
A=if (isKindOf A node) then A.pos else A
B=if (isKindOf B node) then B.pos else B
C=if (isKindOf C node) then C.pos else C
aa=distance B C
bb=distance A C
cc=distance A B
multiMid=cc/(cc+aa)
bbMidPos=A+((normalize (C-A)*(bb*multiMid)))
L=length (B-bbMidPos)
dir=normalize (B-bbMidPos)
bbMidPos+=dir*L+(dir*multi)
)
A, B and C are the hip, knee and ankle positions or objects. Then I find the mid point between A and C and project that through B with a multipleier to set it out from the knee as far as you need. It returns a position value.
Rick Stirling
08-13-2008, 08:04 PM
Ah, that's a very elegant solution! Thanks Paul
CGTalk Moderation
08-13-2008, 08:04 PM
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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.