|
@@ -115,23 +115,29 @@ public class Ipo {
|
|
* the index of the target for which the method calculates the
|
|
* the index of the target for which the method calculates the
|
|
* tracks IMPORTANT! Aet to -1 (or any negative number) if you
|
|
* tracks IMPORTANT! Aet to -1 (or any negative number) if you
|
|
* want to load spatial animation.
|
|
* want to load spatial animation.
|
|
- * @param localQuaternionRotation
|
|
|
|
|
|
+ * @param localTranslation
|
|
|
|
+ * the local translation of the object/bone that will be animated by
|
|
|
|
+ * the track
|
|
|
|
+ * @param localRotation
|
|
* the local rotation of the object/bone that will be animated by
|
|
* the local rotation of the object/bone that will be animated by
|
|
* the track
|
|
* the track
|
|
|
|
+ * @param localScale
|
|
|
|
+ * the local scale of the object/bone that will be animated by
|
|
|
|
+ * the track
|
|
* @param startFrame
|
|
* @param startFrame
|
|
- * the firs frame of tracks (inclusive)
|
|
|
|
|
|
+ * the first frame of tracks (inclusive)
|
|
* @param stopFrame
|
|
* @param stopFrame
|
|
* the last frame of the tracks (inclusive)
|
|
* the last frame of the tracks (inclusive)
|
|
* @param fps
|
|
* @param fps
|
|
* frame rate (frames per second)
|
|
* frame rate (frames per second)
|
|
* @param spatialTrack
|
|
* @param spatialTrack
|
|
* this flag indicates if the track belongs to a spatial or to a
|
|
* this flag indicates if the track belongs to a spatial or to a
|
|
- * bone; the diference is important because it appears that bones
|
|
|
|
|
|
+ * bone; the difference is important because it appears that bones
|
|
* in blender have the same type of coordinate system (Y as UP)
|
|
* in blender have the same type of coordinate system (Y as UP)
|
|
* as jme while other features have different one (Z is UP)
|
|
* as jme while other features have different one (Z is UP)
|
|
* @return bone track for the specified bone
|
|
* @return bone track for the specified bone
|
|
*/
|
|
*/
|
|
- public Track calculateTrack(int targetIndex, Quaternion localQuaternionRotation, int startFrame, int stopFrame, int fps, boolean spatialTrack) {
|
|
|
|
|
|
+ public Track calculateTrack(int targetIndex, Vector3f localTranslation, Quaternion localRotation, Vector3f localScale, int startFrame, int stopFrame, int fps, boolean spatialTrack) {
|
|
if (calculatedTrack == null) {
|
|
if (calculatedTrack == null) {
|
|
// preparing data for track
|
|
// preparing data for track
|
|
int framesAmount = stopFrame - startFrame;
|
|
int framesAmount = stopFrame - startFrame;
|
|
@@ -139,18 +145,18 @@ public class Ipo {
|
|
|
|
|
|
float[] times = new float[framesAmount + 1];
|
|
float[] times = new float[framesAmount + 1];
|
|
Vector3f[] translations = new Vector3f[framesAmount + 1];
|
|
Vector3f[] translations = new Vector3f[framesAmount + 1];
|
|
- float[] translation = new float[3];
|
|
|
|
|
|
+ float[] translation = new float[] { localTranslation.x, localTranslation.y, localTranslation.z };
|
|
Quaternion[] rotations = new Quaternion[framesAmount + 1];
|
|
Quaternion[] rotations = new Quaternion[framesAmount + 1];
|
|
- float[] quaternionRotation = new float[] { 0, 0, 0, 1 };
|
|
|
|
- float[] objectRotation = new float[3];
|
|
|
|
|
|
+ float[] quaternionRotation = new float[] { localRotation.getX(), localRotation.getY(), localRotation.getZ(), localRotation.getW(), };
|
|
|
|
+ float[] objectRotation = localRotation.toAngles(null);
|
|
Vector3f[] scales = new Vector3f[framesAmount + 1];
|
|
Vector3f[] scales = new Vector3f[framesAmount + 1];
|
|
- float[] scale = new float[] { 1.0f, 1.0f, 1.0f };
|
|
|
|
|
|
+ float[] scale = new float[] { localScale.x, localScale.y, localScale.z };
|
|
float degreeToRadiansFactor = 1;
|
|
float degreeToRadiansFactor = 1;
|
|
if (blenderVersion < 250) {// in blender earlier than 2.50 the values are stored in degrees
|
|
if (blenderVersion < 250) {// in blender earlier than 2.50 the values are stored in degrees
|
|
degreeToRadiansFactor *= FastMath.DEG_TO_RAD * 10;// the values in blender are divided by 10, so we need to mult it here
|
|
degreeToRadiansFactor *= FastMath.DEG_TO_RAD * 10;// the values in blender are divided by 10, so we need to mult it here
|
|
}
|
|
}
|
|
int yIndex = 1, zIndex = 2;
|
|
int yIndex = 1, zIndex = 2;
|
|
- if(spatialTrack && fixUpAxis) {
|
|
|
|
|
|
+ if (spatialTrack && fixUpAxis) {
|
|
yIndex = 2;
|
|
yIndex = 2;
|
|
zIndex = 1;
|
|
zIndex = 1;
|
|
}
|
|
}
|
|
@@ -163,12 +169,12 @@ public class Ipo {
|
|
for (int j = 0; j < bezierCurves.length; ++j) {
|
|
for (int j = 0; j < bezierCurves.length; ++j) {
|
|
double value = bezierCurves[j].evaluate(frame, BezierCurve.Y_VALUE);
|
|
double value = bezierCurves[j].evaluate(frame, BezierCurve.Y_VALUE);
|
|
switch (bezierCurves[j].getType()) {
|
|
switch (bezierCurves[j].getType()) {
|
|
- // LOCATION
|
|
|
|
|
|
+ // LOCATION
|
|
case AC_LOC_X:
|
|
case AC_LOC_X:
|
|
translation[0] = (float) value;
|
|
translation[0] = (float) value;
|
|
break;
|
|
break;
|
|
case AC_LOC_Y:
|
|
case AC_LOC_Y:
|
|
- if(fixUpAxis && value != 0) {
|
|
|
|
|
|
+ if (fixUpAxis && value != 0) {
|
|
value = -value;
|
|
value = -value;
|
|
}
|
|
}
|
|
translation[yIndex] = (float) value;
|
|
translation[yIndex] = (float) value;
|
|
@@ -182,7 +188,7 @@ public class Ipo {
|
|
objectRotation[0] = (float) value * degreeToRadiansFactor;
|
|
objectRotation[0] = (float) value * degreeToRadiansFactor;
|
|
break;
|
|
break;
|
|
case OB_ROT_Y:
|
|
case OB_ROT_Y:
|
|
- if(fixUpAxis && value != 0) {
|
|
|
|
|
|
+ if (fixUpAxis && value != 0) {
|
|
value = -value;
|
|
value = -value;
|
|
}
|
|
}
|
|
objectRotation[yIndex] = (float) value * degreeToRadiansFactor;
|
|
objectRotation[yIndex] = (float) value * degreeToRadiansFactor;
|
|
@@ -210,10 +216,10 @@ public class Ipo {
|
|
quaternionRotation[0] = (float) value;
|
|
quaternionRotation[0] = (float) value;
|
|
break;
|
|
break;
|
|
case AC_QUAT_Y:
|
|
case AC_QUAT_Y:
|
|
- if(fixUpAxis && value != 0) {
|
|
|
|
|
|
+ if (fixUpAxis && value != 0) {
|
|
value = -value;
|
|
value = -value;
|
|
}
|
|
}
|
|
- quaternionRotation[yIndex] = (float)value;
|
|
|
|
|
|
+ quaternionRotation[yIndex] = (float) value;
|
|
break;
|
|
break;
|
|
case AC_QUAT_Z:
|
|
case AC_QUAT_Z:
|
|
quaternionRotation[zIndex] = (float) value;
|
|
quaternionRotation[zIndex] = (float) value;
|
|
@@ -222,7 +228,7 @@ public class Ipo {
|
|
LOGGER.log(Level.WARNING, "Unknown ipo curve type: {0}.", bezierCurves[j].getType());
|
|
LOGGER.log(Level.WARNING, "Unknown ipo curve type: {0}.", bezierCurves[j].getType());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- translations[index] = localQuaternionRotation.multLocal(new Vector3f(translation[0], translation[1], translation[2]));
|
|
|
|
|
|
+ translations[index] = localRotation.multLocal(new Vector3f(translation[0], translation[1], translation[2]));
|
|
rotations[index] = spatialTrack ? new Quaternion().fromAngles(objectRotation) : new Quaternion(quaternionRotation[0], quaternionRotation[1], quaternionRotation[2], quaternionRotation[3]);
|
|
rotations[index] = spatialTrack ? new Quaternion().fromAngles(objectRotation) : new Quaternion(quaternionRotation[0], quaternionRotation[1], quaternionRotation[2], quaternionRotation[3]);
|
|
scales[index] = new Vector3f(scale[0], scale[1], scale[2]);
|
|
scales[index] = new Vector3f(scale[0], scale[1], scale[2]);
|
|
}
|
|
}
|