4242import java .io .IOException ;
4343
4444/**
45- * Contains a list of transforms and times for each keyframe.
45+ * An AnimTrack that transforms a Joint or Spatial
46+ * using a list of transforms and times for keyframes.
4647 *
4748 * @author Rémy Bouquet
4849 */
4950public class TransformTrack implements AnimTrack <Transform > {
5051
5152 private double length ;
53+ private FrameInterpolator interpolator = FrameInterpolator .DEFAULT ;
5254 private HasLocalTransform target ;
5355
5456 /**
55- * Transforms and times for track .
57+ * Transforms and times for keyframes .
5658 */
5759 private CompactVector3Array translations ;
5860 private CompactQuaternionArray rotations ;
5961 private CompactVector3Array scales ;
60- private FrameInterpolator interpolator = FrameInterpolator .DEFAULT ;
6162 private float [] times ;
6263
6364 /**
@@ -67,39 +68,42 @@ protected TransformTrack() {
6768 }
6869
6970 /**
70- * Creates a transform track for the given bone index
71+ * Creates a transform track for the given target.
7172 *
7273 * @param target the target Joint or Spatial of the new track
73- * @param times a float array with the time of each frame
74- * @param translations the translation of the bone for each frame
75- * @param rotations the rotation of the bone for each frame
76- * @param scales the scale of the bone for each frame
74+ * @param times the time for each keyframe, or null for none
75+ * @param translations the translation of the target for each keyframe
76+ * (same length as times) or null for no translation
77+ * @param rotations the rotation of the target for each keyframe
78+ * (same length as times) or null for no rotation
79+ * @param scales the scale of the target for each keyframe
80+ * (same length as times) or null for no scaling
7781 */
7882 public TransformTrack (HasLocalTransform target , float [] times , Vector3f [] translations , Quaternion [] rotations , Vector3f [] scales ) {
7983 this .target = target ;
8084 this .setKeyframes (times , translations , rotations , scales );
8185 }
8286
8387 /**
84- * return the array of rotations of this track
88+ * Copies the rotations.
8589 *
86- * @return an array, or null if no rotations
90+ * @return a new array, or null if no rotations
8791 */
8892 public Quaternion [] getRotations () {
8993 return rotations == null ? null : rotations .toObjectArray ();
9094 }
9195
9296 /**
93- * returns the array of scales for this track
97+ * Copies the scales.
9498 *
95- * @return an array or null
99+ * @return a new array, or null if no scales
96100 */
97101 public Vector3f [] getScales () {
98102 return scales == null ? null : scales .toObjectArray ();
99103 }
100104
101105 /**
102- * returns the arrays of time for this track
106+ * Gives access to the keyframe times.
103107 *
104108 * @return the pre-existing array
105109 */
@@ -108,19 +112,19 @@ public float[] getTimes() {
108112 }
109113
110114 /**
111- * returns the array of translations of this track
115+ * Copies the translations.
112116 *
113- * @return an array, or null if no translations
117+ * @return a new array, or null if no translations
114118 */
115119 public Vector3f [] getTranslations () {
116120 return translations == null ? null : translations .toObjectArray ();
117121 }
118122
119123
120124 /**
121- * Sets the keyframes times for this Joint track
125+ * Sets the keyframe times.
122126 *
123- * @param times the keyframes times
127+ * @param times the desired keyframe times (alias created, not null, not empty)
124128 */
125129 public void setTimes (float [] times ) {
126130 if (times == null || times .length == 0 ) {
@@ -132,9 +136,10 @@ public void setTimes(float[] times) {
132136 }
133137
134138 /**
135- * Set the translations for this joint track
139+ * Sets the translations.
136140 *
137- * @param translations the translation of the bone for each frame
141+ * @param translations the desired translation of the target for each
142+ * keyframe (not null, same length as "times")
138143 */
139144 public void setKeyframesTranslation (Vector3f [] translations ) {
140145 if (times == null ) {
@@ -154,9 +159,10 @@ public void setKeyframesTranslation(Vector3f[] translations) {
154159 }
155160
156161 /**
157- * Set the scales for this joint track
162+ * Sets the scales.
158163 *
159- * @param scales the scales of the bone for each frame
164+ * @param scales the desired scale of the target for each keyframe (not
165+ * null, same length as "times")
160166 */
161167 public void setKeyframesScale (Vector3f [] scales ) {
162168 if (times == null ) {
@@ -176,9 +182,10 @@ public void setKeyframesScale(Vector3f[] scales) {
176182 }
177183
178184 /**
179- * Set the rotations for this joint track
185+ * Sets the rotations.
180186 *
181- * @param rotations the rotations of the bone for each frame
187+ * @param rotations the desired rotation of the target for each keyframe
188+ * (not null, same length as "times")
182189 */
183190 public void setKeyframesRotation (Quaternion [] rotations ) {
184191 if (times == null ) {
@@ -199,12 +206,19 @@ public void setKeyframesRotation(Quaternion[] rotations) {
199206
200207
201208 /**
202- * Set the translations, rotations and scales for this bone track
209+ * Sets the translations, rotations, and/or scales.
203210 *
204- * @param times a float array with the time of each frame
205- * @param translations the translation of the bone for each frame
206- * @param rotations the rotation of the bone for each frame
207- * @param scales the scale of the bone for each frame
211+ * @param times the desired time for each keyframe,
212+ * or null to leave the times unchanged
213+ * @param translations the desired translation of the target for each
214+ * keyframe (same length as times)
215+ * or null to leave the translations unchanged
216+ * @param rotations the desired rotation of the target for each keyframe
217+ * (same length as times)
218+ * or null to leave the rotations unchanged
219+ * @param scales the desired scale of the target for each keyframe
220+ * (same length as times)
221+ * or null to leave the scales unchanged
208222 */
209223 public void setKeyframes (float [] times , Vector3f [] translations , Quaternion [] rotations , Vector3f [] scales ) {
210224 if (times != null ) {
@@ -248,7 +262,7 @@ public void getDataAtTime(double t, Transform transform) {
248262 int endFrame = 1 ;
249263 float blend = 0 ;
250264 if (time >= times [lastFrame ]) {
251- // extrapolate beyond the final frame of the animation
265+ // extrapolate beyond the final keyframe of the animation
252266 startFrame = lastFrame ;
253267
254268 float inferredInterval = times [lastFrame ] - times [lastFrame - 1 ];
@@ -281,7 +295,7 @@ public void getDataAtTime(double t, Transform transform) {
281295 }
282296
283297 /**
284- * Replace the frame interpolator.
298+ * Replaces the frame interpolator.
285299 *
286300 * @param interpolator the interpolator to use (alias created)
287301 */
@@ -290,8 +304,7 @@ public void setFrameInterpolator(FrameInterpolator interpolator) {
290304 }
291305
292306 /**
293- * Access the target affected by this track, which might be a Joint or a
294- * Spatial.
307+ * Gives access to the target, which might be a Joint or a Spatial.
295308 *
296309 * @return the pre-existing instance
297310 */
@@ -300,7 +313,7 @@ public HasLocalTransform getTarget() {
300313 }
301314
302315 /**
303- * Replace the target of this track , which might be a Joint or a Spatial.
316+ * Replaces the target, which might be a Joint or a Spatial.
304317 *
305318 * @param target the target to use (alias created)
306319 */
@@ -309,7 +322,7 @@ public void setTarget(HasLocalTransform target) {
309322 }
310323
311324 /**
312- * Serialize this track to the specified exporter, for example when
325+ * Serializes this track to the specified exporter, for example when
313326 * saving to a J3O file.
314327 *
315328 * @param ex the exporter to write to (not null)
@@ -326,7 +339,7 @@ public void write(JmeExporter ex) throws IOException {
326339 }
327340
328341 /**
329- * De-serialize this track from the specified importer, for example when
342+ * De-serializes this track from the specified importer, for example when
330343 * loading from a J3O file.
331344 *
332345 * @param im the importer to read from (not null)
0 commit comments