added first ideas
This commit is contained in:
parent
d287e27776
commit
22bdaaba45
@ -1,56 +1,98 @@
|
|||||||
package main.java.com.ThreeDtest.application;
|
package main.java.com.ThreeDtest.application;
|
||||||
|
|
||||||
|
import javafx.animation.Interpolator;
|
||||||
|
import javafx.animation.RotateTransition;
|
||||||
import javafx.application.Application;
|
import javafx.application.Application;
|
||||||
import javafx.event.ActionEvent;
|
import javafx.event.ActionEvent;
|
||||||
import javafx.fxml.FXML;
|
import javafx.fxml.FXML;
|
||||||
import javafx.fxml.FXMLLoader;
|
import javafx.fxml.FXMLLoader;
|
||||||
|
import javafx.geometry.Pos;
|
||||||
import javafx.stage.Stage;
|
import javafx.stage.Stage;
|
||||||
|
import javafx.util.Duration;
|
||||||
|
import javafx.scene.Node;
|
||||||
|
import javafx.scene.PointLight;
|
||||||
import javafx.scene.Scene;
|
import javafx.scene.Scene;
|
||||||
|
import javafx.scene.SceneAntialiasing;
|
||||||
import javafx.scene.control.Alert;
|
import javafx.scene.control.Alert;
|
||||||
import javafx.scene.control.Alert.AlertType;
|
import javafx.scene.control.Alert.AlertType;
|
||||||
import javafx.scene.control.Button;
|
import javafx.scene.control.Button;
|
||||||
import javafx.scene.control.MenuItem;
|
import javafx.scene.control.MenuItem;
|
||||||
|
import javafx.scene.image.Image;
|
||||||
import javafx.scene.layout.AnchorPane;
|
import javafx.scene.layout.AnchorPane;
|
||||||
|
import javafx.scene.layout.Background;
|
||||||
|
import javafx.scene.layout.BackgroundFill;
|
||||||
|
import javafx.scene.layout.StackPane;
|
||||||
|
import javafx.scene.paint.Color;
|
||||||
|
import javafx.scene.paint.PhongMaterial;
|
||||||
|
import javafx.scene.shape.Box;
|
||||||
|
import javafx.scene.transform.Rotate;
|
||||||
|
|
||||||
public class Main extends Application
|
public class Main extends Application
|
||||||
{
|
{
|
||||||
|
|
||||||
@FXML
|
|
||||||
private AnchorPane mainAnchorpane;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private MenuItem menuItemStart;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private MenuItem menuItemReset;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private MenuItem menuItemClose;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private MenuItem menuItemHilfe;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button startStopButton;
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
private Button resetButton;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void start(Stage primaryStage)
|
public void start(Stage primaryStage)
|
||||||
{
|
{
|
||||||
try {
|
try {
|
||||||
FXMLLoader loader = new FXMLLoader(
|
|
||||||
getClass().getResource("/fxml/MainWindow.fxml"));
|
StackPane pane = new StackPane();
|
||||||
AnchorPane pane = loader.load();
|
|
||||||
primaryStage.setTitle("jFx3Dtest");
|
primaryStage.setTitle("jFx3Dtest");
|
||||||
Scene scene = new Scene(pane);
|
Scene scene = new Scene(pane, 600, 600, true,
|
||||||
/**
|
SceneAntialiasing.BALANCED);
|
||||||
* alle event listener mit fxml-loader
|
|
||||||
*
|
Box myBox = new Box(300, 300, 300);
|
||||||
*/
|
|
||||||
scene.getStylesheets().add(
|
final String DIFFUSE_MAP = "https://upload.wikimedia.org/wikipedia/commons/thumb/a/ac/D%C3%BClmen%2C_Kreuzkapelle_--_2014_--_2731.jpg/640px-D%C3%BClmen%2C_Kreuzkapelle_--_2014_--_2731.jpg";
|
||||||
Main.class.getResource("/css/application.css").toExternalForm());
|
|
||||||
|
Image texture = new Image(DIFFUSE_MAP);
|
||||||
|
|
||||||
|
PhongMaterial textureMaterial = new PhongMaterial();
|
||||||
|
|
||||||
|
textureMaterial.setDiffuseMap(texture);
|
||||||
|
|
||||||
|
myBox.setMaterial(textureMaterial);
|
||||||
|
|
||||||
|
PointLight pointLightFront = new PointLight(Color.WHITE);
|
||||||
|
pointLightFront.setTranslateX(100);
|
||||||
|
pointLightFront.setTranslateY(100);
|
||||||
|
pointLightFront.setTranslateZ(-300);
|
||||||
|
pointLightFront.setRotate(90);
|
||||||
|
|
||||||
|
PointLight pointLightSky = new PointLight(Color.WHITE);
|
||||||
|
pointLightSky.setTranslateX(0);
|
||||||
|
pointLightSky.setTranslateY(-600);
|
||||||
|
pointLightSky.setTranslateZ(0);
|
||||||
|
pointLightSky.setRotate(90);
|
||||||
|
|
||||||
|
PointLight pointLightGround = new PointLight(Color.WHITE);
|
||||||
|
pointLightSky.setTranslateX(0);
|
||||||
|
pointLightSky.setTranslateY(600);
|
||||||
|
pointLightSky.setTranslateZ(0);
|
||||||
|
pointLightSky.setRotate(90);
|
||||||
|
|
||||||
|
pane.getChildren().add(pointLightFront);
|
||||||
|
pane.getChildren().add(pointLightSky);
|
||||||
|
pane.getChildren().add(pointLightGround);
|
||||||
|
|
||||||
|
StackPane.setAlignment(pointLightFront, Pos.CENTER);
|
||||||
|
StackPane.setAlignment(pointLightSky, Pos.CENTER);
|
||||||
|
StackPane.setAlignment(pointLightGround, Pos.CENTER);
|
||||||
|
|
||||||
|
Rotate rxBox = new Rotate(0, 0, 0, 0, Rotate.X_AXIS);
|
||||||
|
Rotate ryBox = new Rotate(0, 0, 0, 0, Rotate.Y_AXIS);
|
||||||
|
Rotate rzBox = new Rotate(0, 0, 0, 0, Rotate.Z_AXIS);
|
||||||
|
rxBox.setAngle(30);
|
||||||
|
ryBox.setAngle(50);
|
||||||
|
rzBox.setAngle(30);
|
||||||
|
myBox.getTransforms().addAll(rxBox, ryBox, rzBox);
|
||||||
|
|
||||||
|
StackPane.setAlignment(myBox, Pos.CENTER);
|
||||||
|
|
||||||
|
rotateAroundYAxis(myBox).play();
|
||||||
|
|
||||||
|
pane.getChildren().add(myBox);
|
||||||
|
|
||||||
primaryStage.setScene(scene);
|
primaryStage.setScene(scene);
|
||||||
primaryStage.show();
|
primaryStage.show();
|
||||||
|
|
||||||
@ -59,44 +101,17 @@ public class Main extends Application
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FXML
|
private RotateTransition rotateAroundYAxis(Node node)
|
||||||
public void menuItemStartAction(ActionEvent event)
|
|
||||||
{
|
{
|
||||||
|
RotateTransition rotate = new RotateTransition(Duration.seconds(36),
|
||||||
|
node);
|
||||||
|
rotate.setAxis(Rotate.Y_AXIS);
|
||||||
|
rotate.setFromAngle(360);
|
||||||
|
rotate.setToAngle(0);
|
||||||
|
rotate.setInterpolator(Interpolator.LINEAR);
|
||||||
|
rotate.setCycleCount(RotateTransition.INDEFINITE);
|
||||||
|
|
||||||
}
|
return rotate;
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void menuItemResetAction(ActionEvent event)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void menuItemCloseAction(ActionEvent event)
|
|
||||||
{
|
|
||||||
System.exit(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void startStopButtonAction(ActionEvent event)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void resetButtonAction(ActionEvent event)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@FXML
|
|
||||||
public void menuItemHilfeAction(ActionEvent event)
|
|
||||||
{
|
|
||||||
Alert alert = new Alert(AlertType.INFORMATION);
|
|
||||||
alert.setTitle("Alert");
|
|
||||||
alert.setHeaderText("Some info");
|
|
||||||
alert.setContentText("Author: localhorst@mosad.xyz");
|
|
||||||
alert.showAndWait();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void main(String[] args)
|
public static void main(String[] args)
|
||||||
@ -104,4 +119,4 @@ public class Main extends Application
|
|||||||
launch(args);
|
launch(args);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -1 +0,0 @@
|
|||||||
/* JavaFX CSS - Leave this comment until you have at least create one rule which uses -fx-Property */
|
|
@ -1,38 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
|
|
||||||
<?import javafx.scene.control.Menu?>
|
|
||||||
<?import javafx.scene.control.MenuBar?>
|
|
||||||
<?import javafx.scene.control.MenuItem?>
|
|
||||||
<?import javafx.scene.control.SeparatorMenuItem?>
|
|
||||||
<?import javafx.scene.layout.AnchorPane?>
|
|
||||||
<?import javafx.scene.layout.BorderPane?>
|
|
||||||
<?import javafx.scene.layout.HBox?>
|
|
||||||
|
|
||||||
<AnchorPane fx:id="mainAnchorpane" maxHeight="400.0" maxWidth="500.0" minHeight="400.0" minWidth="500.0" prefHeight="400.0" prefWidth="500.0" xmlns="http://javafx.com/javafx/9" xmlns:fx="http://javafx.com/fxml/1" fx:controller="main.java.com.ThreeDtest.application.Main">
|
|
||||||
<children>
|
|
||||||
<BorderPane prefHeight="400.0" prefWidth="500.0">
|
|
||||||
<bottom>
|
|
||||||
<HBox prefHeight="100.0" prefWidth="200.0" BorderPane.alignment="CENTER" />
|
|
||||||
</bottom>
|
|
||||||
<top>
|
|
||||||
<MenuBar BorderPane.alignment="CENTER">
|
|
||||||
<menus>
|
|
||||||
<Menu mnemonicParsing="false" text="Aktion">
|
|
||||||
<items>
|
|
||||||
<MenuItem fx:id="menuItemStart" mnemonicParsing="false" onAction="#menuItemStartAction" text="Start" />
|
|
||||||
<MenuItem fx:id="menuItemReset" mnemonicParsing="false" onAction="#menuItemResetAction" text="Reset" />
|
|
||||||
<SeparatorMenuItem mnemonicParsing="false" />
|
|
||||||
<MenuItem fx:id="menuItemClose" mnemonicParsing="false" onAction="#menuItemCloseAction" text="Beenden" />
|
|
||||||
</items>
|
|
||||||
</Menu>
|
|
||||||
<Menu mnemonicParsing="false" text="Hilfe">
|
|
||||||
<items>
|
|
||||||
<MenuItem fx:id="menuItemHilfe" mnemonicParsing="false" onAction="#menuItemHilfeAction" text="Info" />
|
|
||||||
</items>
|
|
||||||
</Menu>
|
|
||||||
</menus>
|
|
||||||
</MenuBar>
|
|
||||||
</top>
|
|
||||||
</BorderPane>
|
|
||||||
</children>
|
|
||||||
</AnchorPane>
|
|
Loading…
Reference in New Issue
Block a user