PDA

View Full Version : mirriong side to side in character?


shalabology
06-22-2009, 12:56 AM
i made a button with the script that including getting pos and rotation from the source object and multplying pos-x by -1 and so rotation by -1 to get the object mirrored over that axis it didnt work good for all the time , any ideas to make mirring for body parts?

shinyprem
06-22-2009, 10:16 AM
Hi...!

If the model is at the grid center .. Duplicate it and scale X by -1 in the channel Box.
Try!
Rgds,

shalabology
06-22-2009, 11:37 PM
no you got me the wrong way , look at my reel:
http://www.youtube.com/watch?v=jGKiN3SZeoQ
if you look at that i want to make button that called for example right mirror you may pose the right arm at any pose and press that button and get the other arm positioned the same and so on , hope you got my point , and thank you for passing by!

shalabology
07-09-2009, 01:54 AM
hey pals , i am talking about something like mirroring in biped pose mirroring like in walk cycles and so , hope to get serious help !

PEN
07-09-2009, 12:51 PM
Your going to want to do this at the matrix level and not trying to use rotations.

For instance this is a teapot mirroring around a box. The mirror axis is x and the flip axis is z

$teapot01.transform=$teaPot01.transform*(inverse ($box01.transform)*(scaleMatrix [-1,1,1]))*(scaleMatrix [1,1,-1])

shalabology
07-09-2009, 08:23 PM
i got the part of transform but why multiplying scale twice ? somewat confused about that, but i think that i began to get it

Ruramuq
07-10-2009, 02:04 AM
you can multiply 2 scales like this:
(scaleMatrix [-1,1,-1])
and it should give the same result

but personally negate Matrices are something to avoid 'cause in matrix math, they get confused easily, rotation vs scale vs quaternions vs euler vs controllers conversions

shalabology
07-14-2009, 04:52 AM
another qs :is this suitable to be apllied in bone-based facial set up? i.e mirroring side to side?

shalabology
07-14-2009, 05:24 AM
after reading in chales looker about matrice i could sort out why incorporating matrix in this formula althou still weird for me ngating the axis that way so any further explaination?

PEN
07-14-2009, 03:10 PM
The reason that I do the scale twice is because the first one mirrors the TM around a given point, once done you have a left handed matrix which you don't want. So I then mirror the object around what is known as the flip axis, this axis could be the same axis or a different one but what is really different is the space that you flip it in, this time it is in the local space of the object and not the pivot point.

Ruramuq
07-14-2009, 09:09 PM
Something important to notice is that matrix math introduces scaling and skew on objects, and after several interactions it is evident.. yes it deteriorates.

Also Matrix and controllers do not synchronize very well. Especially quaternions and euler conversions so pesonally I use the matrix for math as a filter, to get separate values preferable.

this might not be somethign to be very worry for most rigs, but I prefer to care about those things early than later. due to strange things that happen depending of how you change a value.

shalabology
07-15-2009, 03:06 AM
i can tell that i got 95 % of it now but i am greed , may i have any graphical demonstration for it , i iwill be thoughtul

PEN
07-15-2009, 02:12 PM
To correct the scaling and skewing if any when doing matrix math you can run this function on the final TM.

orthogonalize

Ruramuq
07-15-2009, 02:25 PM
I'm not sure what methods use max inside the function orthogonalize..
but I havent been able to see it as reliable, except visually only.
ie:create and object rotate it and scale it in world coordinates to create skew,
then:

$.transform = orthogonalize $.transform
(matrix3 [0.724719,0,0.689044] [0,1,0] [-0.689044,0,0.724719] [-9.984,-0.133445,-0.188484])
$.transform.scalerotationpart
(quat 0 0.382683 0 0.92388) as eulerangles
(eulerAngles 0 -44.9999 0)

in other words,it does not orthogonalize the matrix, in fact the result is random, (the skew).
currently I use different methods.

perhaps there is something I have missed about it..

phoelix
07-15-2009, 02:37 PM
Hi,

ruramuq in fact that scalerotationpart have effect in the matrix skew only if the scalepart is a vector different than [1,1,1]

the scalepart is a vector that scales the matrix in the axis defined by the scalerotation quaternion, if that scale is a [1,1,1] vector there's no scale at all neither skew, even if the scalerotationpart is a quat different than zero.

$.transform=orthogonalize $.transform
(matrix3 [0.751109,0,0.660178] [-0.660178,0,0.751109] [0,-1,0] [-1.57729,0,-0.946372])
$.transform.scalerotationpart
(quat 0 0 0.382683 0.92388) as eulerangles
(eulerAngles 0 0 -44.9999)
$.transform.scalepart
[1,1,1]


i guess ... the quaternion got from the scalerotationpart is differet than zero because the float values of the orthogonalized matrix dont have enought decimals to make it perfect, just a guess

Ruramuq
07-15-2009, 03:29 PM
hi Phoelix
yes, and I think you are absolutely right, but I think I was already considering that.

there is a deterioration when doing matrix math, but the function returns skew, and yes, skew can only exist if there is scale.

try this with a skewed object:

$.transform=orthogonalize $.transform
$.scale = [1,1,4]
the result should give skew in the viewports..

and the reason why I believe that function is not the best option, is because in some situations a matrix might seem perfect, even analysing it with formattedprint it might look like a identity one, but not if you look beyond 18 decimals, the skew is still there.

I used scaleRotationPart beçause it returns an angle near 45º, which if I'm not wrong is likely because of skew instead of lack of presicion..

PEN
07-15-2009, 03:56 PM
Scaling is not Skewing, and you can have Skew without Scale. Scale is if any one of the three vectors is not normalized. Can can normalize the vectors and still have them non orthogonalized.

Example:
b=box()
b.transform=matrix3 [1,0,0] [0,1,0] [0.707107,0,0.707107] [0,0,0]
length [0.707107,0,0.707107]

Max does have issues with precision and we have been seeing that for may years. I do lots of matrix manipulations and I don't have a problem using them. As long as I make sure that the final results are normalized and othogonalized the matrix values are fine.

phoelix
07-15-2009, 04:29 PM
edited---------------

Ruramuq
07-15-2009, 04:53 PM
PEN, thats right, skew can exist without scale. I dont know why i assumed that, that was wrong. I was thinking scalerotationpart as defined by the diagonals of the rows.

but excluding my mistake about that, I disagree with you about that function, it returns skew easily. unless its meant to be used in a special way, its without a doubt bad.

many of those things about precision I'be seen comes directly from this matrix feeding the controllers improperly. believe it or not, thats why I care about it, because I have seen many issues with rigs apparently orthogonal and perfect.

phoelix
07-15-2009, 06:01 PM
In terms of node transform manipulation a skew could be interpreted as a scale transform made to a matrix in a specific space, a space with an orientation different than the node's one.
and that's the way that the scalerotation and scale part could be understood.

anyway a matrix can be skewed without a scale transform, but a skew can always be interpreted as an arbitrary non-uniform scaling in an arbitrary axis system.

this is an exercise to show what i mean:

$.transform=(matrix3 [1,1,0] [0,1,-0.5] [0,0,1] [0,0,0]) --a skewed matrix
(matrix3 [1,1,0] [0,1,-0.5] [0,0,1] [0,0,0])
scaleRotPart=$.transform.scalerotationpart as matrix3
(matrix3 [0.791682,0.587216,-0.168572] [-0.431844,0.733061,0.525482] [0.432145,-0.343218,0.833938] [0,0,0])
scalepart=$.transform.scalepart
[1.65582,0.549988,1.09808]
rotationpart=$.transform.rotationpart as matrix3
(matrix3 [0.887669,0.457766,0.0499437] [-0.429903,0.862697,-0.266341] [-0.165008,0.214951,0.962584] [0,0,0])
$.transform=matrix3 1 --now get the same skewed matrix by scaling and rotating
(matrix3 [1,0,0] [0,1,0] [0,0,1] [0,0,0])
in coordsys scaleRotPart scale $ scalepart --scale the matrix in the scaleRotPart system
OK
$.transform*=rotationpart --rotate the matrix
(matrix3 [1,1,0] [0,1,-0.5] [-1.63913e-007,0,1] [0,0,0])

Inverse(scaleRotPart)*(scalematrix scalepart)*scaleRotPart*rotationpart --the math of the process
(matrix3 [1,1,1.63913e-007] [1.41561e-007,1,-0.5] [0,0,1] [0,0,0])

the last two skewed matrices that i got from scaling and rotating are the same of the first one that i got just filling out the matrix with non orthogonal axis vectors
the difference is because the lack of precision.

Ruramuq
07-15-2009, 08:21 PM
b=box()
b.transform=matrix3 [1,0,0] [0,1,0] [0.707107,0,0.707107] [0,0,0]
length [0.707107,0,0.707107]The true scale in your example is [0.541196,1,1.30656] It seems I was right.
length is not useful with non orthogonal matrices, now that I remember
skew is scale.

I did the next test, some time ago, and probably from there I assumed that a skewed matrix means that it is scaled in any case. but I forgot;
I was trying to extract the scaleRotationPart from a matrix, to test it with an xform tool
so this is what I noticed :

(
local m
local x,y,z = 0
m = $.transform

z = (m.row3 - m.row1)
y = m.row2
x = (cross y z)

print ((matrix3 x y z [0,0,0]).rotation as eulerangles)
print ($.transform.scaleRotationPart as eulerangles)
ok
)

an object with skew in X Z plane. returns 45º in Y axis no matter the amount of skew, and it can be calculated using( row3 - row1) (diagonal dir) for example to get the direction of z.
it basically depends on the longest diagonal formed by these rows or its negatives/flipped ones.
a scale transform made to a matrix in a specific space, a space with an orientation different than the node's oneisnt it the same spaceTransform of the node itself
m = $.transform--skewed matrix
$.transform = (scaleMatrix [1,1,4]) * m -- we apply scale to the skewed matrix and it shows the direction of the skew/node.
but I think you're right, what you explain seems similar to what I believe I understand about this

skew == scale, perhaps it was confusing thinking that if the rows are normalized then its scale is 1 1 1, but it seems its not as simple as that.

PEN
07-15-2009, 08:21 PM
I don't usually use orthogonalize either I do it manually using the cross product so that I know I can reset the vectors in the order that I want.

shalabology
07-10-2010, 03:50 PM
as far as i know skewing comes out from non uniform scaling so how can we get skewing without scaling ?
also , regarding the preciselessness does orthogonolize function suffice to correct skewing ?

CGTalk Moderation
07-10-2010, 03:50 PM
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.