[Closed] Mirroring Rotation
All I’m trying to do is mirror an object across the x across as well as mirror the rotation.
It seems to work fine for scale and position but the rotation is corky. If it is executed several times the rotation will eventually line up properly.
Not sure what to read the rotation as? I’m assuming that is where the problem lies.
boxR = $Teapot002
boxL = $Teapot001
if selection[1] == boxL do
(
--//Postion
dir = boxL.pos
boxR.pos = [dir[1]*-1,dir[2],dir[3]]
--//Scale
boxR.scale = boxL.scale
--//Rotation
rot = boxL.rotation
boxR.rotation.x = rot.x*-1
boxR.rotation.y = rot.y
boxR.rotation.z = rot.z
)
how you do mirror transform is completely wrong. the position only is kinda OK and only if the node doesn’t have a parent.
to get mirror transform you have to multiply the original matrix on a mirror matrix …
the mirror X matrix in world coordinate system is (matrix3 [-1,0,0] [0,1,0] [0,0,1] [0,0,0])
so the sample might look as:
(
origin = box pos:[-30, 10, 10]
rotate origin (eulerangles 30 50 80)
mirrorX = copy origin
mirrorX.transform = origin.transform * (matrix3 [-1,0,0] [0,1,0] [0,0,1] [0,0,0])
)
Denis how would you fix the negative scaling?
I’d say
ResetScale mirrorX
can you prevent negative scaling in the first place or is it something you always have to take care off?
-Johan
something like this:
(
delete objects
origin = box pos:[-30, 10, 10] wirecolor:yellow
rotate origin (eulerangles 30 50 80)
mirrorX = copy origin wirecolor:green
tm = origin.transform * (matrix3 [-1,0,0] [0,1,0] [0,0,1] [0,0,0])
mirrorX.transform = prescale tm [-1,1,1]
)
Negative scaling is such a pain to have to deal with.
It is a good question. As for me I’d do what you said JHN.
or multiply the matrix quat by the mirrored matrix, and then re-composing the matrix
or multiply each matrix row by the correct mirrored vector.
but all this, is world space.
Yes it’s world space, if it where a rig and I’d know how things where set up I’d go straight for the controller values,as simply inversing the controller values would be enough, if the rig was properly made.
-Johan
yes and MAX will deal with the math anyway…
playing with quat controllers:
--#X
(
q = $.rotation.track.value
q.x*= -1
q.w*= -1
$.rotation.controller.value = q
)
--#Y
(
q = $.rotation.track.value
q.y*= -1
q.w*= -1
$.rotation.controller.value = q
)
--#Z
(
q = qorthog $.rotation.track.value [0,1,0]
q.x*= -1
q.w*= -1
$.rotation.controller.value = q
)
usually the mirroring of a transform is a part of some rig/animation… it’s a bad habit to take a bone’s scale into account.
so usually i don’t care about negative scale for my animated objects(bones).
That’s a good point, never looked at it like that, I see a negative scale, I think that’s bad, but it’s not if you don’t use it.
Thanks!
-Johan
So I’m trying to find the average transform of a selection of objects. Then returning the entire matrix 3 so I can then use the desired values, whether it be position, rotation or scale. What is the best way to divide up a matrix3. I know the alternate would be to do each individual obj.pos…obj.scale…obj.rot but that seems very redundant.
totalTransform = (matrix3 1)
for obj in selection do
(
totalTransform += obj.transform
)
myP = point()
myP.transform = (totalTransform/2)