Sep 2012
1 / 3
Sep 2012
Sep 2012

Hi, I know this has been talked about but i still haven't found the solution i'm looking for. I"m modeling something off axis and i want to be able to control the mirroring, possibly by a gizmo. So say i mirror 35 degrees on the y and 15 degress on the x. Does anybody know of any scripts that can achieve this? In max this would take 2 seconds to achieve. I'm finding this frustrating.

Any help is much appreciated 

  • created

    Sep '12
  • last reply

    Sep '12
  • 2

    replies

  • 1.1k

    views

  • 1

    user

Well you could do this. However its almost impossible to please a person who is doing a feature by feature comparison between any two software. This is a sort of philosophical thing, once you determine that feature X is ultimate and must be replicated at all cost the game is lost. The person making this assumption has lost the game, he can never change his application ever. It leads to a complete mental freeze. The reason is that at a system design level certain core choices lead to different, possibly better/worse feature by feature designs. As a result you gain some and you loose some functionality. Now what should matter is whether or not you ultimately gain more from the transition. So the key to successful migration is acceptance of loss and willingness to learn things anew. Doing this can help you even to understand your first application better. Maya can never be max or the other way around.

Now  you cant actually have the exact same end result, period. If you wish for that then you will for reasons explained above be forever unhappy. So stop reading at once. But if your willing to accept some loss then ill outline a way that may or may not work for you.

What is mirror? Its the act of translating. Applying same manipulation across some transformation. Conceptually this is easy just select the corresponding vertices and make same thing over the data in the replicated item. But alas for maya its not that easy maya would need to understand this on a node by node basis (remaking maya form scratch), or ignore construction history altogether. Neither option is really acceptable. But if you'd be willing to sidestep the construction history part and the devs would allow me to access the api calls that govern mirror then it wouldn't be much of a problem but they dont. Not that anyone would be happy with this anyway.

Well so the nodes dont understand mirror, right. But do they have to? No not really. See maya allows you to replicate the result of any complete history tree. So if i would fork my history and merge it back to my history i could do this. Bad ascii art follows:

             +-> S1 
            /      \
A -> B -> C          M -> S3
            \      /
             +-> S2

Since maya allows you to do this you can sidestep the problem elegantly. Just one more problem. Conceptually the gui works on S3 so whatever you modify would go back to the history after M whereas you want the data to go back after C. Now maya can redirect your actions, however it can not redirect shape edits as freely to account for the numbering change*. So you couldn't easily modify the shape + its mirror parts on the fly. However you can still edit S1 and it will do what you want. And here is where the hack begins to unfold.

See what you do is you make S3 a reference, possibly hide S2, and make S1 and S2 non shading This mans that whenever you try to manipulate S3 it activates S1 or S2 instead and your actions go to S3 seamlessly. However this is a bit fo a jumble to work with as it has some drawbacks. But only if you want to edit the stuff later with mirroring data intact mind you.

Still some convolution regarding making sure the mirror plane does not break, can be handles but again YMMV.

So then let me demonstrate this for you with a small scene (this is not really a script that does a mirror its a scene, but run it as a script anyway. I didn't write anything just pasted my log here. Paste into script editor select all and hit ctrl+enter):

file -f -new;
polyPlane -w 0.5 -h 1 -sx 5 -sy 10 -ax 0 1 0 -cuv 2 -ch 1;
move -r -os -wd 0.25 0 0 ;
polyExtrudeFacet -ch 1 -kft 0 
                -ltz 0.3 pPlane1.f[19] pPlane1.f[28];

Heres the thing we need to mirror. Now the mirror is easy just copy this one and scale it by -1. ( continue running)

duplicate -rr -instanceLeaf;
scale -p  0 0 0 -a -1 1 1;
move 0 0 0 pPlane2.scalePivot pPlane2.rotatePivot ;
setToolTo $gRotate;
rotate -r -os 0 0 -30;

Now you have a mirror with arotate ability (you can select thsi rotate whever you want to change the mirror plane). And for obvious reasons you can move or rotae or even scale the counterpart as you wish.

Ok a few ods and ends. The uv did not mirror, but taht cant be handled because the meshes are the same to every level except transform. Lets test this by moving points in one of the meshes:

select -r pPlane1.vtx[5] pPlane1.vtx[11] pPlane1.vtx[17] ;
move -r -os -wd 0.2 0 0 ;

See instant replication. Lets merge the meshes.

polyUnite -ch 1 pPlane1 pPlane2;

now they are the same, but you cant move the plane anyymore... or can you? well it turns out you can just selsect pPlane2 transform and rotate:

select -r pPlane2 ;
setToolTo $gRotate;
rotate -r -os 0 0 60;

Gee, so what about going back to the different pieces for edit? Well they are in fact hidden just lets unhide them (you can see them in hyper graph).

setAttr "pPlaneShape1.intermediateObject" 0;
showHidden -a transform2;

Is si still editable:

select -r transform2.f[47] ;
move -r -os -wd 0 -0.2 0 ;

yep, you can now hide it if you wish. Now lets fix the uv and merge vertices:

select -r polySurface1.vtx[79] ;
$size = size(`ls -sl -fl`);
PolySelectTraverse 1;
while ($size!=size(`ls -sl -fl`)){
  $size = size(`ls -sl -fl`);
  PolySelectTraverse 1;
}
PolySelectConvert 4;
polyEditUV -pu -0 -pv 0 -su -1 -sv 1 ;
polyMergeVertex  -d 0.0001 -am 1 -ch 1 polySurface1;
select -cl  ;

And those are all the stages. Now this can be scripted but untill you can explain what here is unsatisfactory we cant make you satisfied, if ever.  On and you can edit polySurface1 and not have mirroring, if you then edit the mirrors again this will just be added on top. You can also smooth he seam if you wish. And have as many mirror pieces as you like so you can make also multi radial symmetry if you wish. etc...

  • this is one of the few actual flaws in maya. Not that most people ever work at this level but just fixing this would have solved your problem (almost) perfectly, even if its a bit unintuitive at first.

PS: there's no such thing in maya as a gizmo.

PPS: Two cars are the same so why cant two software be? Well see cars are all built on same physical principles more or less. But each software has different mathematical principles as a core. The net effect its like comparing two cars in two universes with a different set of physics, they will almost certainly not be the same if the other has gravity and the other does not.

Hey Joojaa,
Thank you for taking the time to explain in depth some theory there. I appreciate that. I will have to play around with the way you suggested to see if it will work for me.