Skip to content

Commit b22e4b1

Browse files
authored
jme3-core: add missing javadoc to the com.jme3.anim package (#1521)
* jme3-core: add missing javadoc to the com.jme3.anim package * MorphControl: grammar correction in javadoc * TransformTrack: note aliasing in javadoc
1 parent 1f595f1 commit b22e4b1

13 files changed

Lines changed: 444 additions & 9 deletions

jme3-core/src/main/java/com/jme3/anim/AnimClip.java

Lines changed: 65 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2020 jMonkeyEngine
2+
* Copyright (c) 2009-2021 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -38,6 +38,8 @@
3838
import java.io.IOException;
3939

4040
/**
41+
* A named set of animation tracks that can be played in synchrony.
42+
*
4143
* Created by Nehon on 20/12/2017.
4244
*/
4345
public class AnimClip implements JmeCloneable, Savable {
@@ -47,13 +49,27 @@ public class AnimClip implements JmeCloneable, Savable {
4749

4850
private AnimTrack[] tracks;
4951

52+
/**
53+
* No-argument constructor needed by SavableClassUtil.
54+
*/
5055
protected AnimClip() {
5156
}
5257

58+
/**
59+
* Instantiate a zero-length clip with the specified name.
60+
*
61+
* @param name desired name for the new clip
62+
*/
5363
public AnimClip(String name) {
5464
this.name = name;
5565
}
5666

67+
/**
68+
* Replace all tracks in this clip. This method may increase the clip's
69+
* length, but it will never reduce it.
70+
*
71+
* @param tracks the tracks to use (alias created)
72+
*/
5773
public void setTracks(AnimTrack[] tracks) {
5874
this.tracks = tracks;
5975
for (AnimTrack track : tracks) {
@@ -63,20 +79,38 @@ public void setTracks(AnimTrack[] tracks) {
6379
}
6480
}
6581

82+
/**
83+
* Determine the name of this clip.
84+
*
85+
* @return the name
86+
*/
6687
public String getName() {
6788
return name;
6889
}
6990

70-
91+
/**
92+
* Determine the duration of this clip.
93+
*
94+
* @return the duration (in seconds)
95+
*/
7196
public double getLength() {
7297
return length;
7398
}
7499

75-
100+
/**
101+
* Access all the tracks in this clip.
102+
*
103+
* @return the pre-existing array
104+
*/
76105
public AnimTrack[] getTracks() {
77106
return tracks;
78107
}
79108

109+
/**
110+
* Create a shallow clone for the JME cloner.
111+
*
112+
* @return a new instance
113+
*/
80114
@Override
81115
public Object jmeClone() {
82116
try {
@@ -86,6 +120,15 @@ public Object jmeClone() {
86120
}
87121
}
88122

123+
/**
124+
* Callback from {@link com.jme3.util.clone.Cloner} to convert this
125+
* shallow-cloned clip into a deep-cloned one, using the specified Cloner
126+
* and original to resolve copied fields.
127+
*
128+
* @param cloner the Cloner that's cloning this clip (not null)
129+
* @param original the instance from which this clip was shallow-cloned (not
130+
* null, unaffected)
131+
*/
89132
@Override
90133
public void cloneFields(Cloner cloner, Object original) {
91134
AnimTrack[] newTracks = new AnimTrack[tracks.length];
@@ -95,11 +138,23 @@ public void cloneFields(Cloner cloner, Object original) {
95138
this.tracks = newTracks;
96139
}
97140

141+
/**
142+
* Represent this clip as a String.
143+
*
144+
* @return a descriptive string of text (not null, not empty)
145+
*/
98146
@Override
99147
public String toString() {
100148
return "Clip " + name + ", " + length + 's';
101149
}
102150

151+
/**
152+
* Serialize this clip to the specified exporter, for example when saving to
153+
* a J3O file.
154+
*
155+
* @param ex the exporter to write to (not null)
156+
* @throws IOException from the exporter
157+
*/
103158
@Override
104159
public void write(JmeExporter ex) throws IOException {
105160
OutputCapsule oc = ex.getCapsule(this);
@@ -108,6 +163,13 @@ public void write(JmeExporter ex) throws IOException {
108163

109164
}
110165

166+
/**
167+
* De-serialize this clip from the specified importer, for example when
168+
* loading from a J3O file.
169+
*
170+
* @param im the importer to read from (not null)
171+
* @throws IOException from the importer
172+
*/
111173
@Override
112174
public void read(JmeImporter im) throws IOException {
113175
InputCapsule ic = im.getCapsule(this);

jme3-core/src/main/java/com/jme3/anim/AnimComposer.java

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,9 @@ public class AnimComposer extends AbstractControl {
6565
private float globalSpeed = 1f;
6666
private Map<String, Layer> layers = new LinkedHashMap<>();
6767

68+
/**
69+
* Instantiate a composer with a single layer, no actions, and no clips.
70+
*/
6871
public AnimComposer() {
6972
layers.put(DEFAULT_LAYER, new Layer(this));
7073
}
@@ -314,6 +317,12 @@ public Action removeAction(String name) {
314317
return actions.remove(name);
315318
}
316319

320+
/**
321+
* Add a layer to this composer.
322+
*
323+
* @param name the desired name for the new layer
324+
* @param mask the desired mask for the new layer (alias created)
325+
*/
317326
public void makeLayer(String name, AnimationMask mask) {
318327
Layer l = new Layer(this);
319328
l.mask = mask;
@@ -363,6 +372,9 @@ public BlendAction actionBlended(String name, BlendSpace blendSpace, String... c
363372
return action;
364373
}
365374

375+
/**
376+
* Reset all layers to t=0 with no current action.
377+
*/
366378
public void reset() {
367379
for (Layer layer : layers.values()) {
368380
layer.currentAction = null;
@@ -391,6 +403,11 @@ public Set<String> getAnimClipsNames() {
391403
return Collections.unmodifiableSet(animClipMap.keySet());
392404
}
393405

406+
/**
407+
* used internally
408+
*
409+
* @param tpf time per frame (in seconds)
410+
*/
394411
@Override
395412
protected void controlUpdate(float tpf) {
396413
for (Layer layer : layers.values()) {
@@ -410,19 +427,40 @@ protected void controlUpdate(float tpf) {
410427
}
411428
}
412429

430+
/**
431+
* used internally
432+
*
433+
* @param rm the RenderManager rendering the controlled Spatial (not null)
434+
* @param vp the ViewPort being rendered (not null)
435+
*/
413436
@Override
414437
protected void controlRender(RenderManager rm, ViewPort vp) {
415438

416439
}
417440

441+
/**
442+
* Determine the global speed applied to all layers.
443+
*
444+
* @return the speed factor (1=normal speed)
445+
*/
418446
public float getGlobalSpeed() {
419447
return globalSpeed;
420448
}
421449

450+
/**
451+
* Alter the global speed applied to all layers.
452+
*
453+
* @param globalSpeed the desired speed factor (1=normal speed, default=1)
454+
*/
422455
public void setGlobalSpeed(float globalSpeed) {
423456
this.globalSpeed = globalSpeed;
424457
}
425458

459+
/**
460+
* Create a shallow clone for the JME cloner.
461+
*
462+
* @return a new instance
463+
*/
426464
@Override
427465
public Object jmeClone() {
428466
try {
@@ -433,6 +471,15 @@ public Object jmeClone() {
433471
}
434472
}
435473

474+
/**
475+
* Callback from {@link com.jme3.util.clone.Cloner} to convert this
476+
* shallow-cloned composer into a deep-cloned one, using the specified
477+
* Cloner and original to resolve copied fields.
478+
*
479+
* @param cloner the Cloner that's cloning this composer (not null)
480+
* @param original the instance from which this composer was shallow-cloned
481+
* (not null, unaffected)
482+
*/
436483
@Override
437484
public void cloneFields(Cloner cloner, Object original) {
438485
super.cloneFields(cloner, original);
@@ -456,6 +503,13 @@ public void cloneFields(Cloner cloner, Object original) {
456503

457504
}
458505

506+
/**
507+
* De-serialize this composer from the specified importer, for example when
508+
* loading from a J3O file.
509+
*
510+
* @param im the importer to use (not null)
511+
* @throws IOException from the importer
512+
*/
459513
@Override
460514
@SuppressWarnings("unchecked")
461515
public void read(JmeImporter im) throws IOException {
@@ -465,6 +519,13 @@ public void read(JmeImporter im) throws IOException {
465519
globalSpeed = ic.readFloat("globalSpeed", 1f);
466520
}
467521

522+
/**
523+
* Serialize this composer to the specified exporter, for example when
524+
* saving to a J3O file.
525+
*
526+
* @param ex the exporter to use (not null)
527+
* @throws IOException from the exporter
528+
*/
468529
@Override
469530
public void write(JmeExporter ex) throws IOException {
470531
super.write(ex);

jme3-core/src/main/java/com/jme3/anim/AnimTrack.java

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,25 @@
33
import com.jme3.export.Savable;
44
import com.jme3.util.clone.JmeCloneable;
55

6+
/**
7+
* Interface to derive animation data from a track.
8+
*
9+
* @param <T> the type of data that's being animated, such as Transform
10+
*/
611
public interface AnimTrack<T> extends Savable, JmeCloneable {
712

13+
/**
14+
* Determine the track value for the specified time.
15+
*
16+
* @param time the track time (in seconds)
17+
* @param store storage for the value (not null, modified)
18+
*/
819
public void getDataAtTime(double time, T store);
9-
public double getLength();
10-
1120

21+
/**
22+
* Determine the duration of the track.
23+
*
24+
* @return the duration (in seconds, &ge;0)
25+
*/
26+
public double getLength();
1227
}

jme3-core/src/main/java/com/jme3/anim/AnimationMask.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2009-2020 jMonkeyEngine
2+
* Copyright (c) 2009-2021 jMonkeyEngine
33
* All rights reserved.
44
*
55
* Redistribution and use in source and binary forms, with or without
@@ -38,6 +38,12 @@
3838
*/
3939
public interface AnimationMask {
4040

41+
/**
42+
* Test whether the animation should applied to the specified element.
43+
*
44+
* @param target the target element
45+
* @return true if animation should be applied, otherwise false
46+
*/
4147
boolean contains(Object target);
4248

4349
}

jme3-core/src/main/java/com/jme3/anim/Armature.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,11 @@ public Joint[] getRoots() {
145145
return rootJoints;
146146
}
147147

148+
/**
149+
* Access all joints in this Armature.
150+
*
151+
* @return a new list of pre-existing joints
152+
*/
148153
public List<Joint> getJointList() {
149154
return Arrays.asList(jointList);
150155
}
@@ -290,7 +295,13 @@ public void cloneFields(Cloner cloner, Object original) {
290295
}
291296
}
292297

293-
298+
/**
299+
* De-serialize this Armature from the specified importer, for example when
300+
* loading from a J3O file.
301+
*
302+
* @param im the importer to read from (not null)
303+
* @throws IOException from the importer
304+
*/
294305
@Override
295306
@SuppressWarnings("unchecked")
296307
public void read(JmeImporter im) throws IOException {
@@ -324,6 +335,13 @@ public void read(JmeImporter im) throws IOException {
324335
applyInitialPose();
325336
}
326337

338+
/**
339+
* Serialize this Armature to the specified exporter, for example when
340+
* saving to a J3O file.
341+
*
342+
* @param ex the exporter to write to (not null)
343+
* @throws IOException from the exporter
344+
*/
327345
@Override
328346
public void write(JmeExporter ex) throws IOException {
329347
OutputCapsule output = ex.getCapsule(this);

jme3-core/src/main/java/com/jme3/anim/ArmatureMask.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@
22

33
import java.util.BitSet;
44

5+
/**
6+
* An AnimationMask to select joints from a single Armature.
7+
*/
58
public class ArmatureMask implements AnimationMask {
69

710
final private BitSet affectedJoints = new BitSet();
@@ -62,12 +65,27 @@ public boolean contains(Object target) {
6265
return affectedJoints.get(((Joint) target).getId());
6366
}
6467

68+
/**
69+
* Create an ArmatureMask that selects the named Joint and all its
70+
* descendants.
71+
*
72+
* @param armature the Armature containing the joints (not null)
73+
* @param fromJoint the name of the ancestor joint
74+
* @return a new mask
75+
*/
6576
public static ArmatureMask createMask(Armature armature, String fromJoint) {
6677
ArmatureMask mask = new ArmatureMask();
6778
mask.addFromJoint(armature, fromJoint);
6879
return mask;
6980
}
7081

82+
/**
83+
* Create an ArmatureMask that selects the named joints.
84+
*
85+
* @param armature the Armature containing the joints (not null)
86+
* @param joints the names of the joints to be included
87+
* @return a new mask
88+
*/
7189
public static ArmatureMask createMask(Armature armature, String... joints) {
7290
ArmatureMask mask = new ArmatureMask();
7391
mask.addBones(armature, joints);

0 commit comments

Comments
 (0)