View Full Version : Coordinates in parent space
theflash 05-23-2009, 05:57 AM I hope I can explain this in words.
Example,
Locator is parented under a cube. I need a matrix that gives me the transform change in locator when cube is rotated. But I don't want that matrix to change if cube is being rotated by its parent.
In short,
I need matrix info of the locator which gets updated only when the cube (or locator itself) is manipulated.
.matrix attribute gives me the local transform of that locator. But .matrix does not change when I rotate the cube. So I believe I need to do some contatenation but I cant imagine what.
Any ideas?
Thanks.
|
|
theflash
05-23-2009, 06:18 AM
I did this and it seems to be working...
cube.matrix * locator.matrix
(parent's local matrix multiply by locator's local matrix)
This gives me the matrix info in relation to cube's parent space. So I believe what I was looking for was coordinate info of locaor in cube's parent space.
Do I understand this correct?
if you want the transform space of the child relative to its parent you would do:
$.transform * inverse $.parent.transform
Now if the childs rotation is exactly the same as the parent but the position is different your matrix you get back from the above formula gives something like this:
matrix3 [1,0,0,] [0,1,0] [0,0,1] [10,0,0] - i.e no rotation just positional offset from its parent. You can get any object transform space relative to another using the above formula, not just its parent.
To get info if the childs transform is different from its parent you can do a case statement on its transform rows: i.e
if ($.transform * inverse $.parent.transform).row1 != $.parent.transform.row1) do (return
($.transform * inverse $.parent.transform).row1)
For the parent you if it has no parent you would just compare it against the world but still you would have to do it row by row.
if $.transform.row1 != (matrix3 1).row1 do (return $.transform.row1)
theflash
05-23-2009, 08:55 AM
Thanks for your reply Charles.
What I am trying to solve is to have a particular constraint work locally. So as I mentioned in my example I have a locator that is parented under a cube. I want to trigger the constraint only when either locator itself or cube is manipulated. So in that case my coordinate space would be parent of the cube right?
Thanks for your reply Charles.
What I am trying to solve is to have a particular constraint work locally. So as I mentioned in my example I have a locator that is parented under a cube. I want to trigger the constraint only when either locator itself or cube is manipulated. So in that case my coordinate space would be parent of the cube right?
Yes for the child, and world for the parent (if it has no parent)
CGTalk Moderation
05-23-2009, 03:15 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.
vBulletin v3.0.5, Copyright ©2000-2012, Jelsoft Enterprises Ltd.