world angle of bone?

Moho allows users to write new tools and plugins. Discuss scripting ideas and problems here.

Moderators: Víctor Paredes, Belgarath, slowtiger

Post Reply
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

world angle of bone?

Post by davoodice2 »

hi?
how can i achieve that?
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
hayasidist
Posts: 3551
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: world angle of bone?

Post by hayasidist »

2d case : i.e. no rotation about x/y

for a root bone (i.e. one without a parent) bone.fAngle is absolute; for a child bone bone.fAngle is relative to its parent so (e.g.) two bones - one root, one child - pointing down will have angles 270 and 0 respectively.

those are relative to the layer; so if (e.g.) the layer is rotated in z by (say) 90 then bone.fAngle is unchanged, but the bone will be pointing to the right - i.e. world 90+270 (or that mod 360 = 0)
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

Re: world angle of bone?

Post by davoodice2 »

hayasidist wrote: Mon Nov 15, 2021 11:45 am 2d case : i.e. no rotation about x/y

for a root bone (i.e. one without a parent) bone.fAngle is absolute; for a child bone bone.fAngle is relative to its parent so (e.g.) two bones - one root, one child - pointing down will have angles 270 and 0 respectively.

those are relative to the layer; so if (e.g.) the layer is rotated in z by (say) 90 then bone.fAngle is unchanged, but the bone will be pointing to the right - i.e. world 90+270 (or that mod 360 = 0)
that means I must calculate sum of all rotations ?
is there shortway? or function?
and how to define a vector that doesn't start from 0,0
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
User avatar
hayasidist
Posts: 3551
Joined: Wed Feb 16, 2011 8:12 pm
Location: Kent, England

Re: world angle of bone?

Post by hayasidist »

depends what you're trying to do ... you might find that a bone transform matrix (fRest or fMoved) will do what you want -- or you might find it makes sense to use a Matrix to accumulate the rotations and translations.

as for vectors that don't start from {0,0} ... well at the risk of totally misunderstanding what you're thinking here ... an LM_Vector2 has an x value and y value, so if you want your vector to start at {X0, Y0} and go to {X1, Y1} you can store those two vectors exactly like that - or if you have a vector that is {dX, dY} wrt {0,0} then X1=X0+dX, Y1=Y0+dY - either store dX,dY and remember to add - or add and store the result
User avatar
davoodice2
Posts: 381
Joined: Tue Jun 15, 2021 1:14 pm

Re: world angle of bone?

Post by davoodice2 »

hayasidist wrote: Mon Nov 15, 2021 3:30 pm depends what you're trying to do ... you might find that a bone transform matrix (fRest or fMoved) will do what you want -- or you might find it makes sense to use a Matrix to accumulate the rotations and translations.

as for vectors that don't start from {0,0} ... well at the risk of totally misunderstanding what you're thinking here ... an LM_Vector2 has an x value and y value, so if you want your vector to start at {X0, Y0} and go to {X1, Y1} you can store those two vectors exactly like that - or if you have a vector that is {dX, dY} wrt {0,0} then X1=X0+dX, Y1=Y0+dY - either store dX,dY and remember to add - or add and store the result
thanks. i will some test . i'll come back with more questions :D
خیام اگر ز باده مستی خوش باش
با ماهرخی اگر نشستی خوش باش
چون عاقبت کار جهان نیستی است
انگار که نیستی چو هستی خوش باش
Post Reply