PDA

View Full Version : Rigging question


keats
11-22-2004, 07:30 PM
I'm creating a relatively complex character rig and I'm stuck on a detail. I'm new to rigging so go easy on me if this is basic knowledge, Ive looked around but haven't found an answer yet.

I've made an elbow with a spike on the end, you can see the rig at http://users.skynet.be/keats/arm1.JPG . My problem is that I want to link the blue spike-bone to the underarm, but at the same time limit its Z rotation so that it doesnt clip into the upperarm when the arm is stretched, like this : http://users.skynet.be/keats/arm2.JPG .

I've tried wiring parameters (but none of the underarm parameters I wire it to seem to change when I move the hand control shape), Ive tried adding orientation constraints; disabling Z rotation inheritance together with the previous two, but to no success. If anyone here can give me a pointer how I accomplish this best it would be greatly appreciated.

keats
11-27-2004, 04:12 PM
seriously, no-one? I thought this was basic? :o

Still stuck on it ...

eek
11-29-2004, 09:36 AM
I need to know if you have an ik chain system in there, if so i'll have to have another think. I not and your just using fk, i should have a solution for you.


eek

keats
11-30-2004, 09:35 PM
Thanks, I'm working around it for now by making the spike cup around the upperarm even when stretched (thx coffeeman), but I'd still like to know if there is a solution to the problem stated above. I use a HI IK solver for the upper/underarm, the spike isn't IK-ed.

clalan
12-01-2004, 08:30 AM
Hey keats,

I'm relatively new to rigging too so there might be all kinds of things wrong with the solution I'm presenting here, but for a fellow belgian I'd like to make a fool out of me :)

I think the easiest way (maybe the only way) to do this is using maxscript. what you want to do is read the angle between your two armbones and then have the spike do a counterrotation if it's about to crash with the arm. I named the bones in my scene bone_upperarm, bone_lowerarm, bone_spike.

the spike has to do a counterrotation around the elbow, so we have to create a helper there. line it up with bone_lowerarm (pivot points) and then link it to bone_lowerarm. link bone_spike to the newly created helper (helper_spike). in default state the rotation of the helper is zero, but the arm is stretched, we need to adjust it's value to avoid crashing.. and that's where maxscript kicks in.

the most common way to read the angle between bones is through matrix calculations. we basicly want to read the rotation of the lowerarm in upperarm-space instead of worldspace. to do that we got this nice line of code:

quatToEuler ($bone_lowerarm.transform * inverse ($bone_upperarm.transform)).rotationpart;

we multiply the lowerarm matrix with the inverse of the upperarm matrix. we only want to get the rotationpart and we want it in euler angles, not in quaternions. if you put this in the maxscript listener this will give you the angle between those two armbones. I tried out how far the spike could move and in my situation it had to counter the rotation as soon as the arm went below 30°.

so on the motionpanel, assign a float script controller on the z-rotation of helper_spike. I don't know if you have any experience with float scripts, but I assume you do as you have arm twist bones in your setup :) I put in this little bit of code:

dependsOn $bone_upperarm $bone_lowerarm

a = quatToEuler ($bone_lowerarm.transform * inverse ($bone_upperarm.transform)).rotationpart;

if (a.z < 30) then
degToRad (-a.z + 30);
else
0;

first we state that this script should be read every time one of the two armbones is altered. then we read the angle between the two bones (as described above) and put in a local variable.

now, if the z rotation between the two bones is lower than 30, the helper should counter the rotation: -(a.z - 30). otherwise it should just remain in it's default pose.

I hope this all made sense, otherwise give me a shout (and your email adress) and I'll send the maxfile to you :)

-Alan

eek
12-01-2004, 10:35 AM
Ah, beat me to it. Will that script read the rotation values of a bones in an ik chain?. I know in 7 you can grab explicit rotations from ik chain driven bones. As if they werent driven by ik, you could put a expression on the bone = IF (a.z > 30, a.z + 30, 0) same as your script.

Ah, ok if your reading the values via a matrix, then are basically grabbing there offsets?

Mmm i should look into scripts more, never really tried them out.

eek

keats
12-01-2004, 04:56 PM
Fellow belgian, en mede-gentenaar dan nog (for another month that is, I'm moving back to the country :p). Yeah I suspected it'd take maxscript, I tried creating my own maxscript but I didn't know how to get the angle between the two bones. I do now, I'll definately try out your solution, thanks a lot!

eek
12-01-2004, 05:31 PM
not maxscript, but float_script, its a controller type. (float script can use 90% of the MS syntax).


eek

CGTalk Moderation
01-20-2006, 12:00 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.