Blender object animation issues [PATCH]

@Kaelthas The blender importer Ipo class applies a degreeToRadiansFactor to object rotations. But in my tests, the rotation values are already in radians and need to be used as-is.



e.g. see this example cube-ipo-applied.blend



The box should rotate a full 90 degrees, but it’s barely rotating. Patching Ipo.java to not apply that factor makes it work properly.



Separately, it seems like any object transformations that aren’t keyframed are reset to their untransformed values. e.g. see cube-ipo.blend - it’s the same as the above but rot/loc/scale have not been applied to the box. So on the first frame of the animation, the box reverts to 1x1x1 (i.e. the scale transform is lost). In this case, the keyframe is only LocRot - but I would expect the existing scale transform to remain and not be removed. Applying all transforms (as in cube-ipo-applied.blend above) fixes that.



Here’s the patch to Ipo.java to use the rotation values as-is:



[patch]Index: src/blender/com/jme3/scene/plugins/blender/animations/Ipo.java

===================================================================

— src/blender/com/jme3/scene/plugins/blender/animations/Ipo.java (revision 9710)

+++ src/blender/com/jme3/scene/plugins/blender/animations/Ipo.java (working copy)

@@ -141,7 +141,6 @@

float[] objectRotation = new float[3];

Vector3f[] scales = new Vector3f[framesAmount + 1];

float[] scale = new float[] { 1.0f, 1.0f, 1.0f };

  •   	float degreeToRadiansFactor = FastMath.DEG_TO_RAD * 10;// the values in blender are divided by 10, so we need to mult it here<br />
    

// calculating track data
for (int frame = startFrame; frame <= stopFrame; ++frame) {
@@ -169,17 +168,17 @@
// the value here is in degrees divided by 10 (so in
// example: 9 = PI/2)
case OB_ROT_X:
- objectRotation[0] = (float) value * degreeToRadiansFactor;
+ objectRotation[0] = (float) value;
break;
case OB_ROT_Y:
if (fixUpAxis) {
- objectRotation[2] = (float) -value * degreeToRadiansFactor;
+ objectRotation[2] = (float) -value;
} else {
- objectRotation[1] = (float) value * degreeToRadiansFactor;
+ objectRotation[1] = (float) value;
}
break;
case OB_ROT_Z:
- objectRotation[fixUpAxis ? 1 : 2] = (float) value * degreeToRadiansFactor;
+ objectRotation[fixUpAxis ? 1 : 2] = (float) value;
break;

// SIZE
[/patch]
6 Likes

What blender version did you use for tests?



I belive this class was created when blender 2.50+ was still in alpha or beta state.

I’ll check this out because it is possible that your fix will do some mess for 2.49 version so I’ll need to do separate logic for that :slight_smile:



But anyway great thanks for finding it.

@Kaelthas said:
What blender version did you use for tests?


I was using blender 2.63a

OK, turns out that I was right.



Blender earlier that 2.50 had rotations stored in degrees (and divided by 10) and since 2.50 version the values were stored in radians.

I made a fix today. Once again thanks @rectalogic for finding it.

1 Like