PDA

View Full Version : Transformation: A Technical question


Eru
07-26-2006, 01:21 AM
I'm having some technical challenges trying to understand the inner-working of the "Transform Node", on an API and/or mathematical level.

I've already prepared some custom-made Maya scenes to illustrate for myself and others, how transformation calculations are being done in Maya.

That includes among others a complicated set of 3 Gimbals, each meant to illustrate the corresponding 3 types of rotation manipulators (Local, World, Gimbal) and it all works great, for now. I'm also studying Matrix-Math from books and such, to better understand Euler matrices.


However I have encountered different versions of explanation of Euler-Rotation on the web that got me to be somewhat puzzled…

For example, when the order of rotation is XYZ, does that mean that a correct representation of the rotation using a Gimbal, would be to make the X the child of Y, and the Y a child of Z, or parent things in a reversed order? The way I see it (which complies with the Gimbal manipulator in Maya) is of course the former rather then the latter (Meaning, Z is the grandparent).

But, on a web source I got sent to by a friend, the explanation claims that the correct representation of the mathematical mechanism would actually include the X as the grandparent, which got me puzzled: http://www.anticz.com/eularqua.htm


I was hoping someone could help me to shed some light on the matter, by maybe directing me to a more certified source of info.



Also, after reading some Maya Help docs on Transformation, and some web-reading on the Maya API, I still don’t quite understand how Maya saves geometry data inside the Shape node, and how that data is being transferred when Freez-Transforming. I noticed a new node being created sometimes, which I guess might act as a receiving Buffer of some sort, to counteract the fact that the transformation was zeroed out, and preserve the geometry data in its current position.

The question remains, therefore, where does this data go when you delete history?

I've notices on the Component Editor, that vertex position in XYZ is always represented in World-Space, but when you open up the CV's on the Channel-Box, the values are always zero, unless you change them there, which mean that these are relative values. The question that arises, therefore, is "relative to what?" Where can I see the values of vertex-position in local space, or object-space, and if they are stored inside the Shape Node, where can I see it?

Here are some examples I made...
http://img230.imageshack.us/img230/1600/rnongimbalkj7.jpg (http://imageshack.us)




http://img207.imageshack.us/img207/223/rnontransform1hc7.jpg (http://imageshack.us)


Would appreciate any help you could give me...

isoparmB
07-26-2006, 03:04 AM
But, on a web source I got sent to by a friend, the explanation claims that the correct representation of the mathematical mechanism would actually include the X as the grandparent, which got me puzzled: http://www.anticz.com/eularqua.htm


I'm not learned in higher math or anything, but I'd like to comment that the article link you posted dosen't seem to conflict with the first definition you had (wherein in an xyz rotation order situation, z is the grandparent). It just says that in Eular rotation, x gets calculated first, then y, then z. It didn't seem to mean that x will be the granparent of the other rotation axis.

I also did a test on a simple sphere with the rotate tool set to local. In an xyz situation, x will not move any other axis, y will move x, and z moves both. It appears the last axis in the rotate order will be the grandparent.

Emil3d
07-26-2006, 05:14 AM
Only the Gimbal mode of the Rotate Manipulator represents truly how the rotation is working. The other modes World and Local are not true representation of the rotation and simply redraw (translate) the manipulator for convenient usage. The way you defined it at first is correct and the example given from IsoparmB above clearly illustrates that (I’m sure he meant Gimbal when he said Local)

When freezing the transformations my understanding is that Maya simply rotate all axes back to 0 and at the same time repositions the geometry components (points) by rotating them in the reversed order around the current pivot with calculations based on the current relative values of each component. Since each point has a relative and world coordinates Maya uses one or the other for certain calculations to build and affect the geometry (shape node). Relative is a value for a point on the geometry starting with 0 at creation or after freezing the transformations.

Using a history node is simply a way to change the current values in certain order by adding into the calculations the actions (values) that were entered after that node was created. Deleting history simply cuts that possibility and doesn’t affect anything.

I hope this helps

Eru
07-27-2006, 04:05 PM
I also did a test on a simple sphere with the rotate tool set to local. In an xyz situation, x will not move any other axis, y will move x, and z moves both. It appears the last axis in the rotate order will be the grandparent.

Only the Gimbal mode of the Rotate Manipulator represents truly how the rotation is working. The other modes World and Local are not true representation of the rotation and simply redraw (translate) the manipulator for convenient usage. The way you defined it at first is correct and the example given from IsoparmB above clearly illustrates that (I’m sure he meant Gimbal when he said Local)

That's exactly how I see it, so there are flaws in the explanation on the website I mentioned, especially in the graphical simulation (animated GIF or something...).
Here is a little confusing example from the site:

Since the X component has already been evaluated it doesn't get carried along with the other two axis

Exactly the opposite from my point of view. Since the X axis has already been evaluated, it DOES get carried along with the other 2 axies, so it does'nt recieve, or inherit any rotarion values from the other ones, because of the fact that it is a child of all.

In the example given, the X axis should have been drawn to collide with the Z axis (and not the other way around) as the Y axis was beeing rotated, if it were to correctly illustrate rotation order (the 'Gimbal Way') and represent 'Gimbal Lock'.

Since each point has a relative and world coordinates Maya uses one or the other for certain calculations to build and affect the geometry (shape node). Relative is a value for a point on the geometry starting with 0 at creation or after freezing the transformations.

Using a history node is simply a way to change the current values in certain order by adding into the calculations the actions (values) that were entered after that node was created. Deleting history simply cuts that possibility and doesn’t affect anything.

I hope this helps

Actually, that's the most helpfull piece of advice I got on the matter...

However, I think when you freez transformation, it simply takes the world space coordinates, and needs-be, transforms them up the hiarchy, onto the transform node itself, then inserts them as the local coordinates, question remaining, where to? Where can I see the components local coordinates stored within the shape node?

Emil3d
07-27-2006, 06:20 PM
...local coordinates, question remaining, where to? Where can I see the components local coordinates stored within the shape node?You already found out this as suggested from your first message.

The channel box and for NURBS only the attribute editor, display vertices and CVs coordinates in the relative values. The Component Editor display them in world space coordinates. They are all stored in the shape node and if you delete it you will not longer have access to those and the empty transform node is now equivalent to an empty group.

Open the Script Editor and move a point, the feed back will show the change being recorded in relative values. At the same time look at the help line at the bottom of the screen where Maya shows the changes in absolute values.

Eru
07-28-2006, 01:50 AM
Maybe I do not understand it correctly, or maybe I'm just explaining myself in the wrong way. So I'll give it another try, according to how I understand it now.


I am actually being torn by 2 theories of how Maya approaches the storing of transformation data, and more specifically, how is stores vertex position data, and then, how does OpenGL receives these vertices data, to be drawn within the GPU, meaning, within which coordinate system, or using which 'space' (object, local or world).


One approach, suggests that there are buffers within Maya which always stores the vertices in Object-Space, and these are being sent into OpenGL which is then used to transform them within the graphics card itself, using transformation values stored in the transform node:
"
Using this approach, when OpenGL is being asked to draw the Mesh, it is being passed a series of vertex coordinates sequentially, according to the vertex number, each corresponding to the values of position of each vertex, in Object-Space.
Then, Transformation occurs on all of these vertices, based on the order of transformation in each transform-node, one after the other. Rotation and scaling happens 'around' the position (in world space) of the rotate-pivot and scale pivot respectively.
The result of the transformed vertices, are then being transformed again, for each of the transform nodes in the hierarchy, from the bottom (child) node, to the top (grand parent) node.
The final result of transformation of each vertex is then being saved to some kind of a 'world-space buffer' (supposedly inside the shape-node) and is being presented in the component editor.
Whenever transformation manipulation of transform nodes in not happening, redrawing occurs in world space, with the values stored inside each shape-node's 'world-space buffer' (in order to increase performance).
When transformation does occur, however, it can occur in 6 ways (for example with translation, either components are being translated in component mode, or objects are being translated in object mode, and while using 3 translation manipulators for each of them, meaning 2x3 possibilities).
For example -Translating vertices in object space: It is the vertices position in object-space (which are supposedly also stored inside the shape-node) that are being translated.
In any case, while transforming vertices, the buffer receiving the transformation, is the one storing object space coordinates, and thereafter, the result of these are being transformed by the parenting transform nodes, one after the other, and the final result is 'updating' the 'world-space' buffer, containing vertices world-space coordinates.

This approach raises my question, where can I see the vertices values stored in 'Object-Space' the 'object space buffer'?




The other approach relies on the properties of matrix math to by-pass object-space position of vertices altogether, and in which vertex position values are actually 'only' stored in world-space, and are accessible through the component editor:

'

If I understand matrix math correctly, a matrix can either be used in 3D to be a container for values of transformations to be applied, or be used to represent a definition of a given 'Space' or 'coordinate system'. By assigning different indexed placed within a given matrix, for the transformation values to be received into, a 'container' matrix can be customized to receive/represent translation, rotation or scale attributes. Upon multiplying a 'space' matrix with a 'container' matrix, the 'space' matrix can be changed (or rather updated, or 'transformed' by the amount given by the 'container' matrix, for either rotation translation or scale (according to the type of 'container-matrix' involved) thus turning-into a new, post-transform, 'space' matrix.

A vertex can then be transformed by treating it as a vector and multiplying it by a 'space' matrix, which would result in a new post-transform vector, representing the new location of a vector, after transforming it with a given 'space' matrix.

So far, for my very basic understanding of matrix math, as it relates to 3D calculation.
(I would, however, take my world with a grain of salt, and would actually appreciate any correction to my understanding, if one would find any mistakes I've made and wish to do so, so I can benefit from his/her knowledge, without resorting to studying matrix math all over again, and so others would not be misled by my words.)

As for how Maya use matrices, according to what I've read from the Help about the way the transform node calculates things (within the MPxTransformationMatrix class), it goes like this:


The default matrix math is defined by:

-1 -1 [Sp]x[S]x[Sh]x[Sp]x[St]x[Rp]x[Ro]x[R]x[Rp]x[Rt]x[T] Where [Sp] is the scale pivot, [S] is the scale matrix, [Sh] is the shear matrix, [St] is the scale pivot translation, [Rp] is the rotate pivot, [Ro] is the rotate orientation, [R] is the rotate matrix, [Rt] is the rotate picot translation, and [T] is the translation.


So, there are actually many temporary "space-matrices", which once multiplied one by the other in the order described above, yield the final transformation matrix, which is just another 'space' matrix, and they can be divided into a couple of main groups, which can be represented in Maya by using sub-types of the enumerated class 'MSpace':


There are four spaces in which to apply a transformation.

World Space - This is the space that an object is in after it has had all of its transformations applied to it. A world space transformation is the the very last transformation that would be applied to the object.

Object Space - This is the space in which an object is defined. An object space transformation would be the first transformation that would be applied to an object. This is the same as pre-transform space.

Post Transform Space - This is the space in which the object lives after having the transformations of its transform node applied. For example, when a primitive object is created in Maya, there is a shape node which defined the geometry and a transform node which positions/orients the geometry. The space that the geometry is in is object space. After applying the transformations of the transform node to the geometry, the transformed geometry is in post transform space.

Transform Space - This space depends on the type of transformation being applied. Transform nodes define a fixed sequence of affine transformations. Basically, there is scale followed by rotation and finally translation. There are four spaces here:

1) The space before applying the scale. 2) The space after the scale but before the rotation. 3) The space between the rotation and translation. 4) The space after the translation.

Space 1) is pre-transform space. Space 4) is post-transform space. Spaces 2) and 3) define transform spaces.

If applying a transform space scale, this transform will be applied after the current scale but before the rotation (space 2). If applying a transform space rotation, this transform will be applied after the current rotation but before the translation. Applying a translation in transform space, the translation will be applied after the current translation.


The 'MPxTransformationMatrix' class contains methods of altering the final transformation-matrix by 'attacking' different 'stages' in the computation process.

For example the 'scale' 'stage' (or 'sub-process') includes the first 5 matrices in the computation order list (which also encompasses the 'shear' matrix), and yields a 'transform space' (an 'MSpace' class of sub-type kTransform), that represent the temporary-space-matrix, after scaling, but before rotating, upon which any 'scaling operation' by the user (or by a MEL command, or an API function) will be done.

Also, by this logic, the 'rotate' 'stage' would include the next 5 matrices (which encompasses the "local rotation axis" in the form of 'rotate orientation' = [Ro]), which could be represented as another 'transform space', upon which 'final' 'orientation' in local-space, could be extracted, when for example needing to orient a translation manipulator into Object-space, and translating within this transform-space.

By this approach, the 'space' matrix, by which an 'object-space'-position of mesh-vertices could be described, is 'pre transform space' (an 'MSpace' class of sub-type kPreTramsform), and the resulting values would actually represent 'object-space' position, only if they were to be multiplied by the inverse-matrix of all subsequent parenting transform nodes, or better yet, the 'Post Transform Space' (an 'MSpace' class sup-type kPostTransform) of only the direct-parent of the current transform node.

It would also be within this space, that values of translating vertices are saved and are presented in the channel-box, which brings us back to the question of where are these values being saved? Maya doesn't create a 'tweak' node, until you freez-transform, so these 'elative' values, which are in 'Object Space', have to be saved somewhere, and it would be logical to have a buffer for Object-Space coordinates, since these relative values are within this space, and not having such a buffer would mean that in order for Maya to apply them onto the vertices, they would actually have to be pre-multiplied by the 'Post Transform Space' before translating the vertices, which sounds somewhat in-efficient to me…


Also, what exactly happens when you freeze-transform?

Why doe's it only 'sometimes' create all of a sudden, a polyTweak node and a transformGeometry node, and sometimes not?

In what space are vertices actually being sent into OpenGL to be drawn?

Emil3d
07-28-2006, 05:21 AM
Wow, Eru, you really want to know a lot:). Your questions are in a scope where somebody else will be more helpful than me but I’m replying to you since we were in a middle of a dialog.

I don’t know what you will be using Maya for, but I use it for creating images and animations to communicate ideas and for the kind of work I do, I’ve never been in need to understand all this and have lack of interest and hard time understanding things that don’t directly affect my work or/and are beyond my control.

I really tried to read your whole message and keep my concentration but I got lost a lot of times. Sorry if this disappoints you but I’m not adequate for the level of knowledge you are digging in.

Although you may not find it useful, I will give you my feedback from my perspective anyway for some of your questions.

Regarding freezing the transformations, my understanding as I said earlier and now with other words is that Maya automatically does what one can manually do by first rotating back in reverse order the transform node that will in effect redo all transformations back to 0, and then select and transform all components (the geometry in the shape node) in such way as to position them in the same world space coordinates as before the transform node was redone. At which point Maya replaces all relative values for the coordinates of the components with 0.

A tweak node like any history node is created for some tools and actions that were designed to produced history nodes. For example, moving a vertex will not create history, however it may do that after certain action/s or command/s and choosing Edit Polygons > Move Component will always create a history node.

Open GL for me is just another renderer that tries to render in real time on screen using mostly the video card and in order to achieve that it scarifies the higher quality and features like those available in the software renderers and that’s all I need to know about it in order to use it:).



Good luck and take care.

Eru
07-29-2006, 07:27 PM
I don’t know what you will be using Maya for, but I use it for creating images and animations to communicate ideas and for the kind of work I do, I’ve never been in need to understand all this and have lack of interest and hard time understanding things that don’t directly affect my work or/and are beyond my control.

Acually, I'm looking to become a Technical Director (Character/Lighting&Rendering) who can R&D (MEL,C++,API,Shaders Etc.) and finally a CG-Supervisor (and somewhere on the line do some Maya instruction, perhapse even start my own school/studio integrated environment some day) so you can see where I'm comming from... (or rather where I'm going)
It's just that I have this "tendancy" to develope an earge to understan everything I learn, down to it's a-tomic level, can't help it...
I am a very "technically-oriented" kind of guy, but I also have pashion (and talent) for drawing, modeling & animating, so I'm always sidetracking... It's a problem, really! I know...


Ah, well...
Thanks, anyways ;)

Emil3d
07-30-2006, 12:14 AM
Acually, I'm looking to become a Technical Director (Character/Lighting&Rendering) who can R&D (MEL,C++,API,Shaders Etc.) ...I wish you success and all the best in acquiring and applying your knowledge, I have always admired the people who create the means of production and the extensive knowledge required for this. To bad that 3D tools is not an easy thing so that everybody can create their own tools and at the same time have enough time to produce 3D.

danielkenobi
08-09-2006, 01:03 AM
To bad that 3D tools is not an easy thing so that everybody can create their own tools and at the same time have enough time to produce 3D.


I totally agree.
BUt on the other side I am trying to understand rotations to avoid some problems, Y was trying to animate a simple spaceship, and I encounter with a grimball lock I think, does somebody know how to avoid this and make rotation behave more like in 3dmax were all the rotation transformations seem to be independent an relative to zero rotation.

goleafsgo
08-09-2006, 01:45 AM
A tweak node like any history node is created for some tools and actions that were designed to produced history nodes. For example, moving a vertex will not create history, however it may do that after certain action/s or command/s and choosing Edit Polygons > Move Component will always create a history node.
I believe tweaks get stored in the actual shape until you add another node into the history...then the tweaks get split out into an actual "tweak node". Try tweaking a vert, then do an Extrude Face, then tweak another vert, then do another Extrude Face... Keep the Hypergraph open and look at your history. When you do the tweaks you shouldn't see a tweak node get created because it is being stored locally in the shape, but when you do an extrude you should see the extrude node as well as a tweak node get created.

For what you want to get into I would highly suggest going to http://www.davidgould.com/
and looking at his volume 2 book on Maya programming. Take a look at the Table of Contents...I think it covers most of what you are asking here.

CGTalk Moderation
08-09-2006, 01:45 AM
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.