/** * returns the rotation for a given frame index * creates the rotation if it doesn't exists * @param keyFrameIndex index * @return the rotation */ private Rotation getRotationForFrame(int keyFrameIndex) { if (keyFrameIndex < 0 || keyFrameIndex > totalFrames) { throw new ArrayIndexOutOfBoundsException("keyFrameIndex must be between 0 and " + totalFrames + " (received " + keyFrameIndex + ")"); } Rotation v = keyFramesRotation[keyFrameIndex]; if (v == null) { v = new Rotation(); keyFramesRotation[keyFrameIndex] = v; } return v; }
/** * Creates and AnimationHelper * @param duration the desired duration for the resulting animation * @param name the name of the resulting animation * @param fps the number of frames per second for this animation (default is 30) */ public AnimationFactory(float duration, String name, int fps) { this.name = name; this.duration = duration; this.fps = fps; totalFrames = (int) (fps * duration) + 1; tpf = 1 / (float) fps; times = new float[totalFrames]; translations = new Vector3f[totalFrames]; rotations = new Quaternion[totalFrames]; scales = new Vector3f[totalFrames]; keyFramesTranslation = new Vector3f[totalFrames]; keyFramesTranslation[0] = new Vector3f(); keyFramesScale = new Vector3f[totalFrames]; keyFramesScale[0] = new Vector3f(1, 1, 1); keyFramesRotation = new Rotation[totalFrames]; keyFramesRotation[0] = new Rotation(); }
/** * Creates and AnimationHelper * @param duration the desired duration for the resulting animation * @param name the name of the resulting animation * @param fps the number of frames per second for this animation (default is 30) */ public AnimationFactory(float duration, String name, int fps) { this.name = name; this.duration = duration; this.fps = fps; totalFrames = (int) (fps * duration) + 1; tpf = 1 / (float) fps; times = new float[totalFrames]; translations = new Vector3f[totalFrames]; rotations = new Quaternion[totalFrames]; scales = new Vector3f[totalFrames]; keyFramesTranslation = new Vector3f[totalFrames]; keyFramesTranslation[0] = new Vector3f(); keyFramesScale = new Vector3f[totalFrames]; keyFramesScale[0] = new Vector3f(1, 1, 1); keyFramesRotation = new Rotation[totalFrames]; keyFramesRotation[0] = new Rotation(); }
/** * returns the rotation for a given frame index * creates the rotation if it doesn't exists * @param keyFrameIndex index * @return the rotation */ private Rotation getRotationForFrame(int keyFrameIndex) { if (keyFrameIndex < 0 || keyFrameIndex > totalFrames) { throw new ArrayIndexOutOfBoundsException("keyFrameIndex must be between 0 and " + totalFrames + " (received " + keyFrameIndex + ")"); } Rotation v = keyFramesRotation[keyFrameIndex]; if (v == null) { v = new Rotation(); keyFramesRotation[keyFrameIndex] = v; } return v; }
/** * returns the rotation for a given frame index * creates the rotation if it doesn't exists * @param keyFrameIndex index * @return the rotation */ private Rotation getRotationForFrame(int keyFrameIndex) { if (keyFrameIndex < 0 || keyFrameIndex > totalFrames) { throw new ArrayIndexOutOfBoundsException("keyFrameIndex must be between 0 and " + totalFrames + " (received " + keyFrameIndex + ")"); } Rotation v = keyFramesRotation[keyFrameIndex]; if (v == null) { v = new Rotation(); keyFramesRotation[keyFrameIndex] = v; } return v; }
/** * Adds a key frame for the given rotation at the given keyFrame index<br> * This can't be used if the interpolated angle is higher than PI (180°)<br> * Use {@link #addKeyFrameRotationAngles(int keyFrameIndex, float x, float y, float z)} instead that uses Euler angles rotations. * @param keyFrameIndex the index at which the keyFrame must be inserted * @param rotation the rotation Quaternion to use for this keyFrame * @see #addKeyFrameRotationAngles(int keyFrameIndex, float x, float y, float z) */ public void addKeyFrameRotation(int keyFrameIndex, Quaternion rotation) { Rotation r = getRotationForFrame(keyFrameIndex); r.set(rotation); }
/** * Adds a key frame for the given rotation at the given keyFrame index<br> * This can't be used if the interpolated angle is higher than PI (180°)<br> * Use {@link #addKeyFrameRotationAngles(int keyFrameIndex, float x, float y, float z)} instead that uses Euler angles rotations. * @param keyFrameIndex the index at which the keyFrame must be inserted * @param rotation the rotation Quaternion to use for this keyFrame * @see #addKeyFrameRotationAngles(int keyFrameIndex, float x, float y, float z) */ public void addKeyFrameRotation(int keyFrameIndex, Quaternion rotation) { Rotation r = getRotationForFrame(keyFrameIndex); r.set(rotation); }
/** * Creates and AnimationHelper * @param duration the desired duration for the resulting animation * @param name the name of the resulting animation * @param fps the number of frames per second for this animation (default is 30) */ public AnimationFactory(float duration, String name, int fps) { this.name = name; this.duration = duration; this.fps = fps; totalFrames = (int) (fps * duration) + 1; tpf = 1 / (float) fps; times = new float[totalFrames]; translations = new Vector3f[totalFrames]; rotations = new Quaternion[totalFrames]; scales = new Vector3f[totalFrames]; keyFramesTranslation = new Vector3f[totalFrames]; keyFramesTranslation[0] = new Vector3f(); keyFramesScale = new Vector3f[totalFrames]; keyFramesScale[0] = new Vector3f(1, 1, 1); keyFramesRotation = new Rotation[totalFrames]; keyFramesRotation[0] = new Rotation(); }
/** * Adds a key frame for the given rotation at the given keyFrame index<br> * This can't be used if the interpolated angle is higher than PI (180°)<br> * Use {@link #addKeyFrameRotationAngles(int keyFrameIndex, float x, float y, float z)} instead that uses Euler angles rotations. * @param keyFrameIndex the index at which the keyFrame must be inserted * @param rotation the rotation Quaternion to use for this keyFrame * @see #addKeyFrameRotationAngles(int keyFrameIndex, float x, float y, float z) */ public void addKeyFrameRotation(int keyFrameIndex, Quaternion rotation) { Rotation r = getRotationForFrame(keyFrameIndex); r.set(rotation); }