Page 9 of 16

Posted: Fri May 18, 2007 6:22 am
by capricorn33
human wrote:Capricorn, I wanted to complain that your modesty is a bit misplaced. /.../ Hope to see much more--and learn from you.
Oh, I'm a finn... you see. We're supposed to be a little modest (compared to americans in general, anyway... :wink:) It's in the national character or maybe in the genes, I don't know. I just can't help it. :)

BTW, apologies if you still get a lot of popups and other annoyances trying to open my files... (I just noticed that I had problems myself with the lycos site) I really need to get another host for my uploaded files...

Posted: Fri May 18, 2007 10:21 am
by Genete
heyvern wrote: The numbers aren't "exact" so it... it would have to be some funky kind of conversion... using the bone name might be easier.

-vern
Sorry but this is hilarious... :lol: Numbers are the only exact thing in this world!!

If we were talking about traditional animation (frame by hand made animation) we can talk about a sort of "intuitive artistic animation" apart of any kind of math concept. But man!, every single piece of animation you do in Anime Studio is plenty of maths and numbers (in fact ALL in Anime Studio have a numeric value) and then there is an "exact" relationship between every tool and its effect. In fact the greatness of Anime Studio (and any other good animation programs) is that it allows the user to have exact control of (almost) every thing that the program can do (most of my feature request go in the sense of have more detailed control) , and, at the same time, hides them behind an intuitive interface to allow those "intiuitive artistic animators" to work with them wothout taking care about any kind of maths.
A good example of a bad interface is the color chooser that currently Anime Studio has. It is poorly intuitive and most of us wanted a color picker for the next version.

What a pity that you (that have programming skills) don't have enough math knowledge and that I (that have maths skills) don't have lua programming knowledge!.

-G

Posted: Fri May 18, 2007 2:10 pm
by heyvern
I promise to respect the numbers! ;)

Yes, I admit I suck at math.

What I meant about the numbers not being "exact" is that there is no... "logical" relationship between a bones translation/rotation/scale. I use the values as they are in the AS lua scripting to convert them. It doesn't always make mathematical sense.

For instance in AS, scale IS based on 1.0 = 100%. So if I use lua to change the scale of a bone... it is a recognizable value... 50% = 0.5. Exactly as it appears in the AS interface. BUT... If I use lua to access a bone's rotation... I don't get "53.5 degrees" or "23.9 degrees", I get a number that must be multiplied times 57.29 and then I "round it up" to get something at least close to the actual key frame value in AS.

These numbers need to be modified so a small translation of a bone will rotate another bone without having to drag it "off the screen into the next zip code". ;)

If translation = rotation in a script I have to determine a "random" amount of translation to rotate a bone, this would be based on what "size" my interface is. So these numbers are never... related. They don't have any logical correlation to each other in the script. To translate a bone by rotating another bone you don't want to have to "wind the bone" 50 times.. or maybe sometimes you do! ;)

------

Genete, can you give me a math formula for converting any min/max value to 0-1 or to 1-10 etc?

For example if I have two values that are "0.567" and "1.345" how would I convert that so it represents (roughly) a range between "0 and 1" (scale) or "0-360" (rotation)?

I can do this... but my math is always... simplistic and verbose to get there. I'm hoping there might be a simpler formula... these things make my brain ache.

p.s. I can do some math on my own. ;) I am writing a script that converts bone rotation to switch layer switching. Works great so far. I just divide 360 degrees (or 180... haven't decided yet) by the number of layers in a switch. When the bone rotates past each value the target switch layer gets keyed for that layer.

Switch keys are based on the bone's rotation only at the key frame so you never have to touch the switch layer.

-vern

Posted: Fri May 18, 2007 2:24 pm
by jahnocli
heyvern wrote:I get a number that must be multiplied times 57.29

I suck at math too, but I can understand this bit -- the angles in lua must be expressed in radians, not geometrical angles like 27 degrees...(I think radians are easier to work with as a programming construct. I don't know for sure, I'm guessing -- like I said, I suck at math too...)

Posted: Fri May 18, 2007 3:41 pm
by heyvern
Yes, someone else mentioned radians regarding this issue...

... radians shmadians... I still have to multiply it by 57.29. ;)

p.s. Funny story. Recently I was getting frustrated because my switch layer script wasn't working when I thought it should. I was dividing 360 by the number of layers... but I was using the "raw" rotation value for the unit to change the switch layer.

I forgot about that whole radians thingy.

I'm an artist... 2 + 2 = 4... unless... it would look prettier if it equaled 5... (or you have a cage with rats in it on your head) ;)

-vern

Posted: Fri May 18, 2007 4:24 pm
by jahnocli
heyvern wrote:you have a cage with rats in it on your head
That's not 4. It's 1984...

Posted: Fri May 18, 2007 4:53 pm
by Genete
The "magic factor that you're talking about is 57,295779524 that is number is the result of dividing 360 degrees between 2*pi. That means that 57,295779524 is the amount of degrees of a radian. (You're right Jahnocli and it is not the firs time...)

So, don't convert the angles given in radians in lua script to degrees unless you need to show to the user a numerical value or an input value. Work internally always with radians.

FORMULAS
:arrow: To convert a rotation into a translation.

Case A) I rotate a bone from alpha= 0 to alpha=360 (from 0 to 2*pi radians) and want other bone to translate from X0 to X0+L and to X0-L (being L a known value and X0 the center of oscillation) I assume that we are talking always to modify the x coordinate of the slave bone:

X=X0+L*sin(alpha)
where sin = sine a trigonometric function. the alpha value must be in radians when write the script. You should look the lua API to be sure of that.
For this case if you continue rotating the master bone until let say 480 degrees the slave bone would continue oscillating properly between X0 + L and X0 -L.


Case B) I rotate a bone from alpha = 0 to alpha = ANY VALUE and want the slave bone to translate continuously an amount of L for every turn I give to the master bone (like a car jack). In this case you have to make the calculus in two steps.

Let's do N=alpha/(2*pi) and truncate N to an integer number. Now N have the amount of turns that you have done with the master bone. It is important that you truncate and not round N
Then now you can do:
X= X0 + L*N + L*sin(alpha)

NOTE: I assume that master bone angle is 0 at frame 0. If not alpha is the difference between the current angle and the angle at frame 0.

:arrow:To convert a translation into a rotation.
I think it make sense only the inverse of the case B).

Case B) I translate a bone and then other bone rotates (like if you pull a car jack)

Let's make the inverse formula:
Let's be X0 the original place of the bone (at frame 0) and X the current position.

N=(X0-X)/L you should truncate N also to be integer. N can be negative of course.
alpha = alpha0 + N*2*pi + arcsine((X-X0)/L -N)
where arcsine = arcsine a trigonometric function (inverse of sine)
Where alpha0 is the angle at frame 0 and L have the same meaning that previously.

SOME HINTS WITH THE SCALE TOOL:

Let's be M0 the length of a bone at frame 0. It untouched scale is 1.
Let's make S the scale of the bone at any other frame than 0.
Then its length becomes:
M=M0*S (simple isn't it?)

So to convert a rotation into a bone scale is as simple as making the scale of the bone equal to the sine of the angle of the master bone:
S=sin(alpha)

The inverse is also easy you have only to do the same steps than in the B case o f rotate by translation but now X0=0 and L=M0.

:arrow: One curios thing:

If a bone is constrained by other in the scale value then the formula is different than the easy one.
M=master length; L=slave length

M=M0*S

-->> L = L0(1+S). SO THE SLAVE SCALE VALUE IS (1+S) AND NOT 'S' AS YOU CAN IMAGINE.

:arrow: Last remark: HOW A BONE SCALE AFFECT TO A MESH:

Please watch this file:
http://genetita.googlepages.com/flipbone.anme

The scale of a bone affects the same to all the points in its local coordinate system. But more away are the point more quick is the movement of the point for the same scale and vice versa. Same comment applies to any other bone that is linked to the bone that is being scaled.

Hope this quick math lesson help you in your script an definitively you can post those cool scripts that you have done in your sticky are in the Scripting forum (copy / paste bones, rotate trans, trans rotate, scale rotate, rotate switch, and so on...) :wink:

Best
Genete

Posted: Fri May 18, 2007 5:55 pm
by heyvern
Woohooo!

Thanks Genete! Great stuff. Can't wait to play with those formulas.

-vern

Posted: Fri May 18, 2007 5:58 pm
by Genete
Hope this quick math lesson help you in your script an definitively you can post those cool scripts that you have done in your sticky area in the Scripting forum (copy / paste bones, rotate trans, trans rotate, scale rotate, rotate switch, and so on...) :wink:
you're welcome :D

Posted: Fri May 18, 2007 7:17 pm
by capricorn33
DK wrote: Cap: You have discovered something there. Verticle movement via the translate tool :)

D.K
Yup, so now I've tried to work a little on that one... The tilting of the lion's head is controlled by translating the bone on the right. Try it.

http://members.lycos.co.uk/hasse/AS/lion_tilt_cap.mov
http://members.lycos.co.uk/hasse/AS/lion_tilt_cap.anme

You can get quite nice (moderate) tilts with this technique. And it's very simple, once you have understood DK:s idea with different scaling amounts to the different layered objects (...the "trex"-trick...)

You simply use incrementing translation values to the same bones that you use for the sideways scaling...!

Only ONE bone added to get this effect!!! Nice, isn't it! :D

I hope you guys can find some use for this.

Posted: Fri May 18, 2007 7:23 pm
by Genete
capricorn33 wrote:
DK wrote: Cap: You have discovered something there. Verticle movement via the translate tool :)

D.K
Yup, so now I've tried to work a little on that one... The tilting of the lion's head is controlled by translating the bone on the right. Try it.

http://members.lycos.co.uk/hasse/AS/lion_tilt_cap.mov
http://members.lycos.co.uk/hasse/AS/lion_tilt_cap.anme

You can get quite nice (moderate) tilts with this technique. And it's very simple, once you have understood DK:s idea with different scaling amounts to the different layered objects (...the "trex"-trick...)

You simply use incrementing translation values to the same bones that you use for the sideways scaling...!

Only ONE bone added to get this effect!!! Nice, isn't it! :D

I hope you guys can find some use for this.
Let heyvern read this post and then you can understand the POWER of constraints... :wink:

BTW Nice!

Posted: Fri May 18, 2007 9:39 pm
by heyvern
Yeehaa!

I love that lion.

Here is a down and dirty version with one bone control.

http://www.lowrestv.com/character_rig/l ... ontrol.zip

I wrote a simple script that converts translation to scale to the bone for turning left/right along with a scale constraint for the two scale bones.

So now moving the one bone turns the head in any direction.

-vern

Posted: Fri May 18, 2007 9:51 pm
by heyvern
One thing I've noticed with these rigs.

You guys are binding points to specific bones. This works great... but I am trying to come up with a system that won't require binding. So you could drop in a different "face" and it would just work.

There of course would be some tweaking of certain bone position and constraints to account for different types of face shapes. Point binding would require both binding the right points AND modifying the bones. ;)

My technique however uses region binding, and also requires more bones and using bone offset to "lock" things down properly.

-vern

Posted: Fri May 18, 2007 10:12 pm
by capricorn33
heyvern wrote:Yeehaa!

I love that lion.

Here is a down and dirty version with one bone control.

http://www.lowrestv.com/character_rig/l ... ontrol.zip
Hey, that was fun, vern!!! Thanks! :D :D

I have been dragging that lion's face around on my screen for five minutes now, can't stop, giggling to myself all the time... like a child with a brand new toy. :)

Posted: Fri May 18, 2007 11:39 pm
by human
capricorn33 wrote:After lots of failures and a thousand headaches I got it this far... I'm only guessing all the time with the all the scaling parameters and bones placements... Would be nice to know how to go about it when you start building a new model. How to PLAN it. (I'm looking forward to that tutorial which I hope someone will write someday... :D )
If you were ready to write the tutorial now you wouldn't refer to "someday"--I understand this.

But I'd love to see you explain the fundamentals of "start building a new model."

Are you able to give us a rough overview of what you will do when you start on your next model?

If not you, Cap, then DK?

Or Vern?