From e1db2e3630ef3c72aaccf0c42049a93fdf5a10de Mon Sep 17 00:00:00 2001 From: stephengold Date: Sun, 17 Nov 2024 14:14:02 -0800 Subject: [PATCH] TrackEdit: add the translate() method --- .../java/jme3utilities/wes/TrackEdit.java | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/WesLibrary/src/main/java/jme3utilities/wes/TrackEdit.java b/WesLibrary/src/main/java/jme3utilities/wes/TrackEdit.java index 93816ff..e3bc113 100644 --- a/WesLibrary/src/main/java/jme3utilities/wes/TrackEdit.java +++ b/WesLibrary/src/main/java/jme3utilities/wes/TrackEdit.java @@ -2488,6 +2488,25 @@ public static TransformTrack smooth(TransformTrack oldTrack, float width, return result; } + /** + * Copy the translations of the specified TransformTrack, adding the + * specified offset to each translation. + * + * @param track input TransformTrack (not null, unaffected) + * @param offset the desired offset (not null, unaffected) + * @return a new array of new vectors + */ + public static Vector3f[] translate(TransformTrack track, Vector3f offset) { + Vector3f[] oldTranslations = track.getTranslations(); + int count = oldTranslations.length; + Vector3f[] result = new Vector3f[count]; + for (int index = 0; index < count; ++index) { + result[index] = oldTranslations[index].add(offset); + } + + return result; + } + /** * Copy a MorphTrack, truncating it at the specified time. *