Hi, this is probably a really stupid question, but I can't find the answer anywhere!
I was basically wanting to know the difference between the xform command and the get/setAttr commands. They both can get and set the translation and rotation etc of an object right?
The reason I ask is this.
I am using FBIK and I'm trying to move the FBIK effectors in a script and then key them. The problems I have run into is that first I found that you need to update the model after you use setAttr to move the effector and before setting the key. I do this currently by moving the effector a tiny bit and moving it back. I don't know if this is the correct way but it is the only way that seems to work. BUT the weird side effect of this is that after I move the effector back it is in roughly the same position but the rotations are completely out. Why not do this by hand in MAYA? Well, I am trying to find out the amount of translate and rotate the user has changed from the original position at the point they push my MEL button. To do this I getAttr the trans and rot and save them. Then I change the time slider to get the model back to the original state. I then getAttr again and calculate the difference and then use the setAttr to return the model back to the state the user created and then update the model and key.
Anyway, I was thinking could the weird rotations and stuff be down to the setAttr command doing something weird in the background like changing rotation order or something? Ideally I would like to set all 6 attributes (trans + rot) and then update the model so that it will pop straight back to its original position.
I'm really sorry for this long winded post! Thank you for any help!
getAttr and setAttr work on the nodes internal data, form is a convinence function to work on movement of trasfromations, in way theres little differnce here EXCEPT that xform has more space options. Howvyer getAttr and setAttr are generic nodla info workers in the end all data is pushed thisway.
both Xform and setAttr mark the node dirty, maya never actualy refreshes anything untill its absolutely neccesery. but querrying a dirty value mostly does propagate a dirty propagation to said point.
Understanding node update scheme in maya is paramount for understanding what and how things work:
when a anodes attribute gets changed maya marks out all downstream attributes dirty (each node knows what attribute affects what output)
Whenever a attribute marked dirty gets requested and its dirty it asks for its predeseccor for its input value (this cascades into a chain of events)
Nothing happens etween theese 2 heppenings so if no ones requesting teh data it will stay dirty indefinitely.
anyway i dont think you need to calculate anything here, because if you set this up smartly you will alwasy know the aswer a bit depending on what you define as origial position offcourse. Thing is that in general rotation aritmetics DONT work like this:
rotation1 - rotation 2 = difference in rotation THis is in general untrue! As euler rirtation cant rely be stacked in thisway, except in localspace asuming only localspace is affected.
One interssing bit of problem here is that your working on data downstream of the keyframe node so setting something underneath it is allways pure, tough it does not stick once you chnage time. Also here its not necceserily a update problem at all but rather a problem releted to teh fact that theres NOBODY asking the fbik to update. Because scren refresh is disabled during your scripttime.
If I'm reading things right, I can get my FBIK to update during my script running time by querying a dirty node? I can get this working if only I can update the actual model to follow the effectors.
The current progress I have is that I can get the effectors all reproduced OK but the actual skeleton doesn't follow them so in the end I have a static skeleton with animated effectors. If I can update the skeleton to the effectors after every frame I can set a key and then everything would work out OK. But since my skeleton doesn't update, even if I set keys the skeleton will stay in the same place and not follow my effectors.
I nearly got this working by using the refresh command. The problem is that if I refresh the effector for the, for example, hand first and tehn the hips, the hand will first move to the correct position but then when the hips move the hand will be in the wrong position from the hierarchical structure of the model.
Ideally I would like to just move all effectors into the position needed for a particular keyframe (which I have accomplished) and then move the skeleton all in one go to snap to those effectors. Then I can key and all will be happy!
Hevent worked with fbik that much because it does indeed refresh wonkily (its tied to the dg in a very peculiar unmayalike way, because each node is slow to eacvt because they act like keyframes). BUt try marking the trasforms in fbik dirty
(inorder for maya to be able to key something kaying occours in wierd update dowstream is fresh upsteram is not way so actuay the keyframe s dirty)
Howevr quick testing does not show any problems. just issuing a full dg refresh was enough. But just in case it isnt you can mark all the trasforms in the fbik dirty! (yu dont need to querry them you can actualy set the dirty cleansstate of them directly)
The main reason I never use fbik is that its sometimes PAINFULL to controll, and this is definitely not one of the hardest issues to controll. More over i can actualy do most of the stuff fbik does with smart rigging so i dontbother sticking my head into the hornets nest