Page 1 of 2
Rotate a bone by traslating other?
Posted: Sun Feb 04, 2007 10:33 pm
by Genete
Hi admired scripters!!.
It could bevery interesting to have a embedded script in a bone layer that let rotate a bone with the traslation of another one. I supouse that it is easy to know the new position of a bone after a traslation. Even very easy to know how much the traslation is in x or y directions.
The slave rotation bones can follow the x coordinate or the y coordinate.
For sure, there must be a conversion between the cartesian coordinates and the rotation anlges. For example an amount of tralation of a value of 1.0 should give a rotation of 360º. a traslation of 0.5 units gives a rotation of 180º, a traslation of -.25 gives a rotation of -90º.
It could be very useful due to several things:
A traslation converted to a rotation is always consistent. I mean that if you traslate a bone an amount of X the slave will rotate an amount of Y. The inverse is nor the same. For example if you rotate a bone and another one follows the traslation coordinate of it it have the same solution for several rotation of the bones. For instance a rotation of 90º produces the same movement of the bone that a rotation of 360+90. Due to the fact that the cartesian coordinates of the slave bone is the same. It is one of the problems of Rasheed's transrotate script(*). The traslation of the slave bone between keyframes is always lineal and not really a curvilinear traslation.
With my pseudo 3D rig using springy mechanisms I can make a curvilinear traslation of a bone with only two keyframes. A rotation of 90 of the master bone is completely different than a rotation of 360+90 of the master bone. The second one describes a whole elliptical rotation plus.
But with my pseudo 3D rig I need rotate two bones to set a new position in the "3D" space of the rigged solid. So if I can rotate
both bones at the same time using the translation of a single master bone it could be
FANTASTIC!!!
Is any scripter over there so kind of write this useful script to me?
Bones:
Master: name of the bone that rotate other bones by it traslation.
Master.x: name of the bone that rotate when Master change its x corrdinate.
Master.y: name of the bone that rotate when Master change its y coordinate.
Thank you for your attention.
Best
Genete
(*) Hey Rasheed! don't think your script is not useful. I'm only trying to get better results.
Posted: Mon Feb 05, 2007 6:08 am
by heyvern
You read my mind!!!
I already have been poking around with Rasheed's script to see if this can be done.
Your description of the value conversions fits in to my simplistic approach. I think this can be done based on Rasheed's existing script.
At first I was trying to do something CRAZY with calculating vectors aiming at the translation bone etc... <sigh>. Just convert the darn numbers! Don't need to point exactly at the bone.
This would solve a HUGE problem with the flipbybones script and my face rig!! If I have a bone that IS TRANSLATING that script works again since the only problem was using constraints! I can link the layer flipping directly to the key framed translated bone!!
Now if someone can write a script that adds more than 24 hours to a day... I would pay money for that.
-vern
Posted: Mon Feb 05, 2007 9:28 am
by heyvern
I did it!
Piece of cake! In reality it was just a mater of applying the x or y value directly to the fAngle with a slight multiplication to scale it up a bit (otherwise you have to drag really far to rotate).
Now I have to "hack" Rasheed's script to eliminate the translation stuff on that bone or just add it in so we can get both rotation to translation and translation to rotation based on bone name extension.
This is COOOL!
What the heck is that "fAngle" value anyway? The number has to be multiplied by 57.3 or something to come close to an actual "angle" in degrees. I ran into this before but I've totally forgotten.
1 degree in the "UI" rotation box = .017453 in the LUA fAngle thingy.
Not important I'm just curious. Probably "hex" or something weird like that. I hate math and it hates me.
-vern
Posted: Mon Feb 05, 2007 9:50 am
by jahnocli
I'm no mathematician (far from it) but I think fAngle is probably in radians. This always has to be multiplied by some number like you quoted to convert it to degrees...
Posted: Mon Feb 05, 2007 9:55 am
by Rasheed
The .fAngle value is expressed in radians. 2 pi radians is equal to 360 degrees. This means that if the radius of a circle is equal to one, the distance along the circumference of that circle is equal to the number of radians.
Posted: Mon Feb 05, 2007 10:19 am
by Genete
Greeeaaat!!!
hey, vern! I cannot wait to you to post the new script!!
Come on!!
Thanks!!!!
Posted: Mon Feb 05, 2007 10:37 am
by heyvern
I should be posting a quick early sample pretty soon.
At the moment I'm trying to figure out how to set the 0 frame position to "0" on subsequent frames. Other wise the controlled rotation bone is already rotated on frames other than 0. I need to include some kind of of "offset" to the translation/rotation calculation for frames other than 0 similar to what Rasheed does with the transrotate portion.
I got both the tranrotate and the rotatetrans in one script. they work great.
I haven't added the y trans yet but that is simple to do. I want to figure out this offset thingy first.
This... is.... wicked jump up and down COOOOL as heck. And so relatively simple to do.
Rasheed... I stole most of the code from you. It is probably total crap the way I did it. I just duplicated everything and made it... unique for each process. So there are two functions for every one function you had.
Your functions do the transrotate, mine do the rotatetrans. It was the easiest way for me to do a proof of concept. I suppose with some effort I could figure out how to combine them into the same functions.
I have not tested this yet with 150 bones doing stuff at the same time... it will probably explode and destroy my computer.
I will still have to add this functionality to the utility script as well since I have to have that when using the flip layer script.... WOOOHOOOO! I can use the flip layer script with this now! YEEEEHHAAAAAA!!!!!
This new thing uses a "standard" translation of a bone so that script will work perfectly.
This is so GREAT!
-vern
Posted: Mon Feb 05, 2007 12:01 pm
by Rasheed
Don't worry about stealing my code. I wrote it for you in the first place, because you seem to have (temporary) problems coding. Looks like I have helped you to take that hurdle to start coding again.
Anyway, I'm used to this. People all around me progress much faster than I. It seems that is just the way things are. Have fun with the code I wrote for you.
In the mean time I'm continuing at my very slow pace with learning how to code in Lua. I still should study
Programming in Lua, because, to be honest, I haven't read it through until now. I have only read those things I needed for my scripts.
Posted: Mon Feb 05, 2007 1:02 pm
by Genete
Anyway, I'm used to this. People all around me progress much faster than I
Come on!. Don't compare you with heyvern! He is incomparable!!
By the way, look to your new avatar! It is great compared with preious! If that is not progress, ... what is it?
Posted: Mon Feb 05, 2007 1:41 pm
by heyvern
Rasheed is ten times the LUA programmer I am... yikes!
Here is a zip file with your 3D eye project Genete.
http://www.lowrestv.com/moho_stuff/RotateTrans.zip
The bone to move is called "rotation". The rotation bones that control the rig are named "rotation.x" and "rotation.y". That's how it works. You have a master bone and two slaves with .x and .y.
At the moment you must have an ".x" bone. The ".y" is optional. Without the x bone the y won't work on its own. I know why this happens and plan to fix it.
Small problem in the example file. Your y rotation bone in your 3Deye file rotates... uh... backwards on the y axis. I didn't fix that so the translation rotation is "backwards" up and down. Dragging the Y axis bone up rotates the bone down... or something like that... I'm not sure now exactly which one is backwards.
I could have stuck in another bone for rotation and reversed it with a constraint... uh... but I didn't.
Also the bones have to be in a specific spot on frame 0 so that the rotated bones aren't "pre-rotated". I didn't figure that part out yet with LUA.
It is fairly simple to find the center spot for the bone and then copy that translation to frame 0.
I really just wanted you to see how it works and maybe Rasheed can look at it and make fun of my horribly redundant code.
There is a ton of stuff in there that needs to be removed (left over stuff from the TransRotate that I left in the functions for RotateTrans). Plus there is a ton of redundant code. Stuff that is duplicated because I was to lazy to do it correctly.
I plan to revise it but it works as is.
-vern
Posted: Mon Feb 05, 2007 1:47 pm
by heyvern
Holy COW!
I just realized what I did... this is amazing. I can use this code to create a "pseudo" translation constraint that can be SPLIT between two bones.
By being able to split the x and y using the bone names a bone could be translated x using one bone and y using another.
-vern
Posted: Mon Feb 05, 2007 1:52 pm
by heyvern
We make a great team I think. I don't ever recall having this kind of back and forth brainstorming resulting in so many fantastic things.
I think the three of us bring out the best in each other.
-vern
Posted: Mon Feb 05, 2007 1:54 pm
by Rasheed
Genete wrote:By the way, look to your new avatar! It is great compared with preious! If that is not progress, ... what is it?
self-mock
I'm not a smoker, and certainly not of The Herb (marijuana), nor a drinker (of alcoholic beverages), so I like to mock myself being such a person, just to tease myself.
I guess this brings me in a creative mood, being tough on myself. Otherwise, I procrastinate, like the animation contest on this forum. I even haven't got a concept. Perhaps I should have slapped myself in the face a few times, and then some more, to start the creative juices...

Posted: Mon Feb 05, 2007 3:25 pm
by heyvern
Oh man... I make things more complicated than needed.
In order to move around the translation rotation control bone with out effecting translation, just make it a child of another bone.
Then you can move the parent any where you want. It has no effect on the child bone which controls the rotation.
This can be used for lots of cool stuff. While playing with it I realized you could make wiggly antennas very easily.
You could also control BOTH ARMS of a character with just ONE BONE.
-vern
Posted: Mon Feb 05, 2007 4:10 pm
by Genete
Oh my god! Holy cow! Good grief!!
(In southern spanish languaje) Ostiaaaaa!!!!
I love you both!!! Yeeeeeeeeeaaaaaaahhhhhh!!!!
It works!!
It doesn't matter if the rotate.y is reversed. Just include a new bone in the middle with reversed rotation contraints and voila!!
Thanks you both men!!
Genete