CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »  
 
Thread Tools Search this Thread Display Modes
Old 11-19-2013, 07:08 PM   #1
mrfred
PRO
portfolio
fred
Canada
 
Join Date: Mar 2012
Posts: 123
Issue mirror transformation

I never really had any issue mirror rotation until I stumbled onto this:
how to "mirror" those 2 points:
Code:
point transform:(matrix3 [-0.0744505,0.102782,-0.991914] [0.900617,-0.420165,-0.111136] [-0.42819,-0.901608,-0.061286] [-41.0417,2.50814,301.575]) name:"LeftPoint" point transform:(matrix3 [0.110613,0.061457,-0.991962] [0.958345,0.257846,0.122839] [0.263323,-0.964229,-0.030376] [41.0417,2.50804,301.575])name:"Rightoint"


What I'm actually looking for is to mirror the local X axix rotation value

so let's say that point001 is rotated 15 degree on the x axis I need to have the opposite roll value on the other side.

I need to keep the overall same direction (don't flip axis) SHould I just mirror the whole thing and fix the axis back as to how I want them ?
 
Old 11-19-2013, 08:46 PM   #2
Klunk
Lord of the posts
 
Klunk's Avatar
portfolio
Klunk
United Kingdom
 
Join Date: Sep 2005
Posts: 701
quick and dirty method

Code:
tm = $.transform; tm[1] *= -1; $.transform = tm;


sorry just read the final part of your post but to actually "mirror" you need to flip an axis otherwise your just rotating 180 degrees around the z axis which is not the same ?

Code:
$.transform = ((eulerangles 0 0 180) as matrix3) * $.transform

or
Code:
$.transform = prerotateZ $.transform 180;

which is the same thing and the same as rotating 180 degrees about the local z axis in the viewport and very similar to the axis flip above but with the additional flipping of the y axis.

Last edited by Klunk : 11-19-2013 at 08:59 PM.
 
Old 11-19-2013, 09:09 PM   #3
mrfred
PRO
portfolio
fred
Canada
 
Join Date: Mar 2012
Posts: 123
thanks, but those solution doesn't give me the desired result

I managed to get the desired "mirror" effect using this function
Code:
fn MirrorRollAxis Source Target = ( pointParent = point name:"Point_Parent" pointSource = point name:"Point_Source" pointSource.parent = pointParent pointSource.transform = Source.transform pointParent.transform = prescale pointParent.transform [-1,1,1] pointSource.transform = prescale pointSource.transform [1,-1,1] target.transform = pointSource.transform delete pointParent;delete pointSource )

But I dont like having to create node just to get the desired result :/
 
Old 11-19-2013, 09:49 PM   #4
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,432
Send a message via ICQ to denisT
post the scene and say what objects you want to mirror

(please give a file with max version <= 2012)
 
Old 11-19-2013, 09:53 PM   #5
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,432
Send a message via ICQ to denisT
the situation might vary. it depends on:
# are mirroring objects children of the same parent
# are they originally flipped against each other
# can they be translated (rotated, scale)
# etc.

the math is simple... you have to multiply transform one with mirror matrix.
for x axis in absolute coordinate system it's:
Code:
x_mirror_tm = matrix3 [-1,0,0] [0,1,0] [0,0,1] [0,0,0] delete objects p1 = point name:"R point" pos:[10,0,10] rotation:(eulerangles 45 60 70) axistripod:on box:on cross:off wirecolor:green p2 = point name:"L point" axistripod:on box:on cross:off wirecolor:yellow p2.transform = p1.transform*x_mirror_tm

Last edited by denisT : 11-19-2013 at 10:03 PM.
 
Old 11-19-2013, 10:17 PM   #6
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,432
Send a message via ICQ to denisT
Quote:
Originally Posted by mrfred
Code:
point transform:(matrix3 [-0.0744505,0.102782,-0.991914] [0.900617,-0.420165,-0.111136] [-0.42819,-0.901608,-0.061286] [-41.0417,2.50814,301.575]) name:"LeftPoint" point transform:(matrix3 [0.110613,0.061457,-0.991962] [0.958345,0.257846,0.122839] [0.263323,-0.964229,-0.030376] [41.0417,2.50804,301.575])name:"Rightoint"


I need to keep the overall same direction (don't flip axis)


in your case the method should be modified a little:
Code:
x_mirror_tm = matrix3 [-1,0,0] [0,1,0] [0,0,1] [0,0,0] delete objects p3 = point transform:(matrix3 [-0.0744505,0.102782,-0.991914] [0.900617,-0.420165,-0.111136] [-0.42819,-0.901608,-0.061286] [-41.0417,2.50814,30.575]) name:"LeftPoint" wirecolor:red p4 = point transform:(matrix3 [0.110613,0.061457,-0.991962] [0.958345,0.257846,0.122839] [0.263323,-0.964229,-0.030376] [41.0417,2.50804,30.575]) name:"Rightoint" wirecolor:blue p5 = copy p3 transform:(p3.transform*x_mirror_tm) wirecolor:orange p5.transform = prescale p5.transform [1,-1,1] resetscale p5
 
Old 11-19-2013, 10:22 PM   #7
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,432
Send a message via ICQ to denisT
or ...
Code:
x_mirror_tm = matrix3 [-1,0,0] [0,1,0] [0,0,1] [0,0,0] delete objects p3 = point transform:(matrix3 [-0.0744505,0.102782,-0.991914] [0.900617,-0.420165,-0.111136] [-0.42819,-0.901608,-0.061286] [-41.0417,2.50814,30.575]) name:"LeftPoint" wirecolor:red --p4 = point transform:(matrix3 [0.110613,0.061457,-0.991962] [0.958345,0.257846,0.122839] [0.263323,-0.964229,-0.030376] [41.0417,2.50804,30.575]) name:"Rightoint" wirecolor:blue p5 = copy p3 transform:((prescale p3.transform [1,-1,1])*x_mirror_tm) wirecolor:orange
 
Old 11-19-2013, 10:22 PM   #8
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,480
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 09:55 PM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.