diff --git a/src/main/java/sh/ball/audio/FrameSet.java b/src/main/java/sh/ball/audio/FrameSet.java index 5771b86..963e738 100644 --- a/src/main/java/sh/ball/audio/FrameSet.java +++ b/src/main/java/sh/ball/audio/FrameSet.java @@ -1,12 +1,8 @@ package sh.ball.audio; -import sh.ball.parser.obj.Listener; - public interface FrameSet { T next(); void setFrameSettings(Object settings); - - void addListener(Listener listener); } diff --git a/src/main/java/sh/ball/gui/Controller.java b/src/main/java/sh/ball/gui/Controller.java index d685747..617cc24 100644 --- a/src/main/java/sh/ball/gui/Controller.java +++ b/src/main/java/sh/ball/gui/Controller.java @@ -44,14 +44,13 @@ import sh.ball.audio.engine.ConglomerateAudioEngine; import sh.ball.audio.midi.MidiCommunicator; import sh.ball.audio.midi.MidiListener; import sh.ball.engine.Vector3; -import sh.ball.parser.obj.Listener; import sh.ball.parser.obj.ObjSettingsFactory; import sh.ball.parser.obj.ObjParser; import sh.ball.parser.ParserFactory; import sh.ball.shapes.Shape; import sh.ball.shapes.Vector2; -public class Controller implements Initializable, FrequencyListener, Listener, MidiListener { +public class Controller implements Initializable, FrequencyListener, MidiListener { private static final InputStream DEFAULT_OBJ = Controller.class.getResourceAsStream("/models/cube.obj"); private static final double MAX_FREQUENCY = 12000; @@ -195,7 +194,6 @@ public class Controller implements Initializable, FrequencyListener, Listener, M frameSets.add(frames); frameSetPaths.add("cube.obj"); currentFrameSet = 0; - frames.addListener(this); this.producer = new FrameProducer<>(audioPlayer, frames); this.defaultDevice = audioPlayer.getDefaultDevice(); if (defaultDevice == null) { @@ -502,11 +500,17 @@ public class Controller implements Initializable, FrequencyListener, Listener, M } private void updateCameraPos() { - producer.setFrameSettings(ObjSettingsFactory.cameraPosition(new Vector3( + Vector3 vector = new Vector3( tryParse(cameraXTextField.getText()), tryParse(cameraYTextField.getText()), tryParse(cameraZTextField.getText()) - ))); + ); + + producer.setFrameSettings(ObjSettingsFactory.cameraPosition(vector)); + + cameraXTextField.setText(String.valueOf(round(vector.getX(), 3))); + cameraYTextField.setText(String.valueOf(round(vector.getY(), 3))); + cameraZTextField.setText(String.valueOf(round(vector.getZ(), 3))); } private double tryParse(String value) { @@ -530,7 +534,6 @@ public class Controller implements Initializable, FrequencyListener, Listener, M private void changeFrameSet() { FrameSet> frames = frameSets.get(currentFrameSet); producer.stop(); - frames.addListener(this); producer = new FrameProducer<>(audioPlayer, frames); updateObjectRotateSpeed(); @@ -623,17 +626,6 @@ public class Controller implements Initializable, FrequencyListener, Listener, M ); } - @Override - public void update(Object pos) { - if (pos instanceof Vector3 vector) { - Platform.runLater(() -> { - cameraXTextField.setText(String.valueOf(round(vector.getX(), 3))); - cameraYTextField.setText(String.valueOf(round(vector.getY(), 3))); - cameraZTextField.setText(String.valueOf(round(vector.getZ(), 3))); - }); - } - } - private static double round(double value, double places) { if (places < 0) throw new IllegalArgumentException(); diff --git a/src/main/java/sh/ball/parser/obj/Listener.java b/src/main/java/sh/ball/parser/obj/Listener.java deleted file mode 100644 index cb973ed..0000000 --- a/src/main/java/sh/ball/parser/obj/Listener.java +++ /dev/null @@ -1,6 +0,0 @@ -package sh.ball.parser.obj; - -public interface Listener { - - void update(Object obj); -} diff --git a/src/main/java/sh/ball/parser/obj/ObjFrameSet.java b/src/main/java/sh/ball/parser/obj/ObjFrameSet.java index 6b891a0..917a36c 100644 --- a/src/main/java/sh/ball/parser/obj/ObjFrameSet.java +++ b/src/main/java/sh/ball/parser/obj/ObjFrameSet.java @@ -13,7 +13,6 @@ public class ObjFrameSet implements FrameSet> { private final WorldObject object; private final Camera camera; - private final List listeners = new ArrayList<>(); private Vector3 rotation = new Vector3(); private Double rotateSpeed = 0.0; @@ -23,20 +22,6 @@ public class ObjFrameSet implements FrameSet> { this.camera = camera; } - @Override - public void addListener(Listener listener) { - listeners.add(listener); - notifyListener(listener); - } - - private void notifyListener(Listener listener) { - listener.update(camera.getPos()); - } - - private void notifyListeners() { - listeners.forEach(this::notifyListener); - } - @Override public List next() { if (rotateSpeed == 0) { @@ -56,7 +41,6 @@ public class ObjFrameSet implements FrameSet> { } if (obj.cameraPos != null && camera.getPos() != obj.cameraPos) { camera.setPos(obj.cameraPos); - notifyListeners(); } if (obj.rotation != null) { this.rotation = obj.rotation; diff --git a/src/main/java/sh/ball/shapes/ShapeFrameSet.java b/src/main/java/sh/ball/shapes/ShapeFrameSet.java index 5186f95..95b04a7 100644 --- a/src/main/java/sh/ball/shapes/ShapeFrameSet.java +++ b/src/main/java/sh/ball/shapes/ShapeFrameSet.java @@ -1,7 +1,6 @@ package sh.ball.shapes; import sh.ball.audio.FrameSet; -import sh.ball.parser.obj.Listener; import java.util.List; @@ -20,7 +19,4 @@ public class ShapeFrameSet implements FrameSet> { @Override public void setFrameSettings(Object settings) {} - - @Override - public void addListener(Listener listener) { } } diff --git a/src/main/resources/fxml/osci-render.fxml b/src/main/resources/fxml/osci-render.fxml index fcbac15..098f34f 100644 --- a/src/main/resources/fxml/osci-render.fxml +++ b/src/main/resources/fxml/osci-render.fxml @@ -42,11 +42,11 @@