Notifications
Clear all

[Closed] Flip hand pose

Hi
In some show reel there is a (Flip hand pose_button)by pressing it for example right hand pose comes to Left hand and at the same time the Left hand pose comes to right hand
I know matrix , i know how to mirror a pose of a hand to other opposite one but how to do it at the same time.

Any help ,ages or topic to search and study is appreciated

Thanks in advance

8 Replies

collect matrices in array, flip them, and apply…
it’s better to do it using a structure…

struct MirrorTarget (target, targetTM)
  mirrorData = for bone in skeleton collect 
  (
  	data = MirrorTarget()
  	data.target = findMirrorTarget node
  	sourceTM = getNodeTransform node
  	data.targetTM = mirrorTransform sourceTM data.target
  	data
  )
  for d in mirrorData where isvalidnode d.target do applyTransform d.target d.targetTM 

Thanks denis for the reply
maybe funny , but first time working with srtuct ,i looked in Ms_help it was so basic creating struct ,i work on hand cnt and hand cnt mirror so

A=$c1– which is right hand cnt
B=$c2– which is left hand cnt

fn Mir_of_C1 = —it makes c2 become mirror of c1
(

)

fn Mir_of_C2 = —it makes c1 become mirror of c2
(

)

would you please explain above script for me

i never taught that it was this easy my mistake was instead of


           flipTm=((eulerAngles 0 0 180) as matrix3) *scaleMatrix [-1,1,1] 
           mirrorTm=scaleMatrix [-1,1,1] --Axis to mirror around
           flipTm *($c1.transform*inverse $Main_CNT.transform)*mirrorTm*$Main_CNT.transform
      
   i wrote

           flipTm=((eulerAngles 0 0 180) as matrix3) *scaleMatrix [-1,1,1] 
           mirrorTm=scaleMatrix [-1,1,1] --Axis to mirror around
           $c2.transform = flipTm *($c1.transform*inverse $Main_CNT.transform)*mirrorTm*$Main_CNT.transform
     
      
   so i face a problem to get both fliped TM at the same time and were looking for a fancy solution for it.


   Here it is the script hope handy for some    

       rollout flipping "Flip" width:100 height:50
       (
       	button Flip "Flip it" pos:[7,7] width:87 height:21
       
       
       fn flip_it =
       (
       
       	
       	flip_c2 =
       	(
       	flipTm=((eulerAngles 0 0 180) as matrix3) *scaleMatrix [-1,1,1] 
       	mirrorTm=scaleMatrix [-1,1,1] --Axis to mirror around
       	flipTm *($c1.transform*inverse $Main_CNT.transform)*mirrorTm*$Main_CNT.transform	
       	)
       	
       
       
       	flip_c1=
       	(
       	flipTm=((eulerAngles 0 0 180) as matrix3) *scaleMatrix [-1,1,1] 
       	mirrorTm=scaleMatrix [-1,1,1] --Axis to mirror around
       	flipTm*($c2.transform*inverse $Main_CNT.transform)*mirrorTm*$Main_CNT.transform	
       	)
       	
       	$c1.transform=flip_c1
       	$c2.transform=flip_c2
       )
       
       on Flip  pressed do
       (
       	flip_it ()
       )
       
       ---------==========================	
       )
       createDialog flipping 100 50
       
       --creating scene geometry
       	delete objects
       Teapot name:"C1" radius:16 smooth:on pos:[-50,0,0] wirecolor:yellow
       Rotate $c1 (EulerAngles 0 0 -90)
       Teapot name:"C2" radius:16 smooth:on pos:[50,0,0] wirecolor:Orange
       Rotate $c2 (EulerAngles 0 45 -90)
       Circle name:"Main_CNT" radius:16 pos:[0,0,0] wirecolor:red
       
   and i still don't know how to use this with strut hope sb leave a post
 eek

Hi Jaber,

This might be similar to other replies but anyhow:

I try to handle mirroring as simply as possible, basically all your really doing is transforming a stored transform space by a scale matrix which basically will cause a skewed transform a right handed matrix becomes a left handed one. Then after this transform i apply the scale matrix again to this skewed transform to push the transform back into its original handedness.

An example being when you hold you hand in front of a mirror your seeing your palm in the mirror reflected but your facing the back of your hand – so you need to in the reflected image flip the hand again.

So this is my math:

m0 = $rectangle001
p0 = $point001

mirror_vector = [1, -1, 1]
mirror_tm = (p0.transform * inverse m0.transform)
p0.transform = (scaleMatrix mirror_vector) * (mirror_tm * (scaleMatrix mirror_vector) * m0.transform)

So first of we have a mirror vector this is the axis we are flipping against. Then we store a mirror transform essentially this is the objects transform relative to a mirror plane. Now we scale this stored transform along our mirror vector to give a skewed transform (original handedness will be flipped along one axis). Now we need to finally flip the handedness back so we multiple the mirror vector as a scale matrix by this skewed transform.

So in a simple function:

fn mirror_transform source target vec:[1,-1, 1] =
(
	target_tm = (source.transform * inverse target.transform)
	return (scaleMatrix vec) * (target_tm * (scaleMatrix vec) * target.transform)
)

Then all we do is use this function to store the mirrored transforms of the hands relative to a transform – hips , the world etc… (could be just rotation transform) and then apply the opposite hand to the opposite transform.

So something like this (rough):

fn flip_transforms source_a source_b target vec:[1, -1, 1] =
(
	source_a_tm = mirror_transform source_a target
	source_b_tm = mirror_transform source_b target

	return #(source_a_tm, source_b_tm)
)

tms = flip_transforms $point001 $box001 $rectangle001 

$point001.transform = tms[2]
$box001.transform = tms[1]

Thats it roughly,

cheers

sorry_mistake

Thanks Charles Thanks so much for the good points, clear description and beautiful scripting.
My goal in above script was ,in a character IK mode,right hand get left hand pose and stay at its position so i wrote that way.
Your reply raises a question.
The only thing i know about Right handed matrix is


  dot (cross $.transform.row1 $.transform.row2) $.transform.row3 > 0
  

if this code returns ‘True” it means the objects has Right handed matrix otherwise left handed matrix.so i run this code before mirroring and after mirroring because the result was the same (True), so i taught that’s ok.

If it is not the way, how to know about Right handed matrix and left one.
as a rookie animator and rigger forgive me to ask this,but what happen if Right handed matrix becomes left handed matrix.

Thanks

1 Reply
 eek
(@eek)
Joined: 10 months ago

Posts: 0

So its really a decision as a rigger you need to take on the functionality of the rig. When one side of the rig is right-handed and the other is left-handed you can pose the rig symmetrically really easily – you just need to select both sides and rotate in gimbal/local/object space. You sidedness needs to on a plane that both systems revolve around E.g. if you select left and right upper arms and rotate forward they should both rotate forward where as if you rotate them out they should both rotate opposite from each other outwardly. So thats your plane of handiness.

Crucially though you want to try you maintain handiness through the hierarchy for each side – you don’t want the upper arm in a right-handed system and then the forearm in a left-handed system, because now your parent space essentially has a non-uniform transformed wedged between the two.

Remember in a child-parent relationship, the child’s transforms essentially lives in the space of its parent, so if the child’s transform is in an opposite handiness it basically inherits a non-orthogonal scale transform from its parent. If you rotated it against its parent to align its handedness with its parents, I think its handed axis would get scaled to 0 < Bad. – (I haven’t tried this, just theorizing it).

So you have to be careful when combining handiness, you need to use axis’ and there order to allow inherited transforms to not have sheered transforms. < This is very important to understand.

I tend to keep the rig entirely right or left and never a mixture of the two – but this is really because I’ve built tools to do the mirroring, flipping etc. Rigs based purely in the viewport may want a mixture of the both to allow direct mirrored posing. Mirroring becomes easier but flipping is a little more trickier.

cheers,

Thanks to take your time and answer this tread
Thanks