Maya Transforms

Hi all,

I am very curious about how Maya deals with its transforms internally, and a friend showed me this page: http://help.autodesk.com/view/MAYAUL/2016/ENU/?guid=__cpp_ref_class_m_fn_transform_html

I started building this in Maya's own Node Editor, just to discover it doesn't have trigonometry nodes! To my luck Fabric has just released 2.2.1 that works with Maya Ext2, which is the one I am testing. yey

So, my questions:
. Mat44 plugs into Xfo, but it doesn't draw with DrawXfo. how should I approach that? SetFromMat44 didn't work with me as well. I would think Xfos were nothing more than 4x4 Matrices
. I am getting an error: ":3:11 no resolution for binary operation floating-point constant / Mat44" which I have NO IDEA what it is
. how would one put a Rotation Order to be chosen in something like this?

regarding the connection themselves I am still confused I got it right, because Maya's help page use the same variables for different matrices, and explains very poorly which matrices are being inverted. the rotations should be in radians as well, for what it seems.

well, if anyone can share an idea it would be very appreciated. Fabric looks amazing, but I am having a hard time learning it, coming from ICE.

cheers!

Tagged:

Comments

  • Daniele NieroDaniele Niero Posts: 233 ✭✭

    Hi,

    I'm not sure why you would want to replicate the horrible Maya's transform if not for pure curiosity and learning process.
    We will get back to this later.

    . Mat44 plugs into Xfo, but it doesn't draw with DrawXfo. how should I approach that? SetFromMat44 didn't work with me as well. I would think Xfos were nothing more than 4x4 Matrices

    Xfo are nothing like 4x4 matrices, they serve the same purpose, but they really are different.
    A 4x4 matrix is 16 numbers 4 per each column or row, 4 columns and rows. These reflect 1 to 1 what a matrix is in algebra.
    We can use it to store the pose of a point in space. In Maya's terms (row major matrices) the first row are the coordinates of the X axis, the second the Y and the third the Z. This is how you achieve rotation and scale (if the axis are not unit length). The fourth row is the position.
    The fourth column is actually irrelevant and always 0,0,0,1 it exists so the matrix is squared and we can use some properties of squared matrices. It can be considered waste, a little waste, but a waste nevertheless.
    With matrices you can't really decide the order of how position, rotation ans scale are applied, when you multiply two matrices. They are all compact and the operation is one. That's one of the reasons (but not the only one) why softwares like Maya introduced the "transform", a more rich object, composed by many matrices.

    Xfo are instead made by a vector for position, a vector for scale and a quaternion for rotation. In total they are 3+3+4=10 numbers none of them irrelevant. Position, scale and rotation are independent and when two Xfo multiply they don't present the matrices issues.
    Quaternion is also a better object to represent rotations especially during an animation.

    Now that we know what the two objects are, let's move to the answer:
    You can plug a Matrix to a Xfo port because in KL the Xfo can be constructed with a Matrix. When you plug a Mat44 to an Xfo port, KL recognises that and does what is called an implicit cast (it converts the Matrix to an Xfo for you).
    Because Xfo has other two constructors that accept a Vec3 and a Quat respectively, you can also plug a Vec3 or a Quat to an Xfo port.
    The opposite isn't possible simply because Mat44 doesn't have any constructor that takes a single Xfo as argument.

    . I am getting an error: ":3:11 no resolution for binary operation floating-point constant / Mat44" which I have NO IDEA what it is.

    Are you dividing a number by a Matrix? If so, that's why you have this error. (if I'm reading it correctly)

    how would one put a Rotation Order to be chosen in something like this?

    We go back to a concept of transform here.
    Rotation order makes sense only when you have Euler angles. Please refer to this thread to know more about it.
    You use Euler angles to allow a user to input 3 distinct angles to define a rotation. Input the 4 inter-dependent values of a quaternion would be too complicated, not to mention the 9 of a matrix.
    So you need to expose 3 scalar ports, one for each angle, and an integer port with values from 0 to 5. Then in Canvas you can use the node **ComposeEuler ** and plug those ports into it. Once you have a Euler you use it to set the rotation of a Matrix or a Xfo, then you keep going with your graph.

    Despite all of these, as I was saying in the beginning, there is not reason to try to have a Maya transform. It is an old thing that caries with it many problems. It tries to give many features that in theory sound great, like the possibility to set its pivots, but in practice it's simply way to complicated, convoluted, over-designed, resulting in a huge object (considering the context of its typical use) that it's slower than what it should, not mentioning the headache it gives every time you have to deal with it in the API.

    My suggestion? You have Fabric now, that allow you to stay away from the bloated Maya's transform as much as you can. Lern instead how to handle Xfos and do what you want with those. Care about the Maya's transform only when you set them from Fabric or read them for Fabric.
    You said you come from Xsi. Don't make your life unnecessary sad and ugly as I had to do :)

    I hope this helps,
    Daniele

  • Ed SchifferEd Schiffer Posts: 2

    Hi Daniele, really thanks for the detailed answer.
    Yes, I am trying to replicate Maya's transform for 1.understand it better since now I have to work with it and 2.understand Fabric Engine.

    I was thinking that Mat44 and Xfo were pretty much the same as Scalar and Float32, for instance. Different names for the same thing, which confuses me a lot in Fabric. There are SO-many-nodes!

    It was good to see your opinion on Maya's Transform, which seems to be the general one. I never see people messing with the pivots, just grouping lots and lots of transform groups.

    I'll keep taking a look at Fabric.
    Cheers

  • EricTEricT Administrator, Moderator, Fabric Employee Posts: 305 admin
    edited June 2016

    To explain a bit more high level for less experienced with Maths. Xfo and Mat44 represent the same thing in context of an object's SRT (Not saying either of you are that) :smile:. It's just a different way of describing it. Each has pluses and minuses and you need to use each in different circumstances at times.

    There is a way to convert from Xfo to Mat44 using the .toMat44() method on the Xfo which you can then pass to a Mat44 to construct it.

    It may be helpful to review the KL code that represent these two items in the %FABRIC_DIR%/Exts/Builtin/Math/Xfo.kl and Mat44.kl

    In Softimage ICE you had the concept of Mat44 (4x4 Matrices) but not a true Xfo type. Though you could convert from 4x4 Matrices to SRT which essentially is what an Xfo object contains. You can break down the 4x4 Matrix in ICE and see how the same data from 4x4 Matrix to SRTand straight from 4x4 Matrix can give you the same result in the attached image.

    Eric Thivierge
    Kraken Developer
    Kraken Rigging Framework

  • seltzdesignseltzdesign Posts: 80

    @Daniele Niero

    Very interesting explanations about Mat44 and Xfo. I am using 4x4 Matrixes already (in other software) and now want to use them in Fabric. You mention that

    You can plug a Matrix to a Xfo port because in KL the Xfo can be constructed with a Matrix. When you plug a Mat44 to an Xfo port, KL recognises that and does what is called an implicit cast (it converts the Matrix to an Xfo for you).

    I have tried that approach (as there is no Mat44.ToXfo node), but am not having any luck as you can see here. At least when using Arrays of Mat44's:

    Adding to that the Mat44.DecomposeArray as well as Xfo.SetFromMat44 seem to not work for me. I have an array of valid Mat44's, but am not getting any output at all from both. Also in KL there is not Mat44.ToXfo method.

    Any ideas?

  • mootzoidmootzoid Fabric Employee Posts: 185 Fabric Employee

    Hi @seltzdesign

    you can use the node Xfo.setFromMat44 (or Xfo.setFromMat44Array) to convert a Mat44 (or array of Mat44) into a Xfo (or array of Xfo).

    Cheers,
    Eric

  • seltzdesignseltzdesign Posts: 80

    @mootzoid

    Ok, I finally got it to work! I am getting a warning on one of the frames (only that one). Do you know what it means? The Mat44's are created in another script (Grasshopper) and it might be that there is a scale value of 0 (or very close to zero), so it might even be a rounding thing.

  • mootzoidmootzoid Fabric Employee Posts: 185 Fabric Employee

    Yes, with a scaling very close to zero you get these kind of messages.
    In this case I think it's okay to just ignore the warning.

  • Daniele NieroDaniele Niero Posts: 233 ✭✭

    Well, Eric answered already, so... :)

    In general, keep an eye at what type you are using. A single Matrix and Xfo are not the same as an Array of them. What programming language are you familiar with?

Sign In or Register to comment.