|
|
@ -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,12 +145,12 @@ 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[] quaternionRotation = new float[] { localRotation.getX(), localRotation.getY(), localRotation.getZ(), localRotation.getW(), }; |
|
|
|
float[] objectRotation = new float[3]; |
|
|
|
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
|
|
|
@ -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]); |
|
|
|
} |
|
|
|
} |
|
|
|