Skip to content

Commit b9b4d81

Browse files
committed
cleanup
1 parent a6a5df1 commit b9b4d81

File tree

5 files changed

+61
-89
lines changed

5 files changed

+61
-89
lines changed

jme3-core/src/main/java/com/jme3/cinematic/Cinematic.java

Lines changed: 36 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -59,38 +59,36 @@
5959
import java.util.logging.Logger;
6060

6161
/**
62-
* An AppState for composing and playing cutscenes in a game.
62+
* An appstate for composing and playing cutscenes in a game. The cinematic
63+
* schedules CinematicEvents over a timeline. Once the Cinematic created it has
64+
* to be attached to the stateManager.
6365
*
64-
* <p>A cinematic schedules and plays {@link CinematicEvent}s over a timeline.
65-
* Once a Cinematic is created, you must attach it to the `AppStateManager` to
66-
* run it. You can add various `CinematicEvent`s, see the `com.jme3.cinematic.events`
67-
* package for built-in event types.
66+
* You can add various CinematicEvents to a Cinematic, see package
67+
* com.jme3.cinematic.events
6868
*
69-
* <p>Events can be added in two main ways:
70-
* <ul>
71-
* <li>{@link Cinematic#addCinematicEvent(float, CinematicEvent)} adds an event
72-
* at a specific time from the cinematic's start.</li>
73-
* <li>{@link Cinematic#enqueueCinematicEvent(CinematicEvent)} adds events
74-
* one after another, with each starting at the end of the previous one.</li>
75-
* </ul>
69+
* Two main methods can be used to add an event :
7670
*
77-
* <p>Playback can be controlled with methods like:
78-
* <ul>
79-
* <li>{@link Cinematic#play()}</li>
80-
* <li>{@link Cinematic#pause()}</li>
81-
* <li>{@link Cinematic#stop()}</li>
82-
* </ul>
71+
* @see Cinematic#addCinematicEvent(float,
72+
* com.jme3.cinematic.events.CinematicEvent) , that adds an event at the given
73+
* time form the cinematic start.
8374
*
84-
* <p>Since `Cinematic` itself extends `CinematicEvent`, you can nest cinematics
85-
* within each other. Nested cinematics should not be attached to the `AppStateManager`.
75+
* @see
76+
* Cinematic#enqueueCinematicEvent(com.jme3.cinematic.events.CinematicEvent)
77+
* that enqueue events one after the other according to their initialDuration
8678
*
87-
* <p>This class also handles multiple camera points of view by creating and
88-
* activating camera nodes on a schedule.
89-
* <ul>
90-
* <li>{@link Cinematic#bindCamera(java.lang.String, com.jme3.renderer.Camera)}</li>
91-
* <li>{@link Cinematic#activateCamera(float, java.lang.String)}</li>
92-
* <li>{@link Cinematic#setActiveCamera(java.lang.String)}</li>
93-
* </ul>
79+
* A Cinematic has convenient methods to manage playback:
80+
* @see Cinematic#play()
81+
* @see Cinematic#pause()
82+
* @see Cinematic#stop()
83+
*
84+
* A Cinematic is itself a CinematicEvent, meaning you can embed several
85+
* cinematics. Embedded cinematics must not be added to the stateManager though.
86+
*
87+
* Cinematic can handle several points of view by creating camera nodes
88+
* and activating them on schedule.
89+
* @see Cinematic#bindCamera(java.lang.String, com.jme3.renderer.Camera)
90+
* @see Cinematic#activateCamera(float, java.lang.String)
91+
* @see Cinematic#setActiveCamera(java.lang.String)
9492
*
9593
* @author Nehon
9694
*/
@@ -295,8 +293,8 @@ public void write(JmeExporter ex) throws IOException {
295293

296294
oc.write(cinematicEvents.toArray(new CinematicEvent[cinematicEvents.size()]), "cinematicEvents",
297295
null);
298-
oc.writeStringSavableMap(cameras, "cameras", null);
299-
oc.write(timeLine, "timeLine", null);
296+
oc.writeStringSavableMap(cameras, "cameras", null);
297+
oc.write(timeLine, "timeLine", null);
300298
} finally {
301299
// unhack
302300
for (CinematicEvent event : cinematicEvents) {
@@ -353,8 +351,6 @@ public void setSpeed(float speed) {
353351
public void initialize(AppStateManager stateManager, Application app) {
354352
this.app = app;
355353
initEvent(app, this);
356-
357-
System.out.println("Initializing");
358354
for (CinematicEvent cinematicEvent : cinematicEvents) {
359355
relinkAnimComposer(cinematicEvent);
360356
relinkCinematic(cinematicEvent);
@@ -503,7 +499,6 @@ public void stateDetached(AppStateManager stateManager) {
503499
@Override
504500
public void update(float tpf) {
505501
if (isInitialized() && playState == PlayState.Playing) {
506-
System.out.println("Updating cinematic at time " + cinematic);
507502
internalUpdate(tpf);
508503
}
509504
}
@@ -704,14 +699,14 @@ public void fitDuration() {
704699
}
705700

706701
/**
707-
* Binds a camera to this Cinematic, tagged by a unique name. This method creates and returns a CameraNode
708-
* for the cam and attaches it to the scene. The control direction is set to SpatialToCamera. This camera
709-
* Node can then be used in other events to handle the camera movements during playback.
702+
* Binds a camera to this Cinematic, tagged by a unique name. This method
703+
* creates and returns a CameraNode for the cam and attaches it to the scene.
704+
* The control direction is set to SpatialToCamera. This camera Node can
705+
* then be used in other events to handle the camera movements during
706+
* playback.
710707
*
711-
* @param cameraName
712-
* the unique tag the camera should have
713-
* @param cam
714-
* the scene camera.
708+
* @param cameraName the unique tag the camera should have
709+
* @param cam the scene camera.
715710
* @return the created CameraNode.
716711
*/
717712
public CameraNode bindCamera(String cameraName, Camera cam) {
@@ -739,9 +734,9 @@ public CameraNode getCamera(String cameraName) {
739734
}
740735

741736
/**
742-
* Enables or disables the camera control of the cameraNode of the current cam.
737+
* enable/disable the camera control of the cameraNode of the current cam
743738
*
744-
* @param enabled `true` to enable, `false` to disable.
739+
* @param enabled
745740
*/
746741
private void setEnableCurrentCam(boolean enabled) {
747742
if (currentCam != null) {
@@ -866,14 +861,6 @@ public Node getScene() {
866861
return scene;
867862
}
868863

869-
/**
870-
* Gets the application instance associated with this cinematic.
871-
*
872-
* @return The application.
873-
*/
874-
public Application getApplication() {
875-
return app;
876-
}
877864

878865
/**
879866
* Remove all events from the Cinematic.

jme3-core/src/main/java/com/jme3/cinematic/events/AbstractCinematicEvent.java

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,6 @@
3939
import com.jme3.export.JmeExporter;
4040
import com.jme3.export.JmeImporter;
4141
import com.jme3.export.OutputCapsule;
42-
import com.jme3.util.clone.Cloner;
43-
import com.jme3.util.clone.JmeCloneable;
44-
4542
import java.io.IOException;
4643
import java.util.ArrayList;
4744
import java.util.List;
@@ -312,10 +309,7 @@ public void read(JmeImporter im) throws IOException {
312309
speed = ic.readFloat("speed", 1);
313310
initialDuration = ic.readFloat("initalDuration", 10);
314311
loopMode = ic.readEnum("loopMode", LoopMode.class, LoopMode.DontLoop);
315-
CinematicHandler cinematic = (CinematicHandler) ic.readSavable("cinematic", null);
316-
if (cinematic != null) {
317-
this.cinematic = cinematic;
318-
}
312+
cinematic = (CinematicHandler) ic.readSavable("cinematic", null);
319313
}
320314

321315
/**

jme3-core/src/main/java/com/jme3/cinematic/events/AnimEvent.java

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -75,8 +75,8 @@ public class AnimEvent extends AbstractCinematicEvent {
7575
* name of the animation layer on which the action will be played
7676
*/
7777
private String layerName;
78-
79-
/**
78+
79+
/**
8080
* Constructs a new AnimEvent to play the named action on the default layer.
8181
*
8282
* @param composer the Control that will play the animation (not null).
@@ -194,6 +194,23 @@ public void onUpdate(float tpf) {
194194
// do nothing
195195
}
196196

197+
/**
198+
* De-serialize this event from the specified importer, for example when
199+
* loading from a J3O file.
200+
*
201+
* @param importer (not null)
202+
* @throws IOException from the importer
203+
*/
204+
@Override
205+
public void read(JmeImporter importer) throws IOException {
206+
super.read(importer);
207+
InputCapsule capsule = importer.getCapsule(this);
208+
actionName = capsule.readString("actionName", "");
209+
composer = (AnimComposer) capsule.readSavable("composer", null);
210+
layerName = capsule.readString("layerName", AnimComposer.DEFAULT_LAYER);
211+
animRef = capsule.readString("animRef", null);
212+
}
213+
197214
/**
198215
* Alter the speed of the animation.
199216
*
@@ -254,23 +271,6 @@ public void setTime(float time) {
254271
}
255272
}
256273

257-
/**
258-
* De-serialize this event from the specified importer, for example when
259-
* loading from a J3O file.
260-
*
261-
* @param importer (not null)
262-
* @throws IOException from the importer
263-
*/
264-
@Override
265-
public void read(JmeImporter importer) throws IOException {
266-
super.read(importer);
267-
InputCapsule capsule = importer.getCapsule(this);
268-
actionName = capsule.readString("actionName", "");
269-
composer = (AnimComposer) capsule.readSavable("composer", null);
270-
layerName = capsule.readString("layerName", AnimComposer.DEFAULT_LAYER);
271-
animRef = capsule.readString("animRef", null);
272-
}
273-
274274
/**
275275
* Serialize this event to the specified exporter, for example when saving
276276
* to a J3O file.

jme3-core/src/main/java/com/jme3/cinematic/events/CinematicEvent.java

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -51,17 +51,16 @@ public interface CinematicEvent extends Savable, CinematicBase {
5151

5252
/**
5353
* initialize this event
54-
*
55-
* @param cinematic
56-
* the cinematic
54+
* @param app the application
55+
* @param cinematic the cinematic
5756
*/
5857
public void initEvent(CinematicHandler cinematic);
59-
58+
6059
@Deprecated
6160
public default void initEvent(Application app, Cinematic cinematic) {
6261
initEvent((CinematicHandler) cinematic);
6362
}
64-
63+
6564
/**
6665
* method called when an event is removed from a cinematic
6766
* this method should remove any reference to any external objects.

jme3-core/src/main/java/com/jme3/cinematic/events/SoundEvent.java

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,6 @@ public void initEvent(CinematicHandler cinematic) {
156156
audioNode = new AudioNode(cinematic.getAssetManager(), path,
157157
stream ? AudioData.DataType.Stream : AudioData.DataType.Buffer);
158158
audioNode.setPositional(false);
159-
System.out.println("SoundEvent: loaded sound from " + path + this + audioNode + " for cinematic "
160-
+ getCinematic());
161159
setLoopMode(loopMode);
162160
}
163161

@@ -174,10 +172,7 @@ public void setTime(float time) {
174172

175173
@Override
176174
public void onPlay() {
177-
System.out.println("SoundEvent: play sound from " + path + this + audioNode + " for cinematic "
178-
+ getCinematic());
179175
audioNode.play();
180-
181176
}
182177

183178
@Override
@@ -231,9 +226,6 @@ public void read(JmeImporter im) throws IOException {
231226
InputCapsule ic = im.getCapsule(this);
232227
path = ic.readString("path", "");
233228
stream = ic.readBoolean("stream", false);
234-
AudioNode audioNode = (AudioNode) ic.readSavable("audioNode", null);
235-
if (audioNode != null) {
236-
this.audioNode = audioNode;
237-
}
229+
audioNode = (AudioNode) ic.readSavable("audioNode", null);
238230
}
239231
}

0 commit comments

Comments
 (0)