Hey guys,
I'm a noob, and am trying to understand how to use the inverse matrix
better. It's related to this thread so I'm replying here. I've searched
through all the documentation and posts and haven't found an answer (that I
can fully comprehend) yet.
My previous experience comes from maxscript, so I'll have to use it as
pseudocode to illustrate.
I've got three objects with transform nodes: "moon", "earth" and
"asteroid1". I want to save the translation and rotation of "moon" relative
to "earth" into a variable, so I can snap "asteroid1" to that exact
translation and rotation that the moon has, relative to the "earth". I want
to save it in a variable so I can use that relative position and rotation
in another file that doesn't have the "moon" in it (therefore I can't cheat
and just xform "asteroid1" to "moon").
Here's how I did this in maxscript pseudocode:
# Get a transformation matrix of the “moon” to the “earth”.
my_matrix = moon.transform * inverse earth.transform
# Then use that matrix to snap the “asteroid1” to the location I recorded
relative to the “earth” in worldspace.
In coordsys world
(
asteroid1.transform = my_matrix * earth.transform
)
In 3DS Max, that would snap "asteroid1" to where "moon" was relative to the
"earth". As a bonus, I'd love the option of being able to snap ONLY
"asteroid1"'s translation OR ONLY it's rotation if I so choose.
I've tried using maya's xform and getAttr commands. I've also tried some
OpenMaya commands suggested by a friend, like .MTransformationMatrix(), and
.asMatrixInverse(), but I don't have enough experience to know how to get
the result I'm looking for. Usually it comes down to me not knowing how to
"multiply" the matrix * the child object's transform node. I'm eager to
learn how to use the MfnTransform and inclusiveMatrix, but I don't have a
good jumping off point. The simpler solution the better for me.
Any advice would be appreciated!
Thanks
On Monday, August 2, 2010 at 6:07:30 PM UTC-7, kungFu_Teddy wrote:
>
> Yep, I think the better and faster way it's MfnTransform and
> inclusiveMatrix :)
>
> --------------------------------
> Marco D'Ambros
> phone : (+61) 0431 830085
> mail : [email protected] <javascript:>
> wave : [email protected] <javascript:>
>
>
>
> On Tue, Aug 3, 2010 at 6:40 AM, Chad Vernon <[email protected]
> <javascript:>> wrote:
>
>> You can get matrices with MDagPath::inclusiveMatrix or exclusiveMatrix.
>> To set a matrix, you can use MFnTransform. The MPx* classes are proxy
>> classes that you only use when creating a custom object like a node or
>> context.
>>
>> Chad
>>
>>
>>
>>
>> On Mon, Aug 2, 2010 at 1:05 PM, johnvdz <[email protected]
>> <javascript:>> wrote:
>>
>>> Hi all,
>>>
>>> i have a script that calculates per vertex tangent space and constructs
>>> a matrix. which all works fine but now i'm just looking at trying to get it
>>> to work in a global position.
>>>
>>> what is the best way in Api to get the objects Inverse Square matrix or
>>> an object? there seems to be a few options whats the deference
>>>
>>>
>>> *MPxTransformationMatrix* <cid:[email protected] <javascript:>> ()
>>>
>>> *MPxTransform* <cid:[email protected] <javascript:>> ()
>>>
>>> any guidance would be great
>>>
>>> john
>>>
>>> --
>>> http://groups.google.com/group/python_inside_maya
>>
>>
>> --
>> http://groups.google.com/group/python_inside_maya
>>
>
>
--
You received this message because you are subscribed to the Google Groups
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/python_inside_maya/29fe8851-9e8a-49df-afcb-f32cc4b35abf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.