View Full Version : biped.setTransform
Mattrne 04-18-2006, 04:19 PM Im working on a agme at the moment where we are using biped. I need to make a tool which will take all of our current skeletons in characters and make sure that the rotations across their hierarchies are the same (to fix a bunch of problems).
I have a skeleton which has all of the rotations I want so I have written a script which uses biped.getTransform to read out the rotation values for the joints in the skeleton and then gives me the relevant output to use to set the other skeletons to match these rotations.
You may think why dont I just load a fig file? Well basically the skeletons are all different heights which we want to keep, so loading a fig file will lose this height info.
The code I have thus far is as follows;
prBon1 = "Hero"
prVal1 = biped.getTransform $Hero (#rotation) limb:$Hero; --attempted to use prBon1
--variable inplace of $Hero but couldnt figure out how - this would mean only the previous
--line needs modification!
format "biped.setTransform $% #Rotation % false limb:$$%\n" prBon1 prVal1 prBon1
This code is repeated for each bone in the hierarchy, just changing the prBon1 variable and replacing the $hero in prVal1 with the relevant bone name.
Now my problem is that when i try to apply the info which the format line gives me to my incorrectly rotated skeletons, various bones get messed up with very bizarre rotations (in particular the fingers). Also if i apply the script numerous times, then each time, the value on the fingers gets added onto the previous rotations, which is not what I am wanting! Its very odd, because the thing seems to work on everything apart from the clavicles and fingers!
Can anyone tell me if there is some way I can set something up to do what I'm wanting?
|
|
sleepite
06-15-2006, 09:50 PM
I realise it's been almost two months since this thread was posted but I'm having the exact same problem myself - fingers seem to be a law unto themselves when it comes to rotation.
I've had more luck in general with bipeds by calculating the quaternion difference between the angle of the bone and the desired angle and then using the rotate command rather than using biped.settransform but still not much joy with the fingers.
btw. using:
prBon1 = "Hero"
limbobj = execute("$'" + prBon1 + "'")
prVal1 = biped.getTransform limbobj #rotationought to let you evaluate that variable to an object.
Anubis
07-02-2006, 08:57 PM
I am trying to attach a biped to an identical imported FBX skeleton with mocap, it all works fine but the damn pelvis. I know the pelvis has changed in 8, anyone know why settransform won't work? As far as your method above, wouldn't it look like this:
rotate $'Bip01 Pelvis' (LnDif (biped.getTransform $'Bip01 Pelvis' #rotation) $'_Bip01 Pelvis'.rotation)
I originally tried like this, which I believe is the same thing:
rotate $'Bip01 Pelvis' ((inverse biped.getTransform $'Bip01 Pelvis' #rotation) * $'_Bip01 Pelvis'.rotation)
Either way I can get neither to work. Biped makes me sad. Did you get this to work?
:shrug:
LoneRobot
06-13-2007, 11:28 AM
This is making me cry a bit too. I can extract the bipeds positions using get/set transform but the pelvis only seems to extract one rotation - (y) I guess this must go back to where the pelvis was more limited in rotation in previous releases of CS. As for any rotation moving backwards and forward etc, i cant seem to get the data for that. Top of my head would suggest to use copy/paste posture to get and set the pelvis position, but that's pretty slow and ugly. there has to be a better way!
MikeKelley
06-16-2007, 08:04 PM
Forgive me for jumping in on this thread, but this is kind of what I'm trying to do.
I don't understand why doing this:
rotcont = biped.getnode $ #head
mytest = biped.getTransform rotcont #rotation
biped.settransform rotcont #rotation mytest true
changes the rotation of the head. Are these things additive? IOW, if you perform a Get and return the current quat values of the head and then turn around and apply them, why does the head rotate?
What I'd like to do is apply the rotations of another object to the biped head, and it *seems* to work except for this weird rotation issue (which is to say that I can get the rotations applied to the head except it turns around backwards and lays on its side, which so far isn't very useful to me :>)
Hello,
I'm not sure if this is what you're looking for, but here is a script I use for applying transforms from an imported bone rig to a biped (matching in size).
rollout B2BRollout "Bone2Biped"
(
button B2BButton "Apply Animation"
On B2BButton pressed Do
(
anim_Start = animationRange.start
anim_End = animationRange.end
DisableSceneRedraw()
Animate On
For t = anim_Start to anim_End Do
(
sliderTime = t
biped.setTransform $Bip02 #pos ($Bip01.transform.pos) True
biped.setTransform $Bip02 #rotation ($Bip01.transform.rotation) True
biped.setTransform $'Bip02 Pelvis' #pos ($'Bip01 Pelvis'.transform.pos) True
biped.setTransform $'Bip02 Pelvis' #rotation ($'Bip01 Pelvis'.transform.rotation) True
biped.setTransform $'Bip02 Spine' #pos ($'Bip01 Spine'.transform.pos) True
biped.setTransform $'Bip02 Spine' #rotation ($'Bip01 Spine'.transform.rotation) True
biped.setTransform $'Bip02 Spine1' #pos ($'Bip01 Spine1'.transform.pos) True
biped.setTransform $'Bip02 Spine1' #rotation ($'Bip01 Spine1'.transform.rotation) True
biped.setTransform $'Bip02 Spine2' #pos ($'Bip01 Spine2'.transform.pos) True
biped.setTransform $'Bip02 Spine2' #rotation ($'Bip01 Spine2'.transform.rotation) True
biped.setTransform $'Bip02 Neck' #pos ($'Bip01 Neck'.transform.pos) True
biped.setTransform $'Bip02 Neck' #rotation ($'Bip01 Neck'.transform.rotation) True
biped.setTransform $'Bip02 Head' #pos ($'Bip01 Head'.transform.pos) True
biped.setTransform $'Bip02 Head' #rotation ($'Bip01 Head'.transform.rotation) True
biped.setTransform $'Bip02 L Clavicle' #pos ($'Bip01 L Clavicle'.transform.pos) True
biped.setTransform $'Bip02 L Clavicle' #rotation ($'Bip01 L Clavicle'.transform.rotation) True
biped.setTransform $'Bip02 L UpperArm' #pos ($'Bip01 L UpperArm'.transform.pos) True
biped.setTransform $'Bip02 L UpperArm' #rotation ($'Bip01 L UpperArm'.transform.rotation) True
biped.setTransform $'Bip02 L Forearm' #pos ($'Bip01 L Forearm'.transform.pos) True
biped.setTransform $'Bip02 L Forearm' #rotation ($'Bip01 L Forearm'.transform.rotation) True
biped.setTransform $'Bip02 L Hand' #pos ($'Bip01 L Hand'.transform.pos) True
biped.setTransform $'Bip02 L Hand' #rotation ($'Bip01 L Hand'.transform.rotation) True
biped.setTransform $'Bip02 L Finger0' #pos ($'Bip01 L Finger0'.transform.pos) True
biped.setTransform $'Bip02 L Finger0' #rotation ($'Bip01 L Finger0'.transform.rotation) True
biped.setTransform $'Bip02 L Finger01' #pos ($'Bip01 L Finger01'.transform.pos) True
biped.setTransform $'Bip02 L Finger01' #rotation ($'Bip01 L Finger01'.transform.rotation) True
biped.setTransform $'Bip02 L Finger1' #pos ($'Bip01 L Finger1'.transform.pos) True
biped.setTransform $'Bip02 L Finger1' #rotation ($'Bip01 L Finger1'.transform.rotation) True
biped.setTransform $'Bip02 L Finger11' #pos ($'Bip01 L Finger11'.transform.pos) True
biped.setTransform $'Bip02 L Finger11' #rotation ($'Bip01 L Finger11'.transform.rotation) True
biped.setTransform $'Bip02 L Finger2' #pos ($'Bip01 L Finger2'.transform.pos) True
biped.setTransform $'Bip02 L Finger2' #rotation ($'Bip01 L Finger2'.transform.rotation) True
biped.setTransform $'Bip02 L Finger21' #pos ($'Bip01 L Finger21'.transform.pos) True
biped.setTransform $'Bip02 L Finger21' #rotation ($'Bip01 L Finger21'.transform.rotation) True
biped.setTransform $'Bip02 R Clavicle' #pos ($'Bip01 R Clavicle'.transform.pos) True
biped.setTransform $'Bip02 R Clavicle' #rotation ($'Bip01 R Clavicle'.transform.rotation) True
biped.setTransform $'Bip02 R UpperArm' #pos ($'Bip01 R UpperArm'.transform.pos) True
biped.setTransform $'Bip02 R UpperArm' #rotation ($'Bip01 R UpperArm'.transform.rotation) True
biped.setTransform $'Bip02 R Forearm' #pos ($'Bip01 R Forearm'.transform.pos) True
biped.setTransform $'Bip02 R Forearm' #rotation ($'Bip01 R Forearm'.transform.rotation) True
biped.setTransform $'Bip02 R Hand' #pos ($'Bip01 R Hand'.transform.pos) True
biped.setTransform $'Bip02 R Hand' #rotation ($'Bip01 R Hand'.transform.rotation) True
biped.setTransform $'Bip02 R Finger0' #pos ($'Bip01 R Finger0'.transform.pos) True
biped.setTransform $'Bip02 R Finger0' #rotation ($'Bip01 R Finger0'.transform.rotation) True
biped.setTransform $'Bip02 R Finger01' #pos ($'Bip01 R Finger01'.transform.pos) True
biped.setTransform $'Bip02 R Finger01' #rotation ($'Bip01 R Finger01'.transform.rotation) True
biped.setTransform $'Bip02 R Finger1' #pos ($'Bip01 R Finger1'.transform.pos) True
biped.setTransform $'Bip02 R Finger1' #rotation ($'Bip01 R Finger1'.transform.rotation) True
biped.setTransform $'Bip02 R Finger11' #pos ($'Bip01 R Finger11'.transform.pos) True
biped.setTransform $'Bip02 R Finger11' #rotation ($'Bip01 R Finger11'.transform.rotation) True
biped.setTransform $'Bip02 R Finger2' #pos ($'Bip01 R Finger2'.transform.pos) True
biped.setTransform $'Bip02 R Finger2' #rotation ($'Bip01 R Finger2'.transform.rotation) True
biped.setTransform $'Bip02 R Finger21' #pos ($'Bip01 R Finger21'.transform.pos) True
biped.setTransform $'Bip02 R Finger21' #rotation ($'Bip01 R Finger21'.transform.rotation) True
biped.setTransform $'Bip02 L Thigh' #pos ($'Bip01 L Thigh'.transform.pos) True
biped.setTransform $'Bip02 L Thigh' #rotation ($'Bip01 L Thigh'.transform.rotation) True
biped.setTransform $'Bip02 L Calf' #pos ($'Bip01 L Calf'.transform.pos) True
biped.setTransform $'Bip02 L Calf' #rotation ($'Bip01 L Calf'.transform.rotation) True
biped.setTransform $'Bip02 L Foot' #pos ($'Bip01 L Foot'.transform.pos) True
biped.setTransform $'Bip02 L Foot' #rotation ($'Bip01 L Foot'.transform.rotation) True
biped.setTransform $'Bip02 L Toe0' #pos ($'Bip01 L Toe0'.transform.pos) True
biped.setTransform $'Bip02 L Toe0' #rotation ($'Bip01 L Toe0'.transform.rotation) True
biped.setTransform $'Bip02 R Thigh' #pos ($'Bip01 R Thigh'.transform.pos) True
biped.setTransform $'Bip02 R Thigh' #rotation ($'Bip01 R Thigh'.transform.rotation) True
biped.setTransform $'Bip02 R Calf' #pos ($'Bip01 R Calf'.transform.pos) True
biped.setTransform $'Bip02 R Calf' #rotation ($'Bip01 R Calf'.transform.rotation) True
biped.setTransform $'Bip02 R Foot' #pos ($'Bip01 R Foot'.transform.pos) True
biped.setTransform $'Bip02 R Foot' #rotation ($'Bip01 R Foot'.transform.rotation) True
biped.setTransform $'Bip02 R Toe0' #pos ($'Bip01 R Toe0'.transform.pos) True
biped.setTransform $'Bip02 R Toe0' #rotation ($'Bip01 R Toe0'.transform.rotation) True
t += 1
)
Animate Off
EnableSceneRedraw()
)
)
CreateDialog B2BRollout width:162 height:30
Best regards,
RX31
MikeKelley
06-17-2007, 11:14 AM
First of all, I am aware you may be responding to the others on this thread and not to me -- so I hope your script works for them (I did not intend to hijack this thread and apologize for any confusion).
For me (trying to get rotations from another object and apply them to the biped) this script causes the same problem -- namely, the biped head immediately lays over on it's side and turns around 180 degrees.
For those of you playing along at home here's my relevent code test (with my animated Box01 being what I'm trying to copy the rotations from):
anim_End = animationRange.end
DisableSceneRedraw()
Animate On
For t = anim_Start to anim_End Do
(
sliderTime = t
biped.setTransform $'Bip01 Head' #pos ($box01.transform.pos) True
biped.setTransform $'Bip01 Head' #rotation ($box01.transform.rotation) True
t += 1
)
Animate Off
EnableSceneRedraw()
Now, based on assuming that what you do works for you, this leads me to the conclusion that it has to do with the hierarchy of the biped structure -- that is, your code works because you are copying the exact same hierarchy and this can't be applied from an unlike structure. Can I ask if the rig you are using (Bip01, in this case) is created with Max bones?
Hello,
Yes, Bip01 is max bones which match exactly with Bip02 in length. Perhaps you'll have more control if you attach your box to max bones, which match your biped and use this script.
Best regards,
RX31
MikeKelley
06-18-2007, 07:11 PM
Thanks, yes indeed using just two Max bones will work correctly with Biped (although they also need to be aligned correctly with the biped head, but that's no big deal). So it solves my problem (mucho thanks) although it also shows just how quirky Biped is.
In any case, I'm working now (and I'm sure you all know how great it is to be able to say that :>)
CGTalk Moderation
06-18-2007, 07:11 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.