# Sharing Transformations

## Recommended Posts

rahulpawar    109
hello everyone!,
well i m unable to decided proper way to handle this may be you guyz could help me out. here is the prob,

i have two skeletons say Arm 1 and Arm 2 as seen in fig.

[img]http://i952.photobucket.com/albums/ae10/global_powers03/DirectX%20Probs/Arms.jpg[/img]

Now i have saved a transformation for Arm1 skeleton [i.e. an animation sequence for Arm1]
( transformation means a matrix or a set[ rotation , scale, translation] )

now from the fig it is clear that the original size of the bones are different in both cases,
so if we directly use the transformations of Arm1 to Arm2 we would get large displacements(linear & angular) and change of bone lengths also
which is totally unacceptable since these bones are skinned and hence these weird side effects will affect the mesh's look

[i know only rotation transformation may not create such effects but when transformation contains rotation along with scale and/or translation it generates those results ]

..... i checked this in 3D Max .
So now, how should i map the transformation from Arm1 to Arm2 without getting those weird side effects....
...
An Answer comes to my mind [b]Relative Transformation Mapping[RTM][/b]
...
In layman's term i need a system that can take
1] given set of transformation
2] other bone system.....Same No Of Bones.....<Should this be required ?>

and outputs new transformation without those weird side effects.

Its like Suppose there are Time Lines AB and CD
[img]http://i952.photobucket.com/albums/ae10/global_powers03/DirectX%20Probs/Arms2.jpg[/img]

Now if Apply transformation from CD to AB using RTM it will be simple linear interpolation between
endpoints A and B based on a delta retrieved from transformation on CD.

[b]But the problem in our case is different because we don't know the end points of the transformation
in Arm2[initial transformation i.e current base pose is only known][/b]
Hence we cant use simple linear or spherical interpolation.

.... Can u Guyz Suggest to make this RTM System work ?

##### Share on other sites
rahulpawar    109
Hidden
Guys i digged more of google sack and found out something called
[size="3"][b]"Transformation Matrix with Respect to a Basis"[/b][/size]
it the most parallel thing i found along the lines of what i want....[url="http://math.stackexchange.com/questions/27363/find-the-matrix-of-a-linear-transformation-relative-to-a-basis"]Check This[/url] and [url="http://www.physicsforums.com/showthread.php?t=338727"]This[/url]

But again i do't know the endpoints.....So how can i find the B....

Can some one unwind this !

rahulpawar    109
Hidden
Guys i digged more of google sack and found out something called
[size="3"][b]"Transformation Matrix with Respect to a Basis"[/b][/size]
it is the most parallel thing i found along the lines of what i want....[url="http://math.stackexchange.com/questions/27363/find-the-matrix-of-a-linear-transformation-relative-to-a-basis"]Check This[/url] and [url="http://www.physicsforums.com/showthread.php?t=338727"]This[/url]

But again i do't know the endpoints.....So how can i find the B and B[sup]-1[/sup]....

Can some one unwind this !

rahulpawar    109
Hidden
Guys i digged more of google sack and found out something called
[size="3"][b]"Transformation Matrix with Respect to a Basis"[/b][/size]
it is the most parallel thing i found along the lines of what i want....[url="http://www.youtube.com/watch?v=PiuhTj0zCf4"]Check This Video[/url]

So now my question is how to find [b]C<change in basis matrix>[/b] from Arm1[standard basis] -> Arm2[non standard matrix]...

A hunch tells me that the [b]offset transformation matrix[/b] from bone transformation matrix may come in picture

Can some one unwind this !

rahulpawar    109
Guys i digged more of google sack and found out something called
[size="3"][b]"Transformation Matrix with Respect to a Basis"[/b][/size]
it is the most parallel thing i found along the lines of what i want....[url="http://www.youtube.com/watch?v=PiuhTj0zCf4"]Check This Video[/url]

So now my question is how to find [b]C<change in basis matrix>[/b] from Arm1[standard basis] -> Arm2[non standard matrix]...

A hunch tells me that the [b]offset transformation matrix[/b] from bone transformation matrix may come in picture

Can some one unwind this !

##### Share on other sites
haegarr    7372
Why isn't it sufficient to just scale the skeleton? (I mean. for each bone matrix in model space apply the same scaling to each matrix as last step.) Or are the bones scaled independently to yield in the other skeleton?

##### Share on other sites
rahulpawar    109
what i'm trying to implement here is a way in which

suppose you have saved a animation sequence applied to one skeleton hierarchy

You Could Using RTM System Directly use same animation sequence with other skeleton hierarchy
[where character's height body dimensions are different than the earlier one]

.
.
.
OK i did some more digging i found [url="http://www.youtube.com/watch?v=1j5WnqwMdCk&feature=relmfu"]This Video[/url] At some point he derives:

C[a][sub]b[/sub] = [a]

where C [b]: change in basis matrix

And We need to find this[b]

[/b][/b]so C[a][sub]b[/sub][a][sub]b[/sub][sup]-1[/sup] = [a][a][sub]b[/sub][sup]-1

[/sup]therefore, C = [a][a][sub]b[/sub][sup]-1[/sup] [ Since [a][sub]b[/sub][a][sub]b[/sub][sup]-1[/sup] is Identity Matrix ]

So from my example Can [a] be initial pose matrix of Arm1 and [a][sub]b[/sub] be initial pose matrix of Arm2 so [a][sub]b[/sub][sup]-1[/sup] will be Its inverse......OR

As i guessed earlier [b]offset transformation matrix [/b]should be used some how..........

##### Share on other sites
lauris71    841
It depends how similar are your skeletons. You said, that they have the same number and topology of bones, but do they have the same bone local rotations (for the identical poses) - i.e. are simply differently scaled variants of each other. And whether you need things like expanding libs (hopefully not).
If the local transforms are the same between skeletons, simply break your animation matrices into rotation and translation parts and only apply rotations to other skeleton.
Say you have the transformation of animated bone in skeleton 1 relative to parent bone AB2P1 (AnimatedBoneToParent), then:

(1) AB2P1 = B2P1 * AB2B1

Where B2P1 (BoneToParent) is the local transformation of bone in rest pose (T-pose) and AB2B1 (AnimatedBoneToBone) is relative animation of the bone (compared to the rest pose).
AB2B1 should be pure rotation matrix (unless stretching or scaling of body parts is involved). So for the other skeleton:

(2) AB2P2 = B2P2 * AB2B1

But as I said, this only works, if you have skeletons, that have similar local bone transformations (for same poses). If the bone transformations are different, then you have to go through object/mesh space.

(3) AM2M1 = AP2M1 * B2P * AB2B1 * M2B1
AM2M1 (AnimatedMeshToMesh)
AP2M1 (AnimatedParentToMesh)
M2B1 (MeshToBone)

For each bone AM2M can be broken to translation and rotation parts (AM2M1_t and AM2M1_r), thus:
(4) AM2M1 = AM2M1_t * AM2M1_r
And:
(5) AM2M1_t = translation of AP2M1 * B2P1

The rotation parts of animations of both skeletons should be identical in mesh space, thus:

(6) AM2M2 = AM2M2_t * AM2M1_r

From those formulas you should be able to compose the needed transformations of the other skeleton. There will be lots of matrix calculations initially, but fortunately much of these can be precalculated or optimized out later.

##### Share on other sites
rahulpawar    109
[quote name='Lauris Kaplinski' timestamp='1307788000' post='4822039']
It depends how similar are your skeletons. You said, that they have the same number and topology of bones, but do they have the same bone local rotations (for the identical poses) - i.e. are simply differently scaled variants of each other. And whether you need things like expanding libs (hopefully not).
If the local transforms are the same between skeletons, simply break your animation matrices into rotation and translation parts and only apply rotations to other skeleton.
Say you have the transformation of animated bone in skeleton 1 relative to parent bone AB2P1 (AnimatedBoneToParent), then:

(1) AB2P1 = B2P1 * AB2B1

Where B2P1 (BoneToParent) is the local transformation of bone in rest pose (T-pose) and AB2B1 (AnimatedBoneToBone) is relative animation of the bone (compared to the rest pose).
AB2B1 should be pure rotation matrix (unless stretching or scaling of body parts is involved). So for the other skeleton:

(2) AB2P2 = B2P2 * AB2B1

But as I said, this only works, if you have skeletons, that have similar local bone transformations (for same poses). If the bone transformations are different, then you have to go through object/mesh space.

(3) AM2M1 = AP2M1 * B2P * AB2B1 * M2B1
AM2M1 (AnimatedMeshToMesh)
AP2M1 (AnimatedParentToMesh)
M2B1 (MeshToBone)

For each bone AM2M can be broken to translation and rotation parts (AM2M1_t and AM2M1_r), thus:
(4) AM2M1 = AM2M1_t * AM2M1_r
And:
(5) AM2M1_t = translation of AP2M1 * B2P1

The rotation parts of animations of both skeletons should be identical in mesh space, thus:

(6) AM2M2 = AM2M2_t * AM2M1_r

From those formulas you should be able to compose the needed transformations of the other skeleton. There will be lots of matrix calculations initially, but fortunately much of these can be precalculated or optimized out later.
[/quote]

Well Finally some hope,

Firstly, Thanks Lauris Kaplinski for Replying ....... And Thats indeed what i would have to do..... i also took the liberty to check "Khayyam 3D" project . . .i would go in little depth there later

Secondly, Just to inform that My Prob goes in "bone transformations are different" Case as you said.

Thirdly, when you said "object/mesh space" did you meant using offset bone matrix to go from bonespace1->worldspace->bonespace2...

Its just that i got rest of how i should handle the separated(rotation+translation) transformations [b]But could you shed little bit more light on the "object/mesh space" part[/b].....thanks in advance