kopia lustrzana https://github.com/jameshball/osci-render
Change perspective effect to have a 0 value that applies no effect, add reset rotation buttons
rodzic
3b1eca99ec
commit
be2d51c440
|
@ -12,6 +12,7 @@ public enum EffectType {
|
||||||
TRACE_MAX(-1),
|
TRACE_MAX(-1),
|
||||||
SMOOTH(100),
|
SMOOTH(100),
|
||||||
DEPTH_3D(52),
|
DEPTH_3D(52),
|
||||||
|
Z_POS_3D(-1),
|
||||||
ROTATE_SPEED_3D(-1),
|
ROTATE_SPEED_3D(-1),
|
||||||
ROTATE_X(-1),
|
ROTATE_X(-1),
|
||||||
ROTATE_Y(-1),
|
ROTATE_Y(-1),
|
||||||
|
|
|
@ -8,8 +8,9 @@ public class PerspectiveEffect implements SettableEffect {
|
||||||
|
|
||||||
private double zPos = 1.0;
|
private double zPos = 1.0;
|
||||||
private Vector3 baseRotation = new Vector3(Math.PI, Math.PI, 0);
|
private Vector3 baseRotation = new Vector3(Math.PI, Math.PI, 0);
|
||||||
private Vector3 currentRotation = baseRotation;
|
private Vector3 currentRotation = new Vector3();
|
||||||
private double rotateSpeed = 0.0;
|
private double rotateSpeed = 0.0;
|
||||||
|
private double effectScale = 1.0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Vector2 apply(int count, Vector2 vector) {
|
public Vector2 apply(int count, Vector2 vector) {
|
||||||
|
@ -20,13 +21,17 @@ public class PerspectiveEffect implements SettableEffect {
|
||||||
|
|
||||||
double focalLength = 1.0;
|
double focalLength = 1.0;
|
||||||
return new Vector2(
|
return new Vector2(
|
||||||
vertex.x * focalLength / (vertex.z - zPos),
|
(1 - effectScale) * vector.x + effectScale * (vertex.x * focalLength / (vertex.z - zPos)),
|
||||||
vertex.y * focalLength / (vertex.z - zPos)
|
(1 - effectScale) * vector.y + effectScale * (vertex.y * focalLength / (vertex.z - zPos))
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setValue(double value) {
|
public void setValue(double value) {
|
||||||
|
this.effectScale = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setZPos(double value) {
|
||||||
zPos = 1.0 + (value - 0.1) * 3;
|
zPos = 1.0 + (value - 0.1) * 3;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,4 +54,9 @@ public class PerspectiveEffect implements SettableEffect {
|
||||||
public void setRotationZ(double rotateZ) {
|
public void setRotationZ(double rotateZ) {
|
||||||
this.baseRotation = new Vector3(baseRotation.x, baseRotation.y, rotateZ * Math.PI);
|
this.baseRotation = new Vector3(baseRotation.x, baseRotation.y, rotateZ * Math.PI);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void resetRotation() {
|
||||||
|
baseRotation = new Vector3();
|
||||||
|
currentRotation = new Vector3();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -63,6 +63,8 @@ public class EffectsController implements Initializable, SubController {
|
||||||
@FXML
|
@FXML
|
||||||
private EffectComponentGroup rotateZ;
|
private EffectComponentGroup rotateZ;
|
||||||
@FXML
|
@FXML
|
||||||
|
private EffectComponentGroup zPos;
|
||||||
|
@FXML
|
||||||
private EffectComponentGroup translationScale;
|
private EffectComponentGroup translationScale;
|
||||||
@FXML
|
@FXML
|
||||||
private EffectComponentGroup translationSpeed;
|
private EffectComponentGroup translationSpeed;
|
||||||
|
@ -82,6 +84,10 @@ public class EffectsController implements Initializable, SubController {
|
||||||
private CheckBox translateCheckBox;
|
private CheckBox translateCheckBox;
|
||||||
@FXML
|
@FXML
|
||||||
private Button resetTranslationButton;
|
private Button resetTranslationButton;
|
||||||
|
@FXML
|
||||||
|
private Button resetRotationButton;
|
||||||
|
@FXML
|
||||||
|
private Button resetPerspectiveRotationButton;
|
||||||
|
|
||||||
public EffectsController() {
|
public EffectsController() {
|
||||||
this.wobbleEffect = new WobbleEffect(DEFAULT_SAMPLE_RATE);
|
this.wobbleEffect = new WobbleEffect(DEFAULT_SAMPLE_RATE);
|
||||||
|
@ -119,7 +125,7 @@ public class EffectsController implements Initializable, SubController {
|
||||||
|
|
||||||
if (type == EffectType.DEPTH_3D) {
|
if (type == EffectType.DEPTH_3D) {
|
||||||
Platform.runLater(() ->
|
Platform.runLater(() ->
|
||||||
List.of(rotateSpeed3D, rotateX, rotateY, rotateZ).forEach(ecg -> {
|
List.of(rotateSpeed3D, rotateX, rotateY, rotateZ, zPos).forEach(ecg -> {
|
||||||
ecg.controller.slider.setDisable(!checked);
|
ecg.controller.slider.setDisable(!checked);
|
||||||
ecg.controller.spinner.setDisable(!checked);
|
ecg.controller.spinner.setDisable(!checked);
|
||||||
})
|
})
|
||||||
|
@ -162,6 +168,7 @@ public class EffectsController implements Initializable, SubController {
|
||||||
rotateX.controller.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new ConsumerEffect((perspectiveEffect::setRotationX))));
|
rotateX.controller.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new ConsumerEffect((perspectiveEffect::setRotationX))));
|
||||||
rotateY.controller.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new ConsumerEffect((perspectiveEffect::setRotationY))));
|
rotateY.controller.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new ConsumerEffect((perspectiveEffect::setRotationY))));
|
||||||
rotateZ.controller.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new ConsumerEffect((perspectiveEffect::setRotationZ))));
|
rotateZ.controller.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new ConsumerEffect((perspectiveEffect::setRotationZ))));
|
||||||
|
zPos.controller.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new ConsumerEffect((perspectiveEffect::setZPos))));
|
||||||
traceMin.controller.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new ConsumerEffect(audioPlayer::setTraceMin)));
|
traceMin.controller.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new ConsumerEffect(audioPlayer::setTraceMin)));
|
||||||
traceMax.controller.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new ConsumerEffect(audioPlayer::setTraceMax)));
|
traceMax.controller.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new ConsumerEffect(audioPlayer::setTraceMax)));
|
||||||
vectorCancelling.controller.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new VectorCancellingEffect()));
|
vectorCancelling.controller.setAnimator(new EffectAnimator(DEFAULT_SAMPLE_RATE, new VectorCancellingEffect()));
|
||||||
|
@ -213,10 +220,23 @@ public class EffectsController implements Initializable, SubController {
|
||||||
|
|
||||||
translateEllipseCheckBox.selectedProperty().addListener((e, old, ellipse) -> translateEffect.setEllipse(ellipse));
|
translateEllipseCheckBox.selectedProperty().addListener((e, old, ellipse) -> translateEffect.setEllipse(ellipse));
|
||||||
|
|
||||||
List.of(rotateSpeed3D, rotateX, rotateY, rotateZ).forEach(ecg -> {
|
List.of(rotateSpeed3D, rotateX, rotateY, rotateZ, zPos).forEach(ecg -> {
|
||||||
ecg.controller.slider.setDisable(true);
|
ecg.controller.slider.setDisable(true);
|
||||||
ecg.controller.spinner.setDisable(true);
|
ecg.controller.spinner.setDisable(true);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
resetRotationButton.setOnAction(e -> {
|
||||||
|
rotateEffect.resetTheta();
|
||||||
|
rotateSpeed.controller.slider.setValue(0);
|
||||||
|
});
|
||||||
|
|
||||||
|
resetPerspectiveRotationButton.setOnAction(e -> {
|
||||||
|
rotateX.controller.slider.setValue(0);
|
||||||
|
rotateY.controller.slider.setValue(0);
|
||||||
|
rotateZ.controller.slider.setValue(0);
|
||||||
|
rotateSpeed3D.controller.slider.setValue(0);
|
||||||
|
perspectiveEffect.resetRotation();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private List<EffectComponentGroup> effects() {
|
private List<EffectComponentGroup> effects() {
|
||||||
|
@ -230,6 +250,7 @@ public class EffectsController implements Initializable, SubController {
|
||||||
traceMin,
|
traceMin,
|
||||||
traceMax,
|
traceMax,
|
||||||
rotateSpeed3D,
|
rotateSpeed3D,
|
||||||
|
zPos,
|
||||||
rotateX,
|
rotateX,
|
||||||
rotateY,
|
rotateY,
|
||||||
rotateZ,
|
rotateZ,
|
||||||
|
|
|
@ -11,9 +11,9 @@
|
||||||
<?import javafx.scene.layout.VBox?>
|
<?import javafx.scene.layout.VBox?>
|
||||||
<?import sh.ball.gui.components.EffectComponentGroup?>
|
<?import sh.ball.gui.components.EffectComponentGroup?>
|
||||||
|
|
||||||
<ScrollPane hbarPolicy="NEVER" prefHeight="954.0" prefWidth="608.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sh.ball.gui.controller.EffectsController">
|
<ScrollPane hbarPolicy="NEVER" prefHeight="1065.0" prefWidth="608.0" xmlns="http://javafx.com/javafx/17" xmlns:fx="http://javafx.com/fxml/1" fx:controller="sh.ball.gui.controller.EffectsController">
|
||||||
<content>
|
<content>
|
||||||
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="951.0" prefWidth="606.0">
|
<AnchorPane minHeight="0.0" minWidth="0.0" prefHeight="1049.0" prefWidth="606.0">
|
||||||
<children>
|
<children>
|
||||||
<VBox>
|
<VBox>
|
||||||
<children>
|
<children>
|
||||||
|
@ -79,11 +79,22 @@
|
||||||
</padding>
|
</padding>
|
||||||
</Separator>
|
</Separator>
|
||||||
<EffectComponentGroup fx:id="rotateSpeed" increment="0.05" label="rotateSpeed" majorTickUnit="1.0" max="10.0" min="0.0" name="2D Rotate speed" type="ROTATE" value="0.0" />
|
<EffectComponentGroup fx:id="rotateSpeed" increment="0.05" label="rotateSpeed" majorTickUnit="1.0" max="10.0" min="0.0" name="2D Rotate speed" type="ROTATE" value="0.0" />
|
||||||
<EffectComponentGroup fx:id="depthScale" increment="0.005" label="depthScale" majorTickUnit="0.1" max="1.0" min="0.0" name="3D Depth" type="DEPTH_3D" value="0.1" />
|
<AnchorPane prefHeight="34.0" prefWidth="602.0">
|
||||||
|
<children>
|
||||||
|
<Button fx:id="resetRotationButton" layoutX="245.0" layoutY="1.0" mnemonicParsing="false" text="Reset 2D Rotation" />
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
|
<EffectComponentGroup fx:id="depthScale" increment="0.005" label="depthScale" majorTickUnit="0.1" max="1.0" min="0.0" name="3D Perspective" type="DEPTH_3D" value="1.0" />
|
||||||
|
<EffectComponentGroup fx:id="zPos" alwaysEnabled="true" increment="0.005" label="zPos" max="1.0" name="3D Distance" type="Z_POS_3D" value="0.1" />
|
||||||
<EffectComponentGroup fx:id="rotateSpeed3D" alwaysEnabled="true" increment="0.005" label="rotateSpeed3d" majorTickUnit="0.2" max="1.0" min="-1.0" name="3D Rotate speed" type="ROTATE_SPEED_3D" value="0.0" />
|
<EffectComponentGroup fx:id="rotateSpeed3D" alwaysEnabled="true" increment="0.005" label="rotateSpeed3d" majorTickUnit="0.2" max="1.0" min="-1.0" name="3D Rotate speed" type="ROTATE_SPEED_3D" value="0.0" />
|
||||||
<EffectComponentGroup fx:id="rotateX" alwaysEnabled="true" increment="0.01" label="imageRotateX" majorTickUnit="0.2" max="1.0" min="-1.0" name="Rotate x" type="ROTATE_X" value="1.0" />
|
<EffectComponentGroup fx:id="rotateX" alwaysEnabled="true" increment="0.01" label="imageRotateX" majorTickUnit="0.2" max="1.0" min="-1.0" name="Rotate x" type="ROTATE_X" value="1.0" />
|
||||||
<EffectComponentGroup fx:id="rotateY" alwaysEnabled="true" increment="0.01" label="imageRotateY" majorTickUnit="0.2" max="1.0" min="-1.0" name="Rotate y" type="ROTATE_Y" value="1.0" />
|
<EffectComponentGroup fx:id="rotateY" alwaysEnabled="true" increment="0.01" label="imageRotateY" majorTickUnit="0.2" max="1.0" min="-1.0" name="Rotate y" type="ROTATE_Y" value="1.0" />
|
||||||
<EffectComponentGroup fx:id="rotateZ" alwaysEnabled="true" increment="0.01" label="imageRotateZ" majorTickUnit="0.2" max="1.0" min="-1.0" name="Rotate z" type="ROTATE_Z" value="0.0" />
|
<EffectComponentGroup fx:id="rotateZ" alwaysEnabled="true" increment="0.01" label="imageRotateZ" majorTickUnit="0.2" max="1.0" min="-1.0" name="Rotate z" type="ROTATE_Z" value="0.0" />
|
||||||
|
<AnchorPane prefHeight="34.0" prefWidth="602.0">
|
||||||
|
<children>
|
||||||
|
<Button fx:id="resetPerspectiveRotationButton" layoutX="245.0" layoutY="1.0" mnemonicParsing="false" text="Reset 3D Rotation" />
|
||||||
|
</children>
|
||||||
|
</AnchorPane>
|
||||||
<Label alignment="CENTER" prefWidth="601.0" text="Other" textAlignment="JUSTIFY">
|
<Label alignment="CENTER" prefWidth="601.0" text="Other" textAlignment="JUSTIFY">
|
||||||
<padding>
|
<padding>
|
||||||
<Insets bottom="5.0" />
|
<Insets bottom="5.0" />
|
||||||
|
|
Ładowanie…
Reference in New Issue