[QUOTE=PePeTD]
fn mirrorNodeFn obj =
(
tempPoint = point()
offsetTm = obj.transform*inverse tempPoint.transform
mirrorTm = offsetTm*(scaleMatrix [-1,1,1])
finalTm = (scaleMatrix [1,-1,1])*mirrorTm*tempPoint.transform
delete tempPoint
return finalTm
)
all in red doesn’t make any sense…
and the question is: mirror to what axis do you expect to get in this function?
Well the function is mainly used to Mirror a transform across a desired object I quickly stripped down some extra code in the function to make it less confusing and still work! as I said you could do with just a matrix 3 or even without it I guess.
The way I use it is that instead of using a point helper I pass a mirror node ( a node which the transform will be mirrored across ) imagine as if I was mirroring a wrist controller transform across the current position of the hip controller and applying it to the opposite wrist controller (mirroring Right to Left and vice versa).
So I use *inverse tempPoint.transform to get the offset and to get into the object space of the mirrorNode and then I mirror it, flip it and then I use *tempPoint.transform to get out of the mirrorNode object space and now I have an actual transform that has been mirrored across desired mirrorNode and flipped if that is also desired.
Did that help on clarifying why I posted the function that I did, might not have been exactly what OP asked for but it could be useful if used properly I am also pretty sure there might be a better way of coding it.
Did the method I gave you, and streamlined by Klunk, not achieve your desired result?
It did, but this other method seemed to work the same for what I want? From what I can tell so far anyways… But it’s good to know more than one way.
$.transform = prescale $.transform [1,-1,1
]
i just completely misunderstand any reason to create extra node to get a matrix transformation…
any mirror transform tasks needs only two matrices. not more and not less. one is the matrix to mirror, and the second is the mirror matrix.
Here is the mirror method I plan to use… taken from a released Autodesk sample file (originally created by Paul Neale and Mike Biddlecombe– so credit and thanks go to them!)
fn mirrorMatrixFn
axis:"x" --Axis to mirror over
flip:"x" --Axis to flip
tm:(matrix3 1) --Matrix to mirror
pivotTm:(matrix3 1) --Matrix to mirror around
=
(
fn FetchReflection a =
(
case a of (
"x": [-1,1,1] -- reflect in YZ plane
"y": [1,-1,1] -- in ZX plane
"z": [1,1,-1] -- in XY plane
)
)
aReflection = scalematrix (FetchReflection axis)
fReflection = scalematrix (FetchReflection flip)
--calculate the mirroredTM
fReflection * (tm * (inverse pivotTm)) * aReflection * pivotTm
)
Of course the calling and implementation of the above is left to the reader.
this is correct. and it’s exactly the same what we started from
but i don’t really understand the meaning of flip-reflection
but… it’s correct if these two bones have the same parent.
also… there are another types of mirror: xy, yz, and zx…
also… to make two symmetrical bones (left and right) work symmetrically in local space is not enough just flip an axis. you also have to rotate the matrix.
tha means you have more new combinations to play with
Although depending upon what happens when I finally use it, I may have to do it another way.
Need to test tonight/tomorrow morning.
Yep Archangel our scripts do the same thing just written a little different.
$.transform = prescale $.transform [1,-1,1]
does not mirror the object properly it simply flips the Y but leaves the object with [-1,-1,-1] scale on all axis and that is a No no in my opinion.
@Kickflipkid687: But if you ever want to mirror across a reflection plane at any point in space then look at the function PePeTD gave you… or the one created by Paul Neale & Mike Biddlecombe.
So the way i would go about mirroring the object along it own axis would be this way (I simplified my function for the purpose of this post )
fn mirrorNodeFn obj =
(
mirrorTm = obj.transform*(scaleMatrix [-1,1,1])
finalTm = (scaleMatrix [1,-1,1])*mirrorTm
return finalTm
)
in coordSys (transMatrix $.transform.pos) $.rotation = Inverse (mirrorNodeFn $).rotation
There are other ways of doing this and I think it would come down to preference really (unless I am totally wrong and Paul or Bobo will come and slap me silly)
it’s probably something about applying mirror transform to the mirrored bone with flipped against original some axis… (like biped bones for example).