[Closed] mirroring pose by another object position
Hi
i did my best to write pose mirroring.after that i try to mirror a pose of an object based on position of another object (Here anchor which is a point). the guy on scriptspot did it ( http://www.scriptspot.com/3ds-max/scripts/sox-mirror-tool ) but i couldn’t find what he did this is my script change the c1 rotation and position then push button. you can move Anchor then push the button
—————===========start
rollout Mirror_C “Mirror” width:100 height:100
(
button Cm1 “Mirror Left_Arm” pos:[7,7] width:87 height:21
——==================================
on Cm1 pressed do
(
tm1 = $C1.Transform
--Mirror the tm across the world matrix in x axis
mirroredTm=tm1*(scaleMatrix [-1,1,1])
$c2.transform=(scaleMatrix [-1,1,1])*($c1.transform* $Anchor.transform)*(scaleMatrix [-1,1,1])*$Anchor.transform
finalTm=(scaleMatrix [-1,1,1])*mirroredTm*$Anchor.transform
$C2.transform=finalTm
)
)
createDialog Mirror_C 100 100
c3=Circle name:“CNT” radius:20 wirecolor:yellow
c3.pos=[0,0,0]
c2= box name:“c1” wirecolor:blue height:60
c2.pos=[50,0,0]
c1= box name:“c2” wirecolor:Red height:40
c1.pos=[-50,0,0]
c2.parent =c3
c1.parent =c3
Anch= Point name:“Anchor” axistripod:on size:80 wirecolor:Green
Anch.pos=[0,0,0]
————————-=======End
OK-when the anchor moves no problem the c2 will mirror c1 pose in defined Anchor position.
Now problem is
1_when you move Anchor and c1 together , c2 add c1 and Anchor position and is ahead of c1. and 2_I don’t want c2 follow or mirror Anchor’s rotation
Any help will be appreciated
Thanks in advanced
interesting… the mirroring a pose is one of the most essential tasks in character rigging. a rigger who provides this feature with his rig puts himself on a different stage.
for me your question sounds like you want to jump over a gap between newbie and pro rigging level. hmm… IMHO … the things don’t work this way.
if you want to know how to mirror a transform matrix by some axis… well ask it
The way to do this like you are asking is to mirror the offset of the C1 from the Anchor.
Take a look ( I also added a way for you to mirror pos only/ pos/rot or rot only).
BTW this will not solve all your problems and will give you issues if you do not actually know how to properly use it. Your example was flawed to begin with… it seems to me that Dennis had a point, but I will give an answer using information found in this Forum you should try and search it next time you would have found your answer.
rollout Mirror_C "Mirror" width:100 height:100
(
button mirrorLeftBt "Mirror Left_Arm" pos:[7,7] width:87 height:21
radioButtons applyRadio labels:#("pos", "pos/rot", "rot")
on mirrorLeftBt pressed do
(
finalTm = (scaleMatrix [-1,1,1])*($c1.transform*inverse $CNT.transform)*(scaleMatrix [-1,1,1])*$CNT.transform
case applyRadio.state of
(
1:
(
$c2.pos = finalTm.pos
)
2:
(
$c2.pos = finalTm.pos
in coordSys (transMatrix $c2.transform.pos) $c2.rotation = inverse finalTm.rotation
)
3:
(
in coordSys (transMatrix $c2.transform.pos) $c2.rotation = inverse finalTm.rotation
)
)
)
)
createDialog Mirror_C 100 100
(The way to get the offset of a node in relation to another node is to multiply its transform by the inverse of the second node, offset = Tm1.transform* Inverse Tm2.transform)
you forgot about mirroring… mirroring a transform matrix is very far from a mirroring a pose (hierarchy)
I forgot? with what you quoted I was just explaining how to get an offset…
But yeah the code I posted would not work for mirroring a hierarchy(pose) that is a different story.
Thanks Felipe for your reply.
I just want to get my idea either in Matrix way or the way that you suggest. this guy
(( http://www.scriptspot.com/3ds-max/scripts/sox-mirror-tool )) did this and it is a ms file easily open not a showreel, but unfortunately i am new in maxscript so i cant udrestand what he did, i do my best i’m sure that it is possible maybe denisT is right not in Matrix way
thanks anyway.
Denist I think jabermax2 is right, maybe as you said it has nothing to do with The matrix
but the process of mirroring has effected by the object which is not the parent of
mirroring obnject. i made a video to show it its on vimeo https://vimeo.com/106852696
—–( http://www.scriptspot.com/3ds-max/scripts/sox-mirror-tool )
mirror a transform is not a problem.
here is a snippet:
global MirrorDialogPos = unsupplied
try
(
MirrorDialogPos = getdialogpos MirrorDialog
destroydialog MirrorDialog
)
catch()
rollout MirrorDialog "Simple Mirror" width:200
(
radiobuttons axis_rb labels:#("X","Y","Z ")
button mirror_bt "Mirror Selection" width:192 align:#right offset:[8,0]
local axis_types = #(#x, #y, #z)
fn oppositeTM tm axis:#x nodes: =
(
local rot_tm, ntm
if ini == unsupplied do ini = tm
local xm = case axis of
(
#x: (matrix3 [-1,0,0] [0,1,0] [0,0,1] [0,0,0])
#y: (matrix3 [1,0,0] [0,-1,0] [0,0,1] [0,0,0])
#z: (matrix3 [1,0,0] [0,1,0] [0,0,-1] [0,0,0])
default: (matrix3 1)
)
tm * xm
)
on mirror_bt pressed do undo "Mirror" on
(
for node in selection as array do node.transform = oppositeTM node.transform axis:axis_types[axis_rb.state]
)
)
createdialog MirrorDialog pos:MirrorDialogPos
but there are a lot of issues after…
what if we need to prevent negative scale
what if a node has a parent
what if we want to mirror a node in parent space
what if a node have list transform controllers
…
that’s all makes simple ‘mirror transform’ very complicated in general case ‘mirror pose’.
I think i get back to the school time,as a lazy student always asking questions.
as far as i know one way to learn Maxscript is opening other people’s script and learn how did they
do that.The guy in scriptspot create a Ms file , and was kind enough to share it in MS file.
but just like jabermax2 i’m a beginner the guy make script complicated by adding cat and biped and i had no chance to understand beside that script work fine for a hand CNT or atleast for me at this level of rigging and scripting, and i know that its not a polite way to ask sb go there see tell me…
think better for me to quit from this issue now.