Is Blender susceptible to the dreaded gimbal lock?

I understand that Blender uses quaternions for internal evaluation of rotation angles, which suggests to me that it is not prone to gimbal lock despite the fact it uses Euler angles in the IPOs. For those who don’t know what gimbal lock is, it’s basically when a sequence of rotations happens while evaluating angles with the Euler representations (i.e. traditional x, y, z rotations) where one of the axis rotations cause two axes to line up.

This is common when the rotations are evaluated in x, y, z order and the y rotation is +/- 90 degrees thus causing the z axis to align with the x axis. This subsequently takes away a degree of freedom. Now, even if Blender is not susceptible, I know for a fact that Maya is because it still relies on the Euler method. So, I was wondering if, when modelling a character, I should follow the same practise that you have to in Maya by aligning each of the z directions of the local axes along the armatures.

The reason for this is because if I try to export my armatures into Maya, surely despite the fact that Blender won’t have a problem, Maya may well reach a state of gimbal lock and I would be stuck. The obvious solution is to never use Maya but if I have walk/run/jump cycles built in Blender and if I have to use Maya in a production company, how would I get round this issue.

Just as an aside, BTW, I also noticed that when I import my models from Maya, they are the wrong way up. Maya uses Y for its up axis but Blender uses Z. Now, I rotated the models fine but I discovered that all the local axes of the vertices are the wrong way round - is there a way to fix this?

if you mean the normals i’d just flip them in maya (umm, let me think… “edit polygons>>…” don’t remember any more - it’s been a while).

BTW, how are you exporting your armatures to maya?

marin

No, it doesn’t have anything to do with normals. I don’t think armatures have normals. Gimbal lock is where joint rotations are restricted and can cause undesired flipping. Like a person walking along and suddenly his knee locks and maybe flips erratically.

That’s kind of another thing I wanted to know. I don’t know if it’s possible to do with Maya (I was just using that as an example because I encountered gimbal lock with it) but it must be somehow. I know there is a python script out there that exports armatures from Blender but I don’t know if I can use it with Maya or not. It must have been used for some game engine, though. Has anyone ever exported an armature from Blender to a 3rd party game engine (like Quake) and encountered weird joint effects?

Im answer to your secnond question.

Now, I rotated the models fine but I discovered that all the local axes of the vertices are the wrong way round - is there a way to fix this?

You will require to rotations to fix your local axis.

  1. tab into edit mode and select all verticies. Rotate the verticies so that they are in the correct position with respect to the local axis – the local axis won’t move while you are in edit mode.

  2. tab out of edit mode. you can now roatate the oblect along with its local axis to the correct position.

Don’t know about importing/exporting armatures and animations – I’m usually happy if I can just get my object exported correctly.

Hope this helps,
GreyBeard

I don’t know Greybeard, it’s not the local axis of my model but the local axes of my individual vertices. When I select them all, this rotates them around their collective median but I need to rotate each vertex 90 degrees around it’s own centre.

I can see no reason why, but you can’t do that

you can only rotate individual objects around their center, you need to choose the option on the 3d window header [it is the menu left of the layers]

I must not understand what your saying. A vertex is only a point in space and so cannot have a rotation relative to itself. Why did you want to do this? What undesirable effect do you feel is happening because of this?

GreyBeard

bones have a “Roll” value which can be accessed via “N” -panel in edit mode. so just select two bounding “vertices” (i don’t like this term for bones) and hit “N”.

if this still isn’t what you mean, then i can’t help…

abt exporting there’s an interesting thread right here:
https://blenderartists.org/forum/viewtopic.php?t=27189

marin

It’s because of the direction the local axes of the vertices are pointing in. In order to align vertices, I do the s,y,y,0 combination to align all selected vertices along the x axis. This scales all the points along their median and perfectly lines them along x. However, because the local rotation axes of the points are out by 90 degrees, it means that s,y,y,0 is now s,z,z,0 and it gets confusing because if I use the global axis it’s still s,y,0.

Actually, the bone example is a good one because in the pdf manual on page 213 (actual page is 221 but 213 is written in the corner) it says about setting local axes but not how to do it. It just says:

“To get the best results while animating, it is necessary to ensure that the local axes of each bone are consistent throughout the armature. This should be done before any animation takes place.”

How do you transform any local axis?

Another problem I’m seeing is that I can’t move any of the vertices in their local axes. If I press g,y,y or g,x,x or g,z,z the vertices are stuck. This normally works.

did you read my last post?

EditMode, Rotate mesh
Leave EditMode and CTRL+A to Apply Rot/Size
For Armature, EditMode, selectAll CTRL+N to recalculate Orientation

Yes, but I don’t have any bones. Pressing N for vertices only shows their 3 position coordinates.

I get an error saying “can’t do multi-user mesh”. Also, how do you mean rotate mesh, around the local or global axes?

I think I should try to be a bit clearer. It’s quite a difficult phenomenon to describe. If you go into your 3D Blender view, go into front view and make a new cube.

Rotate the cube 90 degrees in z (assuming z is the up axis).

Then select one of the corners and do g,y,y. You will see that the vertices are stuck - i.e. they cannot be moved in their local axes. So, I was wondering if it was possible to change the orientation of the local axes. Now that I think about it, I suppose it’s not that important as I just move the vertices in global view but why do the vertices lock in local mode?

Because the Y-axis is pointing at you in front view.

%<

osx, i understand less and less… i thought you were talking abt bones gimbal lock? but you seem to talk abt mesh vertices?? vertices per se have no orientation, so no gimbal lock can occur. if you have problems with exported objects in other packages (maya) you should set up there the position and orientation of your pivots so that GL doesn’t occur.

Yeah, that’s right. But if you do say, g,y,y,1 the vertices move as normal so why do they lock up for the mouse?

I just want to know how the local axes of vertices are defined? For example, I know the local vertex positions are defined relative to the object centre (the little purple dot). How do you define what is the local z-axis, say for each vertex individually or are the local axes of vertices calculated automatically? You can change the global axes, can’t you? How do you define what is globally up? By default it is Z.

You’re right, I confused the issue with the vertices. Initially, I just wanted to know if I exported armatures from Blender would they be susceptible to gimbal lock if used in a system that doesn’t use quaternions to evaluate the rotations. And I was also asking if Blender was susceptible to gimbal lock in general. I think what LOD said about armatures should sort out this problem if that recalculation of orientation aligns the local axes of the joints to the joint directions. It sounds like it does.

You’re also correct that gimbal lock doesn’t happen in vertices, I was asking about something else. The problem I had there was that I had some models I did in Maya and I wanted to use them in Blender but when I imported them, they were 90 degrees out. I have shown that if you rotate a model 90 degrees then the vertices don’t move locally with the mouse, which is a similar effect to gimbal lock but I don’t think it is. I just wanted to know how to fix it. Using global axes is one way to avoid it.

to align your local axis, you can use my script. it works under 2.33a.
a select first an object to give orientation then the object with the axis which need to be realign and press alt+p in the script.

if need, i can to a version for the new script windows.

the url : http://www.zoo-logique.org/3D.Blender/blenderfiles/script_realign_axis.blend

That’s exactly what I’m talking about thanks, Xand. I was hoping I could do it more easily in Blender, though. I was able to change the orientation of local axes in Maya using a MEL script like “rotate -r -os 90 0 0” for rotating locally around x. I’ll have to get more clued up on Python.

umm, CTRL + A doesn’t do it? (apply size/rot, i.e. however the object is rotated/scaled, it sets RotX,Y,Z and SizeX,Y,Z to 0,0,0 and 1,1,1)

Fligh % wrote:

[quote]Because the Y-axis is pointing at you in front view.

Yeah, that’s right. But if you do say, g,y,y,1 the vertices move as normal so why do they lock up for the mouse?

[/quote]

How would the movement of the mouse determine the movement along the axis [left/right ? up/down?] and then how would you see where the vert, or more tricky still verts, is/are being placed? All this taking into account things like mouse gestures, Proportional editing and Alt-S from the coding POV.
Side view is one hotkey away (or one window to the right).

%<

no if i remember correctly it uses quaternions for skeletal animation. :slight_smile: